babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421
  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. private BJSNODEMATERIALEDITOR;
  60273. /** Get the inspector from bundle or global */
  60274. private _getGlobalNodeMaterialEditor;
  60275. /**
  60276. * Snippet ID if the material was created from the snippet server
  60277. */
  60278. snippetId: string;
  60279. /**
  60280. * Gets or sets data used by visual editor
  60281. * @see https://nme.babylonjs.com
  60282. */
  60283. editorData: any;
  60284. /**
  60285. * 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)
  60286. */
  60287. ignoreAlpha: boolean;
  60288. /**
  60289. * Defines the maximum number of lights that can be used in the material
  60290. */
  60291. maxSimultaneousLights: number;
  60292. /**
  60293. * Observable raised when the material is built
  60294. */
  60295. onBuildObservable: Observable<NodeMaterial>;
  60296. /**
  60297. * Gets or sets the root nodes of the material vertex shader
  60298. */
  60299. _vertexOutputNodes: NodeMaterialBlock[];
  60300. /**
  60301. * Gets or sets the root nodes of the material fragment (pixel) shader
  60302. */
  60303. _fragmentOutputNodes: NodeMaterialBlock[];
  60304. /** Gets or sets options to control the node material overall behavior */
  60305. get options(): INodeMaterialOptions;
  60306. set options(options: INodeMaterialOptions);
  60307. /**
  60308. * Default configuration related to image processing available in the standard Material.
  60309. */
  60310. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60311. /**
  60312. * Gets the image processing configuration used either in this material.
  60313. */
  60314. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60315. /**
  60316. * Sets the Default image processing configuration used either in the this material.
  60317. *
  60318. * If sets to null, the scene one is in use.
  60319. */
  60320. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60321. /**
  60322. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60323. */
  60324. attachedBlocks: NodeMaterialBlock[];
  60325. /**
  60326. * Create a new node based material
  60327. * @param name defines the material name
  60328. * @param scene defines the hosting scene
  60329. * @param options defines creation option
  60330. */
  60331. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60332. /**
  60333. * Gets the current class name of the material e.g. "NodeMaterial"
  60334. * @returns the class name
  60335. */
  60336. getClassName(): string;
  60337. /**
  60338. * Keep track of the image processing observer to allow dispose and replace.
  60339. */
  60340. private _imageProcessingObserver;
  60341. /**
  60342. * Attaches a new image processing configuration to the Standard Material.
  60343. * @param configuration
  60344. */
  60345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60346. /**
  60347. * Get a block by its name
  60348. * @param name defines the name of the block to retrieve
  60349. * @returns the required block or null if not found
  60350. */
  60351. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60352. /**
  60353. * Get a block by its name
  60354. * @param predicate defines the predicate used to find the good candidate
  60355. * @returns the required block or null if not found
  60356. */
  60357. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60358. /**
  60359. * Get an input block by its name
  60360. * @param predicate defines the predicate used to find the good candidate
  60361. * @returns the required input block or null if not found
  60362. */
  60363. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60364. /**
  60365. * Gets the list of input blocks attached to this material
  60366. * @returns an array of InputBlocks
  60367. */
  60368. getInputBlocks(): InputBlock[];
  60369. /**
  60370. * Adds a new optimizer to the list of optimizers
  60371. * @param optimizer defines the optimizers to add
  60372. * @returns the current material
  60373. */
  60374. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60375. /**
  60376. * Remove an optimizer from the list of optimizers
  60377. * @param optimizer defines the optimizers to remove
  60378. * @returns the current material
  60379. */
  60380. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60381. /**
  60382. * Add a new block to the list of output nodes
  60383. * @param node defines the node to add
  60384. * @returns the current material
  60385. */
  60386. addOutputNode(node: NodeMaterialBlock): this;
  60387. /**
  60388. * Remove a block from the list of root nodes
  60389. * @param node defines the node to remove
  60390. * @returns the current material
  60391. */
  60392. removeOutputNode(node: NodeMaterialBlock): this;
  60393. private _addVertexOutputNode;
  60394. private _removeVertexOutputNode;
  60395. private _addFragmentOutputNode;
  60396. private _removeFragmentOutputNode;
  60397. /**
  60398. * Specifies if the material will require alpha blending
  60399. * @returns a boolean specifying if alpha blending is needed
  60400. */
  60401. needAlphaBlending(): boolean;
  60402. /**
  60403. * Specifies if this material should be rendered in alpha test mode
  60404. * @returns a boolean specifying if an alpha test is needed.
  60405. */
  60406. needAlphaTesting(): boolean;
  60407. private _initializeBlock;
  60408. private _resetDualBlocks;
  60409. /**
  60410. * Remove a block from the current node material
  60411. * @param block defines the block to remove
  60412. */
  60413. removeBlock(block: NodeMaterialBlock): void;
  60414. /**
  60415. * Build the material and generates the inner effect
  60416. * @param verbose defines if the build should log activity
  60417. */
  60418. build(verbose?: boolean): void;
  60419. /**
  60420. * Runs an otpimization phase to try to improve the shader code
  60421. */
  60422. optimize(): void;
  60423. private _prepareDefinesForAttributes;
  60424. /**
  60425. * Get if the submesh is ready to be used and all its information available.
  60426. * Child classes can use it to update shaders
  60427. * @param mesh defines the mesh to check
  60428. * @param subMesh defines which submesh to check
  60429. * @param useInstances specifies that instances should be used
  60430. * @returns a boolean indicating that the submesh is ready or not
  60431. */
  60432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60433. /**
  60434. * Get a string representing the shaders built by the current node graph
  60435. */
  60436. get compiledShaders(): string;
  60437. /**
  60438. * Binds the world matrix to the material
  60439. * @param world defines the world transformation matrix
  60440. */
  60441. bindOnlyWorldMatrix(world: Matrix): void;
  60442. /**
  60443. * Binds the submesh to this material by preparing the effect and shader to draw
  60444. * @param world defines the world transformation matrix
  60445. * @param mesh defines the mesh containing the submesh
  60446. * @param subMesh defines the submesh to bind the material to
  60447. */
  60448. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60449. /**
  60450. * Gets the active textures from the material
  60451. * @returns an array of textures
  60452. */
  60453. getActiveTextures(): BaseTexture[];
  60454. /**
  60455. * Gets the list of texture blocks
  60456. * @returns an array of texture blocks
  60457. */
  60458. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60459. /**
  60460. * Specifies if the material uses a texture
  60461. * @param texture defines the texture to check against the material
  60462. * @returns a boolean specifying if the material uses the texture
  60463. */
  60464. hasTexture(texture: BaseTexture): boolean;
  60465. /**
  60466. * Disposes the material
  60467. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60468. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60469. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60470. */
  60471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60472. /** Creates the node editor window. */
  60473. private _createNodeEditor;
  60474. /**
  60475. * Launch the node material editor
  60476. * @param config Define the configuration of the editor
  60477. * @return a promise fulfilled when the node editor is visible
  60478. */
  60479. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60480. /**
  60481. * Clear the current material
  60482. */
  60483. clear(): void;
  60484. /**
  60485. * Clear the current material and set it to a default state
  60486. */
  60487. setToDefault(): void;
  60488. /**
  60489. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60490. * @param url defines the url to load from
  60491. * @returns a promise that will fullfil when the material is fully loaded
  60492. */
  60493. loadAsync(url: string): Promise<void>;
  60494. private _gatherBlocks;
  60495. /**
  60496. * Generate a string containing the code declaration required to create an equivalent of this material
  60497. * @returns a string
  60498. */
  60499. generateCode(): string;
  60500. /**
  60501. * Serializes this material in a JSON representation
  60502. * @returns the serialized material object
  60503. */
  60504. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60505. private _restoreConnections;
  60506. /**
  60507. * Clear the current graph and load a new one from a serialization object
  60508. * @param source defines the JSON representation of the material
  60509. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60510. */
  60511. loadFromSerialization(source: any, rootUrl?: string): void;
  60512. /**
  60513. * Makes a duplicate of the current material.
  60514. * @param name - name to use for the new material.
  60515. */
  60516. clone(name: string): NodeMaterial;
  60517. /**
  60518. * Creates a node material from parsed material data
  60519. * @param source defines the JSON representation of the material
  60520. * @param scene defines the hosting scene
  60521. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60522. * @returns a new node material
  60523. */
  60524. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60525. /**
  60526. * Creates a node material from a snippet saved in a remote file
  60527. * @param name defines the name of the material to create
  60528. * @param url defines the url to load from
  60529. * @param scene defines the hosting scene
  60530. * @returns a promise that will resolve to the new node material
  60531. */
  60532. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60533. /**
  60534. * Creates a node material from a snippet saved by the node material editor
  60535. * @param snippetId defines the snippet to load
  60536. * @param scene defines the hosting scene
  60537. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60538. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60539. * @returns a promise that will resolve to the new node material
  60540. */
  60541. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60542. /**
  60543. * Creates a new node material set to default basic configuration
  60544. * @param name defines the name of the material
  60545. * @param scene defines the hosting scene
  60546. * @returns a new NodeMaterial
  60547. */
  60548. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60549. }
  60550. }
  60551. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60554. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60557. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60558. import { Effect } from "babylonjs/Materials/effect";
  60559. import { Mesh } from "babylonjs/Meshes/mesh";
  60560. import { Nullable } from "babylonjs/types";
  60561. import { Texture } from "babylonjs/Materials/Textures/texture";
  60562. import { Scene } from "babylonjs/scene";
  60563. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60564. /**
  60565. * Block used to read a texture from a sampler
  60566. */
  60567. export class TextureBlock extends NodeMaterialBlock {
  60568. private _defineName;
  60569. private _linearDefineName;
  60570. private _tempTextureRead;
  60571. private _samplerName;
  60572. private _transformedUVName;
  60573. private _textureTransformName;
  60574. private _textureInfoName;
  60575. private _mainUVName;
  60576. private _mainUVDefineName;
  60577. /**
  60578. * Gets or sets the texture associated with the node
  60579. */
  60580. texture: Nullable<Texture>;
  60581. /**
  60582. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60583. */
  60584. convertToGammaSpace: boolean;
  60585. /**
  60586. * Create a new TextureBlock
  60587. * @param name defines the block name
  60588. */
  60589. constructor(name: string);
  60590. /**
  60591. * Gets the current class name
  60592. * @returns the class name
  60593. */
  60594. getClassName(): string;
  60595. /**
  60596. * Gets the uv input component
  60597. */
  60598. get uv(): NodeMaterialConnectionPoint;
  60599. /**
  60600. * Gets the rgba output component
  60601. */
  60602. get rgba(): NodeMaterialConnectionPoint;
  60603. /**
  60604. * Gets the rgb output component
  60605. */
  60606. get rgb(): NodeMaterialConnectionPoint;
  60607. /**
  60608. * Gets the r output component
  60609. */
  60610. get r(): NodeMaterialConnectionPoint;
  60611. /**
  60612. * Gets the g output component
  60613. */
  60614. get g(): NodeMaterialConnectionPoint;
  60615. /**
  60616. * Gets the b output component
  60617. */
  60618. get b(): NodeMaterialConnectionPoint;
  60619. /**
  60620. * Gets the a output component
  60621. */
  60622. get a(): NodeMaterialConnectionPoint;
  60623. get target(): NodeMaterialBlockTargets;
  60624. autoConfigure(material: NodeMaterial): void;
  60625. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60626. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60627. isReady(): boolean;
  60628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60629. private get _isMixed();
  60630. private _injectVertexCode;
  60631. private _writeTextureRead;
  60632. private _writeOutput;
  60633. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60634. protected _dumpPropertiesCode(): string;
  60635. serialize(): any;
  60636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60637. }
  60638. }
  60639. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60642. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60643. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60644. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60645. import { Scene } from "babylonjs/scene";
  60646. /**
  60647. * Class used to store shared data between 2 NodeMaterialBuildState
  60648. */
  60649. export class NodeMaterialBuildStateSharedData {
  60650. /**
  60651. * Gets the list of emitted varyings
  60652. */
  60653. temps: string[];
  60654. /**
  60655. * Gets the list of emitted varyings
  60656. */
  60657. varyings: string[];
  60658. /**
  60659. * Gets the varying declaration string
  60660. */
  60661. varyingDeclaration: string;
  60662. /**
  60663. * Input blocks
  60664. */
  60665. inputBlocks: InputBlock[];
  60666. /**
  60667. * Input blocks
  60668. */
  60669. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60670. /**
  60671. * Bindable blocks (Blocks that need to set data to the effect)
  60672. */
  60673. bindableBlocks: NodeMaterialBlock[];
  60674. /**
  60675. * List of blocks that can provide a compilation fallback
  60676. */
  60677. blocksWithFallbacks: NodeMaterialBlock[];
  60678. /**
  60679. * List of blocks that can provide a define update
  60680. */
  60681. blocksWithDefines: NodeMaterialBlock[];
  60682. /**
  60683. * List of blocks that can provide a repeatable content
  60684. */
  60685. repeatableContentBlocks: NodeMaterialBlock[];
  60686. /**
  60687. * List of blocks that can provide a dynamic list of uniforms
  60688. */
  60689. dynamicUniformBlocks: NodeMaterialBlock[];
  60690. /**
  60691. * List of blocks that can block the isReady function for the material
  60692. */
  60693. blockingBlocks: NodeMaterialBlock[];
  60694. /**
  60695. * Gets the list of animated inputs
  60696. */
  60697. animatedInputs: InputBlock[];
  60698. /**
  60699. * Build Id used to avoid multiple recompilations
  60700. */
  60701. buildId: number;
  60702. /** List of emitted variables */
  60703. variableNames: {
  60704. [key: string]: number;
  60705. };
  60706. /** List of emitted defines */
  60707. defineNames: {
  60708. [key: string]: number;
  60709. };
  60710. /** Should emit comments? */
  60711. emitComments: boolean;
  60712. /** Emit build activity */
  60713. verbose: boolean;
  60714. /** Gets or sets the hosting scene */
  60715. scene: Scene;
  60716. /**
  60717. * Gets the compilation hints emitted at compilation time
  60718. */
  60719. hints: {
  60720. needWorldViewMatrix: boolean;
  60721. needWorldViewProjectionMatrix: boolean;
  60722. needAlphaBlending: boolean;
  60723. needAlphaTesting: boolean;
  60724. };
  60725. /**
  60726. * List of compilation checks
  60727. */
  60728. checks: {
  60729. emitVertex: boolean;
  60730. emitFragment: boolean;
  60731. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60732. };
  60733. /** Creates a new shared data */
  60734. constructor();
  60735. /**
  60736. * Emits console errors and exceptions if there is a failing check
  60737. */
  60738. emitErrors(): void;
  60739. }
  60740. }
  60741. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60742. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60743. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60744. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60745. /**
  60746. * Class used to store node based material build state
  60747. */
  60748. export class NodeMaterialBuildState {
  60749. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60750. supportUniformBuffers: boolean;
  60751. /**
  60752. * Gets the list of emitted attributes
  60753. */
  60754. attributes: string[];
  60755. /**
  60756. * Gets the list of emitted uniforms
  60757. */
  60758. uniforms: string[];
  60759. /**
  60760. * Gets the list of emitted constants
  60761. */
  60762. constants: string[];
  60763. /**
  60764. * Gets the list of emitted samplers
  60765. */
  60766. samplers: string[];
  60767. /**
  60768. * Gets the list of emitted functions
  60769. */
  60770. functions: {
  60771. [key: string]: string;
  60772. };
  60773. /**
  60774. * Gets the list of emitted extensions
  60775. */
  60776. extensions: {
  60777. [key: string]: string;
  60778. };
  60779. /**
  60780. * Gets the target of the compilation state
  60781. */
  60782. target: NodeMaterialBlockTargets;
  60783. /**
  60784. * Gets the list of emitted counters
  60785. */
  60786. counters: {
  60787. [key: string]: number;
  60788. };
  60789. /**
  60790. * Shared data between multiple NodeMaterialBuildState instances
  60791. */
  60792. sharedData: NodeMaterialBuildStateSharedData;
  60793. /** @hidden */
  60794. _vertexState: NodeMaterialBuildState;
  60795. /** @hidden */
  60796. _attributeDeclaration: string;
  60797. /** @hidden */
  60798. _uniformDeclaration: string;
  60799. /** @hidden */
  60800. _constantDeclaration: string;
  60801. /** @hidden */
  60802. _samplerDeclaration: string;
  60803. /** @hidden */
  60804. _varyingTransfer: string;
  60805. private _repeatableContentAnchorIndex;
  60806. /** @hidden */
  60807. _builtCompilationString: string;
  60808. /**
  60809. * Gets the emitted compilation strings
  60810. */
  60811. compilationString: string;
  60812. /**
  60813. * Finalize the compilation strings
  60814. * @param state defines the current compilation state
  60815. */
  60816. finalize(state: NodeMaterialBuildState): void;
  60817. /** @hidden */
  60818. get _repeatableContentAnchor(): string;
  60819. /** @hidden */
  60820. _getFreeVariableName(prefix: string): string;
  60821. /** @hidden */
  60822. _getFreeDefineName(prefix: string): string;
  60823. /** @hidden */
  60824. _excludeVariableName(name: string): void;
  60825. /** @hidden */
  60826. _emit2DSampler(name: string): void;
  60827. /** @hidden */
  60828. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60829. /** @hidden */
  60830. _emitExtension(name: string, extension: string): void;
  60831. /** @hidden */
  60832. _emitFunction(name: string, code: string, comments: string): void;
  60833. /** @hidden */
  60834. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60835. replaceStrings?: {
  60836. search: RegExp;
  60837. replace: string;
  60838. }[];
  60839. repeatKey?: string;
  60840. }): string;
  60841. /** @hidden */
  60842. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60843. repeatKey?: string;
  60844. removeAttributes?: boolean;
  60845. removeUniforms?: boolean;
  60846. removeVaryings?: boolean;
  60847. removeIfDef?: boolean;
  60848. replaceStrings?: {
  60849. search: RegExp;
  60850. replace: string;
  60851. }[];
  60852. }, storeKey?: string): void;
  60853. /** @hidden */
  60854. _registerTempVariable(name: string): boolean;
  60855. /** @hidden */
  60856. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60857. /** @hidden */
  60858. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60859. /** @hidden */
  60860. _emitFloat(value: number): string;
  60861. }
  60862. }
  60863. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60864. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60866. import { Nullable } from "babylonjs/types";
  60867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60868. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60869. import { Effect } from "babylonjs/Materials/effect";
  60870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60871. import { Mesh } from "babylonjs/Meshes/mesh";
  60872. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60873. import { Scene } from "babylonjs/scene";
  60874. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60875. /**
  60876. * Defines a block that can be used inside a node based material
  60877. */
  60878. export class NodeMaterialBlock {
  60879. private _buildId;
  60880. private _buildTarget;
  60881. private _target;
  60882. private _isFinalMerger;
  60883. private _isInput;
  60884. protected _isUnique: boolean;
  60885. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60886. inputsAreExclusive: boolean;
  60887. /** @hidden */
  60888. _codeVariableName: string;
  60889. /** @hidden */
  60890. _inputs: NodeMaterialConnectionPoint[];
  60891. /** @hidden */
  60892. _outputs: NodeMaterialConnectionPoint[];
  60893. /** @hidden */
  60894. _preparationId: number;
  60895. /**
  60896. * Gets or sets the name of the block
  60897. */
  60898. name: string;
  60899. /**
  60900. * Gets or sets the unique id of the node
  60901. */
  60902. uniqueId: number;
  60903. /**
  60904. * Gets or sets the comments associated with this block
  60905. */
  60906. comments: string;
  60907. /**
  60908. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60909. */
  60910. get isUnique(): boolean;
  60911. /**
  60912. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60913. */
  60914. get isFinalMerger(): boolean;
  60915. /**
  60916. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60917. */
  60918. get isInput(): boolean;
  60919. /**
  60920. * Gets or sets the build Id
  60921. */
  60922. get buildId(): number;
  60923. set buildId(value: number);
  60924. /**
  60925. * Gets or sets the target of the block
  60926. */
  60927. get target(): NodeMaterialBlockTargets;
  60928. set target(value: NodeMaterialBlockTargets);
  60929. /**
  60930. * Gets the list of input points
  60931. */
  60932. get inputs(): NodeMaterialConnectionPoint[];
  60933. /** Gets the list of output points */
  60934. get outputs(): NodeMaterialConnectionPoint[];
  60935. /**
  60936. * Find an input by its name
  60937. * @param name defines the name of the input to look for
  60938. * @returns the input or null if not found
  60939. */
  60940. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60941. /**
  60942. * Find an output by its name
  60943. * @param name defines the name of the outputto look for
  60944. * @returns the output or null if not found
  60945. */
  60946. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60947. /**
  60948. * Creates a new NodeMaterialBlock
  60949. * @param name defines the block name
  60950. * @param target defines the target of that block (Vertex by default)
  60951. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60952. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60953. */
  60954. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60955. /**
  60956. * Initialize the block and prepare the context for build
  60957. * @param state defines the state that will be used for the build
  60958. */
  60959. initialize(state: NodeMaterialBuildState): void;
  60960. /**
  60961. * Bind data to effect. Will only be called for blocks with isBindable === true
  60962. * @param effect defines the effect to bind data to
  60963. * @param nodeMaterial defines the hosting NodeMaterial
  60964. * @param mesh defines the mesh that will be rendered
  60965. */
  60966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60967. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60968. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60969. protected _writeFloat(value: number): string;
  60970. /**
  60971. * Gets the current class name e.g. "NodeMaterialBlock"
  60972. * @returns the class name
  60973. */
  60974. getClassName(): string;
  60975. /**
  60976. * Register a new input. Must be called inside a block constructor
  60977. * @param name defines the connection point name
  60978. * @param type defines the connection point type
  60979. * @param isOptional defines a boolean indicating that this input can be omitted
  60980. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60981. * @returns the current block
  60982. */
  60983. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60984. /**
  60985. * Register a new output. Must be called inside a block constructor
  60986. * @param name defines the connection point name
  60987. * @param type defines the connection point type
  60988. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60989. * @returns the current block
  60990. */
  60991. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60992. /**
  60993. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60994. * @param forOutput defines an optional connection point to check compatibility with
  60995. * @returns the first available input or null
  60996. */
  60997. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60998. /**
  60999. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61000. * @param forBlock defines an optional block to check compatibility with
  61001. * @returns the first available input or null
  61002. */
  61003. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61004. /**
  61005. * Gets the sibling of the given output
  61006. * @param current defines the current output
  61007. * @returns the next output in the list or null
  61008. */
  61009. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61010. /**
  61011. * Connect current block with another block
  61012. * @param other defines the block to connect with
  61013. * @param options define the various options to help pick the right connections
  61014. * @returns the current block
  61015. */
  61016. connectTo(other: NodeMaterialBlock, options?: {
  61017. input?: string;
  61018. output?: string;
  61019. outputSwizzle?: string;
  61020. }): this | undefined;
  61021. protected _buildBlock(state: NodeMaterialBuildState): void;
  61022. /**
  61023. * Add uniforms, samplers and uniform buffers at compilation time
  61024. * @param state defines the state to update
  61025. * @param nodeMaterial defines the node material requesting the update
  61026. * @param defines defines the material defines to update
  61027. * @param uniformBuffers defines the list of uniform buffer names
  61028. */
  61029. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61030. /**
  61031. * Add potential fallbacks if shader compilation fails
  61032. * @param mesh defines the mesh to be rendered
  61033. * @param fallbacks defines the current prioritized list of fallbacks
  61034. */
  61035. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61036. /**
  61037. * Initialize defines for shader compilation
  61038. * @param mesh defines the mesh to be rendered
  61039. * @param nodeMaterial defines the node material requesting the update
  61040. * @param defines defines the material defines to update
  61041. * @param useInstances specifies that instances should be used
  61042. */
  61043. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61044. /**
  61045. * Update defines for shader compilation
  61046. * @param mesh defines the mesh to be rendered
  61047. * @param nodeMaterial defines the node material requesting the update
  61048. * @param defines defines the material defines to update
  61049. * @param useInstances specifies that instances should be used
  61050. */
  61051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61052. /**
  61053. * Lets the block try to connect some inputs automatically
  61054. * @param material defines the hosting NodeMaterial
  61055. */
  61056. autoConfigure(material: NodeMaterial): void;
  61057. /**
  61058. * Function called when a block is declared as repeatable content generator
  61059. * @param vertexShaderState defines the current compilation state for the vertex shader
  61060. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61061. * @param mesh defines the mesh to be rendered
  61062. * @param defines defines the material defines to update
  61063. */
  61064. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61065. /**
  61066. * Checks if the block is ready
  61067. * @param mesh defines the mesh to be rendered
  61068. * @param nodeMaterial defines the node material requesting the update
  61069. * @param defines defines the material defines to update
  61070. * @param useInstances specifies that instances should be used
  61071. * @returns true if the block is ready
  61072. */
  61073. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61074. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61075. private _processBuild;
  61076. /**
  61077. * Compile the current node and generate the shader code
  61078. * @param state defines the current compilation state (uniforms, samplers, current string)
  61079. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61080. * @returns true if already built
  61081. */
  61082. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61083. protected _inputRename(name: string): string;
  61084. protected _outputRename(name: string): string;
  61085. protected _dumpPropertiesCode(): string;
  61086. /** @hidden */
  61087. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61088. /** @hidden */
  61089. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61090. /**
  61091. * Clone the current block to a new identical block
  61092. * @param scene defines the hosting scene
  61093. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61094. * @returns a copy of the current block
  61095. */
  61096. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61097. /**
  61098. * Serializes this block in a JSON representation
  61099. * @returns the serialized block object
  61100. */
  61101. serialize(): any;
  61102. /** @hidden */
  61103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61104. /**
  61105. * Release resources
  61106. */
  61107. dispose(): void;
  61108. }
  61109. }
  61110. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61111. /**
  61112. * Enum defining the type of animations supported by InputBlock
  61113. */
  61114. export enum AnimatedInputBlockTypes {
  61115. /** No animation */
  61116. None = 0,
  61117. /** Time based animation. Will only work for floats */
  61118. Time = 1
  61119. }
  61120. }
  61121. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61123. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61124. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61125. import { Nullable } from "babylonjs/types";
  61126. import { Effect } from "babylonjs/Materials/effect";
  61127. import { Matrix } from "babylonjs/Maths/math.vector";
  61128. import { Scene } from "babylonjs/scene";
  61129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61131. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61132. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61133. import { Observable } from "babylonjs/Misc/observable";
  61134. /**
  61135. * Block used to expose an input value
  61136. */
  61137. export class InputBlock extends NodeMaterialBlock {
  61138. private _mode;
  61139. private _associatedVariableName;
  61140. private _storedValue;
  61141. private _valueCallback;
  61142. private _type;
  61143. private _animationType;
  61144. /** Gets or set a value used to limit the range of float values */
  61145. min: number;
  61146. /** Gets or set a value used to limit the range of float values */
  61147. max: number;
  61148. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61149. isBoolean: boolean;
  61150. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61151. matrixMode: number;
  61152. /** @hidden */
  61153. _systemValue: Nullable<NodeMaterialSystemValues>;
  61154. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61155. visibleInInspector: boolean;
  61156. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61157. isConstant: boolean;
  61158. /** Gets or sets the group to use to display this block in the Inspector */
  61159. groupInInspector: string;
  61160. /** Gets an observable raised when the value is changed */
  61161. onValueChangedObservable: Observable<InputBlock>;
  61162. /**
  61163. * Gets or sets the connection point type (default is float)
  61164. */
  61165. get type(): NodeMaterialBlockConnectionPointTypes;
  61166. /**
  61167. * Creates a new InputBlock
  61168. * @param name defines the block name
  61169. * @param target defines the target of that block (Vertex by default)
  61170. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61171. */
  61172. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61173. /**
  61174. * Gets the output component
  61175. */
  61176. get output(): NodeMaterialConnectionPoint;
  61177. /**
  61178. * Set the source of this connection point to a vertex attribute
  61179. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61180. * @returns the current connection point
  61181. */
  61182. setAsAttribute(attributeName?: string): InputBlock;
  61183. /**
  61184. * Set the source of this connection point to a system value
  61185. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61186. * @returns the current connection point
  61187. */
  61188. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61189. /**
  61190. * Gets or sets the value of that point.
  61191. * Please note that this value will be ignored if valueCallback is defined
  61192. */
  61193. get value(): any;
  61194. set value(value: any);
  61195. /**
  61196. * Gets or sets a callback used to get the value of that point.
  61197. * Please note that setting this value will force the connection point to ignore the value property
  61198. */
  61199. get valueCallback(): () => any;
  61200. set valueCallback(value: () => any);
  61201. /**
  61202. * Gets or sets the associated variable name in the shader
  61203. */
  61204. get associatedVariableName(): string;
  61205. set associatedVariableName(value: string);
  61206. /** Gets or sets the type of animation applied to the input */
  61207. get animationType(): AnimatedInputBlockTypes;
  61208. set animationType(value: AnimatedInputBlockTypes);
  61209. /**
  61210. * Gets a boolean indicating that this connection point not defined yet
  61211. */
  61212. get isUndefined(): boolean;
  61213. /**
  61214. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61215. * In this case the connection point name must be the name of the uniform to use.
  61216. * Can only be set on inputs
  61217. */
  61218. get isUniform(): boolean;
  61219. set isUniform(value: boolean);
  61220. /**
  61221. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61222. * In this case the connection point name must be the name of the attribute to use
  61223. * Can only be set on inputs
  61224. */
  61225. get isAttribute(): boolean;
  61226. set isAttribute(value: boolean);
  61227. /**
  61228. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61229. * Can only be set on exit points
  61230. */
  61231. get isVarying(): boolean;
  61232. set isVarying(value: boolean);
  61233. /**
  61234. * Gets a boolean indicating that the current connection point is a system value
  61235. */
  61236. get isSystemValue(): boolean;
  61237. /**
  61238. * Gets or sets the current well known value or null if not defined as a system value
  61239. */
  61240. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61241. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61242. /**
  61243. * Gets the current class name
  61244. * @returns the class name
  61245. */
  61246. getClassName(): string;
  61247. /**
  61248. * Animate the input if animationType !== None
  61249. * @param scene defines the rendering scene
  61250. */
  61251. animate(scene: Scene): void;
  61252. private _emitDefine;
  61253. initialize(state: NodeMaterialBuildState): void;
  61254. /**
  61255. * Set the input block to its default value (based on its type)
  61256. */
  61257. setDefaultValue(): void;
  61258. private _emitConstant;
  61259. private _emit;
  61260. /** @hidden */
  61261. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61262. /** @hidden */
  61263. _transmit(effect: Effect, scene: Scene): void;
  61264. protected _buildBlock(state: NodeMaterialBuildState): void;
  61265. protected _dumpPropertiesCode(): string;
  61266. dispose(): void;
  61267. serialize(): any;
  61268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61269. }
  61270. }
  61271. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61272. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61273. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61274. import { Nullable } from "babylonjs/types";
  61275. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61276. import { Observable } from "babylonjs/Misc/observable";
  61277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61278. /**
  61279. * Enum used to define the compatibility state between two connection points
  61280. */
  61281. export enum NodeMaterialConnectionPointCompatibilityStates {
  61282. /** Points are compatibles */
  61283. Compatible = 0,
  61284. /** Points are incompatible because of their types */
  61285. TypeIncompatible = 1,
  61286. /** Points are incompatible because of their targets (vertex vs fragment) */
  61287. TargetIncompatible = 2
  61288. }
  61289. /**
  61290. * Defines the direction of a connection point
  61291. */
  61292. export enum NodeMaterialConnectionPointDirection {
  61293. /** Input */
  61294. Input = 0,
  61295. /** Output */
  61296. Output = 1
  61297. }
  61298. /**
  61299. * Defines a connection point for a block
  61300. */
  61301. export class NodeMaterialConnectionPoint {
  61302. /** @hidden */
  61303. _ownerBlock: NodeMaterialBlock;
  61304. /** @hidden */
  61305. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61306. private _endpoints;
  61307. private _associatedVariableName;
  61308. private _direction;
  61309. /** @hidden */
  61310. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61311. /** @hidden */
  61312. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61313. private _type;
  61314. /** @hidden */
  61315. _enforceAssociatedVariableName: boolean;
  61316. /** Gets the direction of the point */
  61317. get direction(): NodeMaterialConnectionPointDirection;
  61318. /**
  61319. * Gets or sets the additional types supported by this connection point
  61320. */
  61321. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61322. /**
  61323. * Gets or sets the additional types excluded by this connection point
  61324. */
  61325. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61326. /**
  61327. * Observable triggered when this point is connected
  61328. */
  61329. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61330. /**
  61331. * Gets or sets the associated variable name in the shader
  61332. */
  61333. get associatedVariableName(): string;
  61334. set associatedVariableName(value: string);
  61335. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61336. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61337. /**
  61338. * Gets or sets the connection point type (default is float)
  61339. */
  61340. get type(): NodeMaterialBlockConnectionPointTypes;
  61341. set type(value: NodeMaterialBlockConnectionPointTypes);
  61342. /**
  61343. * Gets or sets the connection point name
  61344. */
  61345. name: string;
  61346. /**
  61347. * Gets or sets a boolean indicating that this connection point can be omitted
  61348. */
  61349. isOptional: boolean;
  61350. /**
  61351. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61352. */
  61353. define: string;
  61354. /** @hidden */
  61355. _prioritizeVertex: boolean;
  61356. private _target;
  61357. /** Gets or sets the target of that connection point */
  61358. get target(): NodeMaterialBlockTargets;
  61359. set target(value: NodeMaterialBlockTargets);
  61360. /**
  61361. * Gets a boolean indicating that the current point is connected
  61362. */
  61363. get isConnected(): boolean;
  61364. /**
  61365. * Gets a boolean indicating that the current point is connected to an input block
  61366. */
  61367. get isConnectedToInputBlock(): boolean;
  61368. /**
  61369. * Gets a the connected input block (if any)
  61370. */
  61371. get connectInputBlock(): Nullable<InputBlock>;
  61372. /** Get the other side of the connection (if any) */
  61373. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61374. /** Get the block that owns this connection point */
  61375. get ownerBlock(): NodeMaterialBlock;
  61376. /** Get the block connected on the other side of this connection (if any) */
  61377. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61378. /** Get the block connected on the endpoints of this connection (if any) */
  61379. get connectedBlocks(): Array<NodeMaterialBlock>;
  61380. /** Gets the list of connected endpoints */
  61381. get endpoints(): NodeMaterialConnectionPoint[];
  61382. /** Gets a boolean indicating if that output point is connected to at least one input */
  61383. get hasEndpoints(): boolean;
  61384. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61385. get isConnectedInVertexShader(): boolean;
  61386. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61387. get isConnectedInFragmentShader(): boolean;
  61388. /**
  61389. * Creates a new connection point
  61390. * @param name defines the connection point name
  61391. * @param ownerBlock defines the block hosting this connection point
  61392. * @param direction defines the direction of the connection point
  61393. */
  61394. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61395. /**
  61396. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61397. * @returns the class name
  61398. */
  61399. getClassName(): string;
  61400. /**
  61401. * Gets a boolean indicating if the current point can be connected to another point
  61402. * @param connectionPoint defines the other connection point
  61403. * @returns a boolean
  61404. */
  61405. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61406. /**
  61407. * Gets a number indicating if the current point can be connected to another point
  61408. * @param connectionPoint defines the other connection point
  61409. * @returns a number defining the compatibility state
  61410. */
  61411. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61412. /**
  61413. * Connect this point to another connection point
  61414. * @param connectionPoint defines the other connection point
  61415. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61416. * @returns the current connection point
  61417. */
  61418. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61419. /**
  61420. * Disconnect this point from one of his endpoint
  61421. * @param endpoint defines the other connection point
  61422. * @returns the current connection point
  61423. */
  61424. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Serializes this point in a JSON representation
  61427. * @returns the serialized point object
  61428. */
  61429. serialize(): any;
  61430. /**
  61431. * Release resources
  61432. */
  61433. dispose(): void;
  61434. }
  61435. }
  61436. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61440. import { Mesh } from "babylonjs/Meshes/mesh";
  61441. import { Effect } from "babylonjs/Materials/effect";
  61442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61443. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61444. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61445. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61446. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61447. /**
  61448. * Block used to add support for vertex skinning (bones)
  61449. */
  61450. export class BonesBlock extends NodeMaterialBlock {
  61451. /**
  61452. * Creates a new BonesBlock
  61453. * @param name defines the block name
  61454. */
  61455. constructor(name: string);
  61456. /**
  61457. * Initialize the block and prepare the context for build
  61458. * @param state defines the state that will be used for the build
  61459. */
  61460. initialize(state: NodeMaterialBuildState): void;
  61461. /**
  61462. * Gets the current class name
  61463. * @returns the class name
  61464. */
  61465. getClassName(): string;
  61466. /**
  61467. * Gets the matrix indices input component
  61468. */
  61469. get matricesIndices(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the matrix weights input component
  61472. */
  61473. get matricesWeights(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the extra matrix indices input component
  61476. */
  61477. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the extra matrix weights input component
  61480. */
  61481. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the world input component
  61484. */
  61485. get world(): NodeMaterialConnectionPoint;
  61486. /**
  61487. * Gets the output component
  61488. */
  61489. get output(): NodeMaterialConnectionPoint;
  61490. autoConfigure(material: NodeMaterial): void;
  61491. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61494. protected _buildBlock(state: NodeMaterialBuildState): this;
  61495. }
  61496. }
  61497. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61502. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61503. /**
  61504. * Block used to add support for instances
  61505. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61506. */
  61507. export class InstancesBlock extends NodeMaterialBlock {
  61508. /**
  61509. * Creates a new InstancesBlock
  61510. * @param name defines the block name
  61511. */
  61512. constructor(name: string);
  61513. /**
  61514. * Gets the current class name
  61515. * @returns the class name
  61516. */
  61517. getClassName(): string;
  61518. /**
  61519. * Gets the first world row input component
  61520. */
  61521. get world0(): NodeMaterialConnectionPoint;
  61522. /**
  61523. * Gets the second world row input component
  61524. */
  61525. get world1(): NodeMaterialConnectionPoint;
  61526. /**
  61527. * Gets the third world row input component
  61528. */
  61529. get world2(): NodeMaterialConnectionPoint;
  61530. /**
  61531. * Gets the forth world row input component
  61532. */
  61533. get world3(): NodeMaterialConnectionPoint;
  61534. /**
  61535. * Gets the world input component
  61536. */
  61537. get world(): NodeMaterialConnectionPoint;
  61538. /**
  61539. * Gets the output component
  61540. */
  61541. get output(): NodeMaterialConnectionPoint;
  61542. /**
  61543. * Gets the isntanceID component
  61544. */
  61545. get instanceID(): NodeMaterialConnectionPoint;
  61546. autoConfigure(material: NodeMaterial): void;
  61547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61548. protected _buildBlock(state: NodeMaterialBuildState): this;
  61549. }
  61550. }
  61551. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61557. import { Effect } from "babylonjs/Materials/effect";
  61558. import { Mesh } from "babylonjs/Meshes/mesh";
  61559. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61561. /**
  61562. * Block used to add morph targets support to vertex shader
  61563. */
  61564. export class MorphTargetsBlock extends NodeMaterialBlock {
  61565. private _repeatableContentAnchor;
  61566. /**
  61567. * Create a new MorphTargetsBlock
  61568. * @param name defines the block name
  61569. */
  61570. constructor(name: string);
  61571. /**
  61572. * Gets the current class name
  61573. * @returns the class name
  61574. */
  61575. getClassName(): string;
  61576. /**
  61577. * Gets the position input component
  61578. */
  61579. get position(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the normal input component
  61582. */
  61583. get normal(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the tangent input component
  61586. */
  61587. get tangent(): NodeMaterialConnectionPoint;
  61588. /**
  61589. * Gets the tangent input component
  61590. */
  61591. get uv(): NodeMaterialConnectionPoint;
  61592. /**
  61593. * Gets the position output component
  61594. */
  61595. get positionOutput(): NodeMaterialConnectionPoint;
  61596. /**
  61597. * Gets the normal output component
  61598. */
  61599. get normalOutput(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the tangent output component
  61602. */
  61603. get tangentOutput(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the tangent output component
  61606. */
  61607. get uvOutput(): NodeMaterialConnectionPoint;
  61608. initialize(state: NodeMaterialBuildState): void;
  61609. autoConfigure(material: NodeMaterial): void;
  61610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61611. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61612. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61613. protected _buildBlock(state: NodeMaterialBuildState): this;
  61614. }
  61615. }
  61616. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61620. import { Nullable } from "babylonjs/types";
  61621. import { Scene } from "babylonjs/scene";
  61622. import { Effect } from "babylonjs/Materials/effect";
  61623. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61624. import { Mesh } from "babylonjs/Meshes/mesh";
  61625. import { Light } from "babylonjs/Lights/light";
  61626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61627. /**
  61628. * Block used to get data information from a light
  61629. */
  61630. export class LightInformationBlock extends NodeMaterialBlock {
  61631. private _lightDataUniformName;
  61632. private _lightColorUniformName;
  61633. private _lightTypeDefineName;
  61634. /**
  61635. * Gets or sets the light associated with this block
  61636. */
  61637. light: Nullable<Light>;
  61638. /**
  61639. * Creates a new LightInformationBlock
  61640. * @param name defines the block name
  61641. */
  61642. constructor(name: string);
  61643. /**
  61644. * Gets the current class name
  61645. * @returns the class name
  61646. */
  61647. getClassName(): string;
  61648. /**
  61649. * Gets the world position input component
  61650. */
  61651. get worldPosition(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the direction output component
  61654. */
  61655. get direction(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the direction output component
  61658. */
  61659. get color(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the direction output component
  61662. */
  61663. get intensity(): NodeMaterialConnectionPoint;
  61664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61666. protected _buildBlock(state: NodeMaterialBuildState): this;
  61667. serialize(): any;
  61668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61669. }
  61670. }
  61671. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61672. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61673. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61674. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61675. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61676. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61677. }
  61678. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61683. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61684. import { Effect } from "babylonjs/Materials/effect";
  61685. import { Mesh } from "babylonjs/Meshes/mesh";
  61686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61687. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61688. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61689. /**
  61690. * Block used to add image processing support to fragment shader
  61691. */
  61692. export class ImageProcessingBlock extends NodeMaterialBlock {
  61693. /**
  61694. * Create a new ImageProcessingBlock
  61695. * @param name defines the block name
  61696. */
  61697. constructor(name: string);
  61698. /**
  61699. * Gets the current class name
  61700. * @returns the class name
  61701. */
  61702. getClassName(): string;
  61703. /**
  61704. * Gets the color input component
  61705. */
  61706. get color(): NodeMaterialConnectionPoint;
  61707. /**
  61708. * Gets the output component
  61709. */
  61710. get output(): NodeMaterialConnectionPoint;
  61711. /**
  61712. * Initialize the block and prepare the context for build
  61713. * @param state defines the state that will be used for the build
  61714. */
  61715. initialize(state: NodeMaterialBuildState): void;
  61716. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61719. protected _buildBlock(state: NodeMaterialBuildState): this;
  61720. }
  61721. }
  61722. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61726. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61728. import { Effect } from "babylonjs/Materials/effect";
  61729. import { Mesh } from "babylonjs/Meshes/mesh";
  61730. import { Scene } from "babylonjs/scene";
  61731. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61732. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61733. /**
  61734. * Block used to pertub normals based on a normal map
  61735. */
  61736. export class PerturbNormalBlock extends NodeMaterialBlock {
  61737. private _tangentSpaceParameterName;
  61738. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61739. invertX: boolean;
  61740. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61741. invertY: boolean;
  61742. /**
  61743. * Create a new PerturbNormalBlock
  61744. * @param name defines the block name
  61745. */
  61746. constructor(name: string);
  61747. /**
  61748. * Gets the current class name
  61749. * @returns the class name
  61750. */
  61751. getClassName(): string;
  61752. /**
  61753. * Gets the world position input component
  61754. */
  61755. get worldPosition(): NodeMaterialConnectionPoint;
  61756. /**
  61757. * Gets the world normal input component
  61758. */
  61759. get worldNormal(): NodeMaterialConnectionPoint;
  61760. /**
  61761. * Gets the world tangent input component
  61762. */
  61763. get worldTangent(): NodeMaterialConnectionPoint;
  61764. /**
  61765. * Gets the uv input component
  61766. */
  61767. get uv(): NodeMaterialConnectionPoint;
  61768. /**
  61769. * Gets the normal map color input component
  61770. */
  61771. get normalMapColor(): NodeMaterialConnectionPoint;
  61772. /**
  61773. * Gets the strength input component
  61774. */
  61775. get strength(): NodeMaterialConnectionPoint;
  61776. /**
  61777. * Gets the output component
  61778. */
  61779. get output(): NodeMaterialConnectionPoint;
  61780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61781. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61782. autoConfigure(material: NodeMaterial): void;
  61783. protected _buildBlock(state: NodeMaterialBuildState): this;
  61784. protected _dumpPropertiesCode(): string;
  61785. serialize(): any;
  61786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61787. }
  61788. }
  61789. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61793. /**
  61794. * Block used to discard a pixel if a value is smaller than a cutoff
  61795. */
  61796. export class DiscardBlock extends NodeMaterialBlock {
  61797. /**
  61798. * Create a new DiscardBlock
  61799. * @param name defines the block name
  61800. */
  61801. constructor(name: string);
  61802. /**
  61803. * Gets the current class name
  61804. * @returns the class name
  61805. */
  61806. getClassName(): string;
  61807. /**
  61808. * Gets the color input component
  61809. */
  61810. get value(): NodeMaterialConnectionPoint;
  61811. /**
  61812. * Gets the cutoff input component
  61813. */
  61814. get cutoff(): NodeMaterialConnectionPoint;
  61815. protected _buildBlock(state: NodeMaterialBuildState): this;
  61816. }
  61817. }
  61818. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61822. /**
  61823. * Block used to test if the fragment shader is front facing
  61824. */
  61825. export class FrontFacingBlock extends NodeMaterialBlock {
  61826. /**
  61827. * Creates a new FrontFacingBlock
  61828. * @param name defines the block name
  61829. */
  61830. constructor(name: string);
  61831. /**
  61832. * Gets the current class name
  61833. * @returns the class name
  61834. */
  61835. getClassName(): string;
  61836. /**
  61837. * Gets the output component
  61838. */
  61839. get output(): NodeMaterialConnectionPoint;
  61840. protected _buildBlock(state: NodeMaterialBuildState): this;
  61841. }
  61842. }
  61843. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61847. /**
  61848. * Block used to get the derivative value on x and y of a given input
  61849. */
  61850. export class DerivativeBlock extends NodeMaterialBlock {
  61851. /**
  61852. * Create a new DerivativeBlock
  61853. * @param name defines the block name
  61854. */
  61855. constructor(name: string);
  61856. /**
  61857. * Gets the current class name
  61858. * @returns the class name
  61859. */
  61860. getClassName(): string;
  61861. /**
  61862. * Gets the input component
  61863. */
  61864. get input(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the derivative output on x
  61867. */
  61868. get dx(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the derivative output on y
  61871. */
  61872. get dy(): NodeMaterialConnectionPoint;
  61873. protected _buildBlock(state: NodeMaterialBuildState): this;
  61874. }
  61875. }
  61876. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61877. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61878. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61879. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61880. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61881. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61882. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61883. }
  61884. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61887. import { Mesh } from "babylonjs/Meshes/mesh";
  61888. import { Effect } from "babylonjs/Materials/effect";
  61889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61891. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61892. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61893. /**
  61894. * Block used to add support for scene fog
  61895. */
  61896. export class FogBlock extends NodeMaterialBlock {
  61897. private _fogDistanceName;
  61898. private _fogParameters;
  61899. /**
  61900. * Create a new FogBlock
  61901. * @param name defines the block name
  61902. */
  61903. constructor(name: string);
  61904. /**
  61905. * Gets the current class name
  61906. * @returns the class name
  61907. */
  61908. getClassName(): string;
  61909. /**
  61910. * Gets the world position input component
  61911. */
  61912. get worldPosition(): NodeMaterialConnectionPoint;
  61913. /**
  61914. * Gets the view input component
  61915. */
  61916. get view(): NodeMaterialConnectionPoint;
  61917. /**
  61918. * Gets the color input component
  61919. */
  61920. get input(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the fog color input component
  61923. */
  61924. get fogColor(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the output component
  61927. */
  61928. get output(): NodeMaterialConnectionPoint;
  61929. autoConfigure(material: NodeMaterial): void;
  61930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61932. protected _buildBlock(state: NodeMaterialBuildState): this;
  61933. }
  61934. }
  61935. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61941. import { Effect } from "babylonjs/Materials/effect";
  61942. import { Mesh } from "babylonjs/Meshes/mesh";
  61943. import { Light } from "babylonjs/Lights/light";
  61944. import { Nullable } from "babylonjs/types";
  61945. import { Scene } from "babylonjs/scene";
  61946. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61947. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61948. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61949. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61950. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61951. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61952. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61953. /**
  61954. * Block used to add light in the fragment shader
  61955. */
  61956. export class LightBlock extends NodeMaterialBlock {
  61957. private _lightId;
  61958. /**
  61959. * Gets or sets the light associated with this block
  61960. */
  61961. light: Nullable<Light>;
  61962. /**
  61963. * Create a new LightBlock
  61964. * @param name defines the block name
  61965. */
  61966. constructor(name: string);
  61967. /**
  61968. * Gets the current class name
  61969. * @returns the class name
  61970. */
  61971. getClassName(): string;
  61972. /**
  61973. * Gets the world position input component
  61974. */
  61975. get worldPosition(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the world normal input component
  61978. */
  61979. get worldNormal(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the camera (or eye) position component
  61982. */
  61983. get cameraPosition(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the glossiness component
  61986. */
  61987. get glossiness(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the glossinness power component
  61990. */
  61991. get glossPower(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the diffuse color component
  61994. */
  61995. get diffuseColor(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the specular color component
  61998. */
  61999. get specularColor(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the diffuse output component
  62002. */
  62003. get diffuseOutput(): NodeMaterialConnectionPoint;
  62004. /**
  62005. * Gets the specular output component
  62006. */
  62007. get specularOutput(): NodeMaterialConnectionPoint;
  62008. /**
  62009. * Gets the shadow output component
  62010. */
  62011. get shadow(): NodeMaterialConnectionPoint;
  62012. autoConfigure(material: NodeMaterial): void;
  62013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62014. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62015. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62016. private _injectVertexCode;
  62017. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62018. serialize(): any;
  62019. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62020. }
  62021. }
  62022. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62023. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62024. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62025. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62026. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62027. }
  62028. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62029. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62030. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62031. }
  62032. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62036. /**
  62037. * Block used to multiply 2 values
  62038. */
  62039. export class MultiplyBlock extends NodeMaterialBlock {
  62040. /**
  62041. * Creates a new MultiplyBlock
  62042. * @param name defines the block name
  62043. */
  62044. constructor(name: string);
  62045. /**
  62046. * Gets the current class name
  62047. * @returns the class name
  62048. */
  62049. getClassName(): string;
  62050. /**
  62051. * Gets the left operand input component
  62052. */
  62053. get left(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the right operand input component
  62056. */
  62057. get right(): NodeMaterialConnectionPoint;
  62058. /**
  62059. * Gets the output component
  62060. */
  62061. get output(): NodeMaterialConnectionPoint;
  62062. protected _buildBlock(state: NodeMaterialBuildState): this;
  62063. }
  62064. }
  62065. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62069. /**
  62070. * Block used to add 2 vectors
  62071. */
  62072. export class AddBlock extends NodeMaterialBlock {
  62073. /**
  62074. * Creates a new AddBlock
  62075. * @param name defines the block name
  62076. */
  62077. constructor(name: string);
  62078. /**
  62079. * Gets the current class name
  62080. * @returns the class name
  62081. */
  62082. getClassName(): string;
  62083. /**
  62084. * Gets the left operand input component
  62085. */
  62086. get left(): NodeMaterialConnectionPoint;
  62087. /**
  62088. * Gets the right operand input component
  62089. */
  62090. get right(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the output component
  62093. */
  62094. get output(): NodeMaterialConnectionPoint;
  62095. protected _buildBlock(state: NodeMaterialBuildState): this;
  62096. }
  62097. }
  62098. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62102. /**
  62103. * Block used to scale a vector by a float
  62104. */
  62105. export class ScaleBlock extends NodeMaterialBlock {
  62106. /**
  62107. * Creates a new ScaleBlock
  62108. * @param name defines the block name
  62109. */
  62110. constructor(name: string);
  62111. /**
  62112. * Gets the current class name
  62113. * @returns the class name
  62114. */
  62115. getClassName(): string;
  62116. /**
  62117. * Gets the input component
  62118. */
  62119. get input(): NodeMaterialConnectionPoint;
  62120. /**
  62121. * Gets the factor input component
  62122. */
  62123. get factor(): NodeMaterialConnectionPoint;
  62124. /**
  62125. * Gets the output component
  62126. */
  62127. get output(): NodeMaterialConnectionPoint;
  62128. protected _buildBlock(state: NodeMaterialBuildState): this;
  62129. }
  62130. }
  62131. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62135. import { Scene } from "babylonjs/scene";
  62136. /**
  62137. * Block used to clamp a float
  62138. */
  62139. export class ClampBlock extends NodeMaterialBlock {
  62140. /** Gets or sets the minimum range */
  62141. minimum: number;
  62142. /** Gets or sets the maximum range */
  62143. maximum: number;
  62144. /**
  62145. * Creates a new ClampBlock
  62146. * @param name defines the block name
  62147. */
  62148. constructor(name: string);
  62149. /**
  62150. * Gets the current class name
  62151. * @returns the class name
  62152. */
  62153. getClassName(): string;
  62154. /**
  62155. * Gets the value input component
  62156. */
  62157. get value(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the output component
  62160. */
  62161. get output(): NodeMaterialConnectionPoint;
  62162. protected _buildBlock(state: NodeMaterialBuildState): this;
  62163. protected _dumpPropertiesCode(): string;
  62164. serialize(): any;
  62165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62166. }
  62167. }
  62168. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62172. /**
  62173. * Block used to apply a cross product between 2 vectors
  62174. */
  62175. export class CrossBlock extends NodeMaterialBlock {
  62176. /**
  62177. * Creates a new CrossBlock
  62178. * @param name defines the block name
  62179. */
  62180. constructor(name: string);
  62181. /**
  62182. * Gets the current class name
  62183. * @returns the class name
  62184. */
  62185. getClassName(): string;
  62186. /**
  62187. * Gets the left operand input component
  62188. */
  62189. get left(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the right operand input component
  62192. */
  62193. get right(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the output component
  62196. */
  62197. get output(): NodeMaterialConnectionPoint;
  62198. protected _buildBlock(state: NodeMaterialBuildState): this;
  62199. }
  62200. }
  62201. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62205. /**
  62206. * Block used to apply a dot product between 2 vectors
  62207. */
  62208. export class DotBlock extends NodeMaterialBlock {
  62209. /**
  62210. * Creates a new DotBlock
  62211. * @param name defines the block name
  62212. */
  62213. constructor(name: string);
  62214. /**
  62215. * Gets the current class name
  62216. * @returns the class name
  62217. */
  62218. getClassName(): string;
  62219. /**
  62220. * Gets the left operand input component
  62221. */
  62222. get left(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the right operand input component
  62225. */
  62226. get right(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the output component
  62229. */
  62230. get output(): NodeMaterialConnectionPoint;
  62231. protected _buildBlock(state: NodeMaterialBuildState): this;
  62232. }
  62233. }
  62234. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62238. import { Vector2 } from "babylonjs/Maths/math.vector";
  62239. import { Scene } from "babylonjs/scene";
  62240. /**
  62241. * Block used to remap a float from a range to a new one
  62242. */
  62243. export class RemapBlock extends NodeMaterialBlock {
  62244. /**
  62245. * Gets or sets the source range
  62246. */
  62247. sourceRange: Vector2;
  62248. /**
  62249. * Gets or sets the target range
  62250. */
  62251. targetRange: Vector2;
  62252. /**
  62253. * Creates a new RemapBlock
  62254. * @param name defines the block name
  62255. */
  62256. constructor(name: string);
  62257. /**
  62258. * Gets the current class name
  62259. * @returns the class name
  62260. */
  62261. getClassName(): string;
  62262. /**
  62263. * Gets the input component
  62264. */
  62265. get input(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the source min input component
  62268. */
  62269. get sourceMin(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the source max input component
  62272. */
  62273. get sourceMax(): NodeMaterialConnectionPoint;
  62274. /**
  62275. * Gets the target min input component
  62276. */
  62277. get targetMin(): NodeMaterialConnectionPoint;
  62278. /**
  62279. * Gets the target max input component
  62280. */
  62281. get targetMax(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the output component
  62284. */
  62285. get output(): NodeMaterialConnectionPoint;
  62286. protected _buildBlock(state: NodeMaterialBuildState): this;
  62287. protected _dumpPropertiesCode(): string;
  62288. serialize(): any;
  62289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62290. }
  62291. }
  62292. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62296. /**
  62297. * Block used to normalize a vector
  62298. */
  62299. export class NormalizeBlock extends NodeMaterialBlock {
  62300. /**
  62301. * Creates a new NormalizeBlock
  62302. * @param name defines the block name
  62303. */
  62304. constructor(name: string);
  62305. /**
  62306. * Gets the current class name
  62307. * @returns the class name
  62308. */
  62309. getClassName(): string;
  62310. /**
  62311. * Gets the input component
  62312. */
  62313. get input(): NodeMaterialConnectionPoint;
  62314. /**
  62315. * Gets the output component
  62316. */
  62317. get output(): NodeMaterialConnectionPoint;
  62318. protected _buildBlock(state: NodeMaterialBuildState): this;
  62319. }
  62320. }
  62321. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62325. import { Scene } from "babylonjs/scene";
  62326. /**
  62327. * Operations supported by the Trigonometry block
  62328. */
  62329. export enum TrigonometryBlockOperations {
  62330. /** Cos */
  62331. Cos = 0,
  62332. /** Sin */
  62333. Sin = 1,
  62334. /** Abs */
  62335. Abs = 2,
  62336. /** Exp */
  62337. Exp = 3,
  62338. /** Exp2 */
  62339. Exp2 = 4,
  62340. /** Round */
  62341. Round = 5,
  62342. /** Floor */
  62343. Floor = 6,
  62344. /** Ceiling */
  62345. Ceiling = 7,
  62346. /** Square root */
  62347. Sqrt = 8,
  62348. /** Log */
  62349. Log = 9,
  62350. /** Tangent */
  62351. Tan = 10,
  62352. /** Arc tangent */
  62353. ArcTan = 11,
  62354. /** Arc cosinus */
  62355. ArcCos = 12,
  62356. /** Arc sinus */
  62357. ArcSin = 13,
  62358. /** Fraction */
  62359. Fract = 14,
  62360. /** Sign */
  62361. Sign = 15,
  62362. /** To radians (from degrees) */
  62363. Radians = 16,
  62364. /** To degrees (from radians) */
  62365. Degrees = 17
  62366. }
  62367. /**
  62368. * Block used to apply trigonometry operation to floats
  62369. */
  62370. export class TrigonometryBlock extends NodeMaterialBlock {
  62371. /**
  62372. * Gets or sets the operation applied by the block
  62373. */
  62374. operation: TrigonometryBlockOperations;
  62375. /**
  62376. * Creates a new TrigonometryBlock
  62377. * @param name defines the block name
  62378. */
  62379. constructor(name: string);
  62380. /**
  62381. * Gets the current class name
  62382. * @returns the class name
  62383. */
  62384. getClassName(): string;
  62385. /**
  62386. * Gets the input component
  62387. */
  62388. get input(): NodeMaterialConnectionPoint;
  62389. /**
  62390. * Gets the output component
  62391. */
  62392. get output(): NodeMaterialConnectionPoint;
  62393. protected _buildBlock(state: NodeMaterialBuildState): this;
  62394. serialize(): any;
  62395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62396. protected _dumpPropertiesCode(): string;
  62397. }
  62398. }
  62399. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62403. /**
  62404. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62405. */
  62406. export class ColorMergerBlock extends NodeMaterialBlock {
  62407. /**
  62408. * Create a new ColorMergerBlock
  62409. * @param name defines the block name
  62410. */
  62411. constructor(name: string);
  62412. /**
  62413. * Gets the current class name
  62414. * @returns the class name
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Gets the rgb component (input)
  62419. */
  62420. get rgbIn(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the r component (input)
  62423. */
  62424. get r(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the g component (input)
  62427. */
  62428. get g(): NodeMaterialConnectionPoint;
  62429. /**
  62430. * Gets the b component (input)
  62431. */
  62432. get b(): NodeMaterialConnectionPoint;
  62433. /**
  62434. * Gets the a component (input)
  62435. */
  62436. get a(): NodeMaterialConnectionPoint;
  62437. /**
  62438. * Gets the rgba component (output)
  62439. */
  62440. get rgba(): NodeMaterialConnectionPoint;
  62441. /**
  62442. * Gets the rgb component (output)
  62443. */
  62444. get rgbOut(): NodeMaterialConnectionPoint;
  62445. /**
  62446. * Gets the rgb component (output)
  62447. * @deprecated Please use rgbOut instead.
  62448. */
  62449. get rgb(): NodeMaterialConnectionPoint;
  62450. protected _buildBlock(state: NodeMaterialBuildState): this;
  62451. }
  62452. }
  62453. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62454. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62455. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62457. /**
  62458. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62459. */
  62460. export class VectorMergerBlock extends NodeMaterialBlock {
  62461. /**
  62462. * Create a new VectorMergerBlock
  62463. * @param name defines the block name
  62464. */
  62465. constructor(name: string);
  62466. /**
  62467. * Gets the current class name
  62468. * @returns the class name
  62469. */
  62470. getClassName(): string;
  62471. /**
  62472. * Gets the xyz component (input)
  62473. */
  62474. get xyzIn(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the xy component (input)
  62477. */
  62478. get xyIn(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the x component (input)
  62481. */
  62482. get x(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the y component (input)
  62485. */
  62486. get y(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the z component (input)
  62489. */
  62490. get z(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the w component (input)
  62493. */
  62494. get w(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the xyzw component (output)
  62497. */
  62498. get xyzw(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the xyz component (output)
  62501. */
  62502. get xyzOut(): NodeMaterialConnectionPoint;
  62503. /**
  62504. * Gets the xy component (output)
  62505. */
  62506. get xyOut(): NodeMaterialConnectionPoint;
  62507. /**
  62508. * Gets the xy component (output)
  62509. * @deprecated Please use xyOut instead.
  62510. */
  62511. get xy(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the xyz component (output)
  62514. * @deprecated Please use xyzOut instead.
  62515. */
  62516. get xyz(): NodeMaterialConnectionPoint;
  62517. protected _buildBlock(state: NodeMaterialBuildState): this;
  62518. }
  62519. }
  62520. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62524. /**
  62525. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62526. */
  62527. export class ColorSplitterBlock extends NodeMaterialBlock {
  62528. /**
  62529. * Create a new ColorSplitterBlock
  62530. * @param name defines the block name
  62531. */
  62532. constructor(name: string);
  62533. /**
  62534. * Gets the current class name
  62535. * @returns the class name
  62536. */
  62537. getClassName(): string;
  62538. /**
  62539. * Gets the rgba component (input)
  62540. */
  62541. get rgba(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the rgb component (input)
  62544. */
  62545. get rgbIn(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the rgb component (output)
  62548. */
  62549. get rgbOut(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the r component (output)
  62552. */
  62553. get r(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the g component (output)
  62556. */
  62557. get g(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the b component (output)
  62560. */
  62561. get b(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the a component (output)
  62564. */
  62565. get a(): NodeMaterialConnectionPoint;
  62566. protected _inputRename(name: string): string;
  62567. protected _outputRename(name: string): string;
  62568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62569. }
  62570. }
  62571. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62575. /**
  62576. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62577. */
  62578. export class VectorSplitterBlock extends NodeMaterialBlock {
  62579. /**
  62580. * Create a new VectorSplitterBlock
  62581. * @param name defines the block name
  62582. */
  62583. constructor(name: string);
  62584. /**
  62585. * Gets the current class name
  62586. * @returns the class name
  62587. */
  62588. getClassName(): string;
  62589. /**
  62590. * Gets the xyzw component (input)
  62591. */
  62592. get xyzw(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the xyz component (input)
  62595. */
  62596. get xyzIn(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the xy component (input)
  62599. */
  62600. get xyIn(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the xyz component (output)
  62603. */
  62604. get xyzOut(): NodeMaterialConnectionPoint;
  62605. /**
  62606. * Gets the xy component (output)
  62607. */
  62608. get xyOut(): NodeMaterialConnectionPoint;
  62609. /**
  62610. * Gets the x component (output)
  62611. */
  62612. get x(): NodeMaterialConnectionPoint;
  62613. /**
  62614. * Gets the y component (output)
  62615. */
  62616. get y(): NodeMaterialConnectionPoint;
  62617. /**
  62618. * Gets the z component (output)
  62619. */
  62620. get z(): NodeMaterialConnectionPoint;
  62621. /**
  62622. * Gets the w component (output)
  62623. */
  62624. get w(): NodeMaterialConnectionPoint;
  62625. protected _inputRename(name: string): string;
  62626. protected _outputRename(name: string): string;
  62627. protected _buildBlock(state: NodeMaterialBuildState): this;
  62628. }
  62629. }
  62630. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62634. /**
  62635. * Block used to lerp between 2 values
  62636. */
  62637. export class LerpBlock extends NodeMaterialBlock {
  62638. /**
  62639. * Creates a new LerpBlock
  62640. * @param name defines the block name
  62641. */
  62642. constructor(name: string);
  62643. /**
  62644. * Gets the current class name
  62645. * @returns the class name
  62646. */
  62647. getClassName(): string;
  62648. /**
  62649. * Gets the left operand input component
  62650. */
  62651. get left(): NodeMaterialConnectionPoint;
  62652. /**
  62653. * Gets the right operand input component
  62654. */
  62655. get right(): NodeMaterialConnectionPoint;
  62656. /**
  62657. * Gets the gradient operand input component
  62658. */
  62659. get gradient(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the output component
  62662. */
  62663. get output(): NodeMaterialConnectionPoint;
  62664. protected _buildBlock(state: NodeMaterialBuildState): this;
  62665. }
  62666. }
  62667. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62671. /**
  62672. * Block used to divide 2 vectors
  62673. */
  62674. export class DivideBlock extends NodeMaterialBlock {
  62675. /**
  62676. * Creates a new DivideBlock
  62677. * @param name defines the block name
  62678. */
  62679. constructor(name: string);
  62680. /**
  62681. * Gets the current class name
  62682. * @returns the class name
  62683. */
  62684. getClassName(): string;
  62685. /**
  62686. * Gets the left operand input component
  62687. */
  62688. get left(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the right operand input component
  62691. */
  62692. get right(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the output component
  62695. */
  62696. get output(): NodeMaterialConnectionPoint;
  62697. protected _buildBlock(state: NodeMaterialBuildState): this;
  62698. }
  62699. }
  62700. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62704. /**
  62705. * Block used to subtract 2 vectors
  62706. */
  62707. export class SubtractBlock extends NodeMaterialBlock {
  62708. /**
  62709. * Creates a new SubtractBlock
  62710. * @param name defines the block name
  62711. */
  62712. constructor(name: string);
  62713. /**
  62714. * Gets the current class name
  62715. * @returns the class name
  62716. */
  62717. getClassName(): string;
  62718. /**
  62719. * Gets the left operand input component
  62720. */
  62721. get left(): NodeMaterialConnectionPoint;
  62722. /**
  62723. * Gets the right operand input component
  62724. */
  62725. get right(): NodeMaterialConnectionPoint;
  62726. /**
  62727. * Gets the output component
  62728. */
  62729. get output(): NodeMaterialConnectionPoint;
  62730. protected _buildBlock(state: NodeMaterialBuildState): this;
  62731. }
  62732. }
  62733. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62737. /**
  62738. * Block used to step a value
  62739. */
  62740. export class StepBlock extends NodeMaterialBlock {
  62741. /**
  62742. * Creates a new StepBlock
  62743. * @param name defines the block name
  62744. */
  62745. constructor(name: string);
  62746. /**
  62747. * Gets the current class name
  62748. * @returns the class name
  62749. */
  62750. getClassName(): string;
  62751. /**
  62752. * Gets the value operand input component
  62753. */
  62754. get value(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the edge operand input component
  62757. */
  62758. get edge(): NodeMaterialConnectionPoint;
  62759. /**
  62760. * Gets the output component
  62761. */
  62762. get output(): NodeMaterialConnectionPoint;
  62763. protected _buildBlock(state: NodeMaterialBuildState): this;
  62764. }
  62765. }
  62766. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62770. /**
  62771. * Block used to get the opposite (1 - x) of a value
  62772. */
  62773. export class OneMinusBlock extends NodeMaterialBlock {
  62774. /**
  62775. * Creates a new OneMinusBlock
  62776. * @param name defines the block name
  62777. */
  62778. constructor(name: string);
  62779. /**
  62780. * Gets the current class name
  62781. * @returns the class name
  62782. */
  62783. getClassName(): string;
  62784. /**
  62785. * Gets the input component
  62786. */
  62787. get input(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the output component
  62790. */
  62791. get output(): NodeMaterialConnectionPoint;
  62792. protected _buildBlock(state: NodeMaterialBuildState): this;
  62793. }
  62794. }
  62795. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62799. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62800. /**
  62801. * Block used to get the view direction
  62802. */
  62803. export class ViewDirectionBlock extends NodeMaterialBlock {
  62804. /**
  62805. * Creates a new ViewDirectionBlock
  62806. * @param name defines the block name
  62807. */
  62808. constructor(name: string);
  62809. /**
  62810. * Gets the current class name
  62811. * @returns the class name
  62812. */
  62813. getClassName(): string;
  62814. /**
  62815. * Gets the world position component
  62816. */
  62817. get worldPosition(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the camera position component
  62820. */
  62821. get cameraPosition(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the output component
  62824. */
  62825. get output(): NodeMaterialConnectionPoint;
  62826. autoConfigure(material: NodeMaterial): void;
  62827. protected _buildBlock(state: NodeMaterialBuildState): this;
  62828. }
  62829. }
  62830. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62834. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62835. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62836. /**
  62837. * Block used to compute fresnel value
  62838. */
  62839. export class FresnelBlock extends NodeMaterialBlock {
  62840. /**
  62841. * Create a new FresnelBlock
  62842. * @param name defines the block name
  62843. */
  62844. constructor(name: string);
  62845. /**
  62846. * Gets the current class name
  62847. * @returns the class name
  62848. */
  62849. getClassName(): string;
  62850. /**
  62851. * Gets the world normal input component
  62852. */
  62853. get worldNormal(): NodeMaterialConnectionPoint;
  62854. /**
  62855. * Gets the view direction input component
  62856. */
  62857. get viewDirection(): NodeMaterialConnectionPoint;
  62858. /**
  62859. * Gets the bias input component
  62860. */
  62861. get bias(): NodeMaterialConnectionPoint;
  62862. /**
  62863. * Gets the camera (or eye) position component
  62864. */
  62865. get power(): NodeMaterialConnectionPoint;
  62866. /**
  62867. * Gets the fresnel output component
  62868. */
  62869. get fresnel(): NodeMaterialConnectionPoint;
  62870. autoConfigure(material: NodeMaterial): void;
  62871. protected _buildBlock(state: NodeMaterialBuildState): this;
  62872. }
  62873. }
  62874. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62878. /**
  62879. * Block used to get the max of 2 values
  62880. */
  62881. export class MaxBlock extends NodeMaterialBlock {
  62882. /**
  62883. * Creates a new MaxBlock
  62884. * @param name defines the block name
  62885. */
  62886. constructor(name: string);
  62887. /**
  62888. * Gets the current class name
  62889. * @returns the class name
  62890. */
  62891. getClassName(): string;
  62892. /**
  62893. * Gets the left operand input component
  62894. */
  62895. get left(): NodeMaterialConnectionPoint;
  62896. /**
  62897. * Gets the right operand input component
  62898. */
  62899. get right(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the output component
  62902. */
  62903. get output(): NodeMaterialConnectionPoint;
  62904. protected _buildBlock(state: NodeMaterialBuildState): this;
  62905. }
  62906. }
  62907. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62911. /**
  62912. * Block used to get the min of 2 values
  62913. */
  62914. export class MinBlock extends NodeMaterialBlock {
  62915. /**
  62916. * Creates a new MinBlock
  62917. * @param name defines the block name
  62918. */
  62919. constructor(name: string);
  62920. /**
  62921. * Gets the current class name
  62922. * @returns the class name
  62923. */
  62924. getClassName(): string;
  62925. /**
  62926. * Gets the left operand input component
  62927. */
  62928. get left(): NodeMaterialConnectionPoint;
  62929. /**
  62930. * Gets the right operand input component
  62931. */
  62932. get right(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the output component
  62935. */
  62936. get output(): NodeMaterialConnectionPoint;
  62937. protected _buildBlock(state: NodeMaterialBuildState): this;
  62938. }
  62939. }
  62940. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62944. /**
  62945. * Block used to get the distance between 2 values
  62946. */
  62947. export class DistanceBlock extends NodeMaterialBlock {
  62948. /**
  62949. * Creates a new DistanceBlock
  62950. * @param name defines the block name
  62951. */
  62952. constructor(name: string);
  62953. /**
  62954. * Gets the current class name
  62955. * @returns the class name
  62956. */
  62957. getClassName(): string;
  62958. /**
  62959. * Gets the left operand input component
  62960. */
  62961. get left(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the right operand input component
  62964. */
  62965. get right(): NodeMaterialConnectionPoint;
  62966. /**
  62967. * Gets the output component
  62968. */
  62969. get output(): NodeMaterialConnectionPoint;
  62970. protected _buildBlock(state: NodeMaterialBuildState): this;
  62971. }
  62972. }
  62973. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62976. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62977. /**
  62978. * Block used to get the length of a vector
  62979. */
  62980. export class LengthBlock extends NodeMaterialBlock {
  62981. /**
  62982. * Creates a new LengthBlock
  62983. * @param name defines the block name
  62984. */
  62985. constructor(name: string);
  62986. /**
  62987. * Gets the current class name
  62988. * @returns the class name
  62989. */
  62990. getClassName(): string;
  62991. /**
  62992. * Gets the value input component
  62993. */
  62994. get value(): NodeMaterialConnectionPoint;
  62995. /**
  62996. * Gets the output component
  62997. */
  62998. get output(): NodeMaterialConnectionPoint;
  62999. protected _buildBlock(state: NodeMaterialBuildState): this;
  63000. }
  63001. }
  63002. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63006. /**
  63007. * Block used to get negative version of a value (i.e. x * -1)
  63008. */
  63009. export class NegateBlock extends NodeMaterialBlock {
  63010. /**
  63011. * Creates a new NegateBlock
  63012. * @param name defines the block name
  63013. */
  63014. constructor(name: string);
  63015. /**
  63016. * Gets the current class name
  63017. * @returns the class name
  63018. */
  63019. getClassName(): string;
  63020. /**
  63021. * Gets the value input component
  63022. */
  63023. get value(): NodeMaterialConnectionPoint;
  63024. /**
  63025. * Gets the output component
  63026. */
  63027. get output(): NodeMaterialConnectionPoint;
  63028. protected _buildBlock(state: NodeMaterialBuildState): this;
  63029. }
  63030. }
  63031. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63035. /**
  63036. * Block used to get the value of the first parameter raised to the power of the second
  63037. */
  63038. export class PowBlock extends NodeMaterialBlock {
  63039. /**
  63040. * Creates a new PowBlock
  63041. * @param name defines the block name
  63042. */
  63043. constructor(name: string);
  63044. /**
  63045. * Gets the current class name
  63046. * @returns the class name
  63047. */
  63048. getClassName(): string;
  63049. /**
  63050. * Gets the value operand input component
  63051. */
  63052. get value(): NodeMaterialConnectionPoint;
  63053. /**
  63054. * Gets the power operand input component
  63055. */
  63056. get power(): NodeMaterialConnectionPoint;
  63057. /**
  63058. * Gets the output component
  63059. */
  63060. get output(): NodeMaterialConnectionPoint;
  63061. protected _buildBlock(state: NodeMaterialBuildState): this;
  63062. }
  63063. }
  63064. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63069. /**
  63070. * Block used to get a random number
  63071. */
  63072. export class RandomNumberBlock extends NodeMaterialBlock {
  63073. /**
  63074. * Creates a new RandomNumberBlock
  63075. * @param name defines the block name
  63076. */
  63077. constructor(name: string);
  63078. /**
  63079. * Gets the current class name
  63080. * @returns the class name
  63081. */
  63082. getClassName(): string;
  63083. /**
  63084. * Gets the seed input component
  63085. */
  63086. get seed(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the output component
  63089. */
  63090. get output(): NodeMaterialConnectionPoint;
  63091. protected _buildBlock(state: NodeMaterialBuildState): this;
  63092. }
  63093. }
  63094. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63098. /**
  63099. * Block used to compute arc tangent of 2 values
  63100. */
  63101. export class ArcTan2Block extends NodeMaterialBlock {
  63102. /**
  63103. * Creates a new ArcTan2Block
  63104. * @param name defines the block name
  63105. */
  63106. constructor(name: string);
  63107. /**
  63108. * Gets the current class name
  63109. * @returns the class name
  63110. */
  63111. getClassName(): string;
  63112. /**
  63113. * Gets the x operand input component
  63114. */
  63115. get x(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the y operand input component
  63118. */
  63119. get y(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the output component
  63122. */
  63123. get output(): NodeMaterialConnectionPoint;
  63124. protected _buildBlock(state: NodeMaterialBuildState): this;
  63125. }
  63126. }
  63127. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63131. /**
  63132. * Block used to smooth step a value
  63133. */
  63134. export class SmoothStepBlock extends NodeMaterialBlock {
  63135. /**
  63136. * Creates a new SmoothStepBlock
  63137. * @param name defines the block name
  63138. */
  63139. constructor(name: string);
  63140. /**
  63141. * Gets the current class name
  63142. * @returns the class name
  63143. */
  63144. getClassName(): string;
  63145. /**
  63146. * Gets the value operand input component
  63147. */
  63148. get value(): NodeMaterialConnectionPoint;
  63149. /**
  63150. * Gets the first edge operand input component
  63151. */
  63152. get edge0(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the second edge operand input component
  63155. */
  63156. get edge1(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the output component
  63159. */
  63160. get output(): NodeMaterialConnectionPoint;
  63161. protected _buildBlock(state: NodeMaterialBuildState): this;
  63162. }
  63163. }
  63164. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63168. /**
  63169. * Block used to get the reciprocal (1 / x) of a value
  63170. */
  63171. export class ReciprocalBlock extends NodeMaterialBlock {
  63172. /**
  63173. * Creates a new ReciprocalBlock
  63174. * @param name defines the block name
  63175. */
  63176. constructor(name: string);
  63177. /**
  63178. * Gets the current class name
  63179. * @returns the class name
  63180. */
  63181. getClassName(): string;
  63182. /**
  63183. * Gets the input component
  63184. */
  63185. get input(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the output component
  63188. */
  63189. get output(): NodeMaterialConnectionPoint;
  63190. protected _buildBlock(state: NodeMaterialBuildState): this;
  63191. }
  63192. }
  63193. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63197. /**
  63198. * Block used to replace a color by another one
  63199. */
  63200. export class ReplaceColorBlock extends NodeMaterialBlock {
  63201. /**
  63202. * Creates a new ReplaceColorBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the value input component
  63213. */
  63214. get value(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the reference input component
  63217. */
  63218. get reference(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the distance input component
  63221. */
  63222. get distance(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the replacement input component
  63225. */
  63226. get replacement(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the output component
  63229. */
  63230. get output(): NodeMaterialConnectionPoint;
  63231. protected _buildBlock(state: NodeMaterialBuildState): this;
  63232. }
  63233. }
  63234. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63238. /**
  63239. * Block used to posterize a value
  63240. * @see https://en.wikipedia.org/wiki/Posterization
  63241. */
  63242. export class PosterizeBlock extends NodeMaterialBlock {
  63243. /**
  63244. * Creates a new PosterizeBlock
  63245. * @param name defines the block name
  63246. */
  63247. constructor(name: string);
  63248. /**
  63249. * Gets the current class name
  63250. * @returns the class name
  63251. */
  63252. getClassName(): string;
  63253. /**
  63254. * Gets the value input component
  63255. */
  63256. get value(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the steps input component
  63259. */
  63260. get steps(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the output component
  63263. */
  63264. get output(): NodeMaterialConnectionPoint;
  63265. protected _buildBlock(state: NodeMaterialBuildState): this;
  63266. }
  63267. }
  63268. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63272. import { Scene } from "babylonjs/scene";
  63273. /**
  63274. * Operations supported by the Wave block
  63275. */
  63276. export enum WaveBlockKind {
  63277. /** SawTooth */
  63278. SawTooth = 0,
  63279. /** Square */
  63280. Square = 1,
  63281. /** Triangle */
  63282. Triangle = 2
  63283. }
  63284. /**
  63285. * Block used to apply wave operation to floats
  63286. */
  63287. export class WaveBlock extends NodeMaterialBlock {
  63288. /**
  63289. * Gets or sets the kibnd of wave to be applied by the block
  63290. */
  63291. kind: WaveBlockKind;
  63292. /**
  63293. * Creates a new WaveBlock
  63294. * @param name defines the block name
  63295. */
  63296. constructor(name: string);
  63297. /**
  63298. * Gets the current class name
  63299. * @returns the class name
  63300. */
  63301. getClassName(): string;
  63302. /**
  63303. * Gets the input component
  63304. */
  63305. get input(): NodeMaterialConnectionPoint;
  63306. /**
  63307. * Gets the output component
  63308. */
  63309. get output(): NodeMaterialConnectionPoint;
  63310. protected _buildBlock(state: NodeMaterialBuildState): this;
  63311. serialize(): any;
  63312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63313. }
  63314. }
  63315. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63319. import { Color3 } from "babylonjs/Maths/math.color";
  63320. import { Scene } from "babylonjs/scene";
  63321. /**
  63322. * Class used to store a color step for the GradientBlock
  63323. */
  63324. export class GradientBlockColorStep {
  63325. /**
  63326. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63327. */
  63328. step: number;
  63329. /**
  63330. * Gets or sets the color associated with this step
  63331. */
  63332. color: Color3;
  63333. /**
  63334. * Creates a new GradientBlockColorStep
  63335. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63336. * @param color defines the color associated with this step
  63337. */
  63338. constructor(
  63339. /**
  63340. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63341. */
  63342. step: number,
  63343. /**
  63344. * Gets or sets the color associated with this step
  63345. */
  63346. color: Color3);
  63347. }
  63348. /**
  63349. * Block used to return a color from a gradient based on an input value between 0 and 1
  63350. */
  63351. export class GradientBlock extends NodeMaterialBlock {
  63352. /**
  63353. * Gets or sets the list of color steps
  63354. */
  63355. colorSteps: GradientBlockColorStep[];
  63356. /**
  63357. * Creates a new GradientBlock
  63358. * @param name defines the block name
  63359. */
  63360. constructor(name: string);
  63361. /**
  63362. * Gets the current class name
  63363. * @returns the class name
  63364. */
  63365. getClassName(): string;
  63366. /**
  63367. * Gets the gradient input component
  63368. */
  63369. get gradient(): NodeMaterialConnectionPoint;
  63370. /**
  63371. * Gets the output component
  63372. */
  63373. get output(): NodeMaterialConnectionPoint;
  63374. private _writeColorConstant;
  63375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63376. serialize(): any;
  63377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63378. protected _dumpPropertiesCode(): string;
  63379. }
  63380. }
  63381. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63385. /**
  63386. * Block used to normalize lerp between 2 values
  63387. */
  63388. export class NLerpBlock extends NodeMaterialBlock {
  63389. /**
  63390. * Creates a new NLerpBlock
  63391. * @param name defines the block name
  63392. */
  63393. constructor(name: string);
  63394. /**
  63395. * Gets the current class name
  63396. * @returns the class name
  63397. */
  63398. getClassName(): string;
  63399. /**
  63400. * Gets the left operand input component
  63401. */
  63402. get left(): NodeMaterialConnectionPoint;
  63403. /**
  63404. * Gets the right operand input component
  63405. */
  63406. get right(): NodeMaterialConnectionPoint;
  63407. /**
  63408. * Gets the gradient operand input component
  63409. */
  63410. get gradient(): NodeMaterialConnectionPoint;
  63411. /**
  63412. * Gets the output component
  63413. */
  63414. get output(): NodeMaterialConnectionPoint;
  63415. protected _buildBlock(state: NodeMaterialBuildState): this;
  63416. }
  63417. }
  63418. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63422. import { Scene } from "babylonjs/scene";
  63423. /**
  63424. * block used to Generate a Worley Noise 3D Noise Pattern
  63425. */
  63426. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63427. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63428. manhattanDistance: boolean;
  63429. /**
  63430. * Creates a new WorleyNoise3DBlock
  63431. * @param name defines the block name
  63432. */
  63433. constructor(name: string);
  63434. /**
  63435. * Gets the current class name
  63436. * @returns the class name
  63437. */
  63438. getClassName(): string;
  63439. /**
  63440. * Gets the seed input component
  63441. */
  63442. get seed(): NodeMaterialConnectionPoint;
  63443. /**
  63444. * Gets the jitter input component
  63445. */
  63446. get jitter(): NodeMaterialConnectionPoint;
  63447. /**
  63448. * Gets the output component
  63449. */
  63450. get output(): NodeMaterialConnectionPoint;
  63451. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63452. /**
  63453. * Exposes the properties to the UI?
  63454. */
  63455. protected _dumpPropertiesCode(): string;
  63456. /**
  63457. * Exposes the properties to the Seralize?
  63458. */
  63459. serialize(): any;
  63460. /**
  63461. * Exposes the properties to the deseralize?
  63462. */
  63463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63464. }
  63465. }
  63466. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63470. /**
  63471. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63472. */
  63473. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63474. /**
  63475. * Creates a new SimplexPerlin3DBlock
  63476. * @param name defines the block name
  63477. */
  63478. constructor(name: string);
  63479. /**
  63480. * Gets the current class name
  63481. * @returns the class name
  63482. */
  63483. getClassName(): string;
  63484. /**
  63485. * Gets the seed operand input component
  63486. */
  63487. get seed(): NodeMaterialConnectionPoint;
  63488. /**
  63489. * Gets the output component
  63490. */
  63491. get output(): NodeMaterialConnectionPoint;
  63492. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63493. }
  63494. }
  63495. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63499. /**
  63500. * Block used to blend normals
  63501. */
  63502. export class NormalBlendBlock extends NodeMaterialBlock {
  63503. /**
  63504. * Creates a new NormalBlendBlock
  63505. * @param name defines the block name
  63506. */
  63507. constructor(name: string);
  63508. /**
  63509. * Gets the current class name
  63510. * @returns the class name
  63511. */
  63512. getClassName(): string;
  63513. /**
  63514. * Gets the first input component
  63515. */
  63516. get normalMap0(): NodeMaterialConnectionPoint;
  63517. /**
  63518. * Gets the second input component
  63519. */
  63520. get normalMap1(): NodeMaterialConnectionPoint;
  63521. /**
  63522. * Gets the output component
  63523. */
  63524. get output(): NodeMaterialConnectionPoint;
  63525. protected _buildBlock(state: NodeMaterialBuildState): this;
  63526. }
  63527. }
  63528. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63532. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63533. /**
  63534. * Block used to rotate a 2d vector by a given angle
  63535. */
  63536. export class Rotate2dBlock extends NodeMaterialBlock {
  63537. /**
  63538. * Creates a new Rotate2dBlock
  63539. * @param name defines the block name
  63540. */
  63541. constructor(name: string);
  63542. /**
  63543. * Gets the current class name
  63544. * @returns the class name
  63545. */
  63546. getClassName(): string;
  63547. /**
  63548. * Gets the input vector
  63549. */
  63550. get input(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the input angle
  63553. */
  63554. get angle(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the output component
  63557. */
  63558. get output(): NodeMaterialConnectionPoint;
  63559. autoConfigure(material: NodeMaterial): void;
  63560. protected _buildBlock(state: NodeMaterialBuildState): this;
  63561. }
  63562. }
  63563. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63567. /**
  63568. * Block used to get the reflected vector from a direction and a normal
  63569. */
  63570. export class ReflectBlock extends NodeMaterialBlock {
  63571. /**
  63572. * Creates a new ReflectBlock
  63573. * @param name defines the block name
  63574. */
  63575. constructor(name: string);
  63576. /**
  63577. * Gets the current class name
  63578. * @returns the class name
  63579. */
  63580. getClassName(): string;
  63581. /**
  63582. * Gets the incident component
  63583. */
  63584. get incident(): NodeMaterialConnectionPoint;
  63585. /**
  63586. * Gets the normal component
  63587. */
  63588. get normal(): NodeMaterialConnectionPoint;
  63589. /**
  63590. * Gets the output component
  63591. */
  63592. get output(): NodeMaterialConnectionPoint;
  63593. protected _buildBlock(state: NodeMaterialBuildState): this;
  63594. }
  63595. }
  63596. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63600. /**
  63601. * Block used to get the refracted vector from a direction and a normal
  63602. */
  63603. export class RefractBlock extends NodeMaterialBlock {
  63604. /**
  63605. * Creates a new RefractBlock
  63606. * @param name defines the block name
  63607. */
  63608. constructor(name: string);
  63609. /**
  63610. * Gets the current class name
  63611. * @returns the class name
  63612. */
  63613. getClassName(): string;
  63614. /**
  63615. * Gets the incident component
  63616. */
  63617. get incident(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the normal component
  63620. */
  63621. get normal(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the index of refraction component
  63624. */
  63625. get ior(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the output component
  63628. */
  63629. get output(): NodeMaterialConnectionPoint;
  63630. protected _buildBlock(state: NodeMaterialBuildState): this;
  63631. }
  63632. }
  63633. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63637. /**
  63638. * Block used to desaturate a color
  63639. */
  63640. export class DesaturateBlock extends NodeMaterialBlock {
  63641. /**
  63642. * Creates a new DesaturateBlock
  63643. * @param name defines the block name
  63644. */
  63645. constructor(name: string);
  63646. /**
  63647. * Gets the current class name
  63648. * @returns the class name
  63649. */
  63650. getClassName(): string;
  63651. /**
  63652. * Gets the color operand input component
  63653. */
  63654. get color(): NodeMaterialConnectionPoint;
  63655. /**
  63656. * Gets the level operand input component
  63657. */
  63658. get level(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the output component
  63661. */
  63662. get output(): NodeMaterialConnectionPoint;
  63663. protected _buildBlock(state: NodeMaterialBuildState): this;
  63664. }
  63665. }
  63666. declare module "babylonjs/Materials/Node/Blocks/index" {
  63667. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63668. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63669. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63670. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63671. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63672. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63673. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63674. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63675. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63676. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63677. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63678. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63679. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63680. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63681. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63682. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63683. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63684. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63685. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63686. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63687. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63688. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63689. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63690. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63691. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63692. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63693. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63694. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63695. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63696. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63697. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63698. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63699. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63700. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63701. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63702. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63703. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63704. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63705. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63706. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63707. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63708. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63709. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63710. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63711. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63712. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63713. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63714. }
  63715. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63716. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63717. }
  63718. declare module "babylonjs/Materials/Node/index" {
  63719. export * from "babylonjs/Materials/Node/Enums/index";
  63720. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63721. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63722. export * from "babylonjs/Materials/Node/nodeMaterial";
  63723. export * from "babylonjs/Materials/Node/Blocks/index";
  63724. export * from "babylonjs/Materials/Node/Optimizers/index";
  63725. }
  63726. declare module "babylonjs/Materials/effectRenderer" {
  63727. import { Nullable } from "babylonjs/types";
  63728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63729. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63730. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63731. import { Viewport } from "babylonjs/Maths/math.viewport";
  63732. import { Observable } from "babylonjs/Misc/observable";
  63733. import { Effect } from "babylonjs/Materials/effect";
  63734. import "babylonjs/Shaders/postprocess.vertex";
  63735. /**
  63736. * Effect Render Options
  63737. */
  63738. export interface IEffectRendererOptions {
  63739. /**
  63740. * Defines the vertices positions.
  63741. */
  63742. positions?: number[];
  63743. /**
  63744. * Defines the indices.
  63745. */
  63746. indices?: number[];
  63747. }
  63748. /**
  63749. * Helper class to render one or more effects.
  63750. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63751. */
  63752. export class EffectRenderer {
  63753. private engine;
  63754. private static _DefaultOptions;
  63755. private _vertexBuffers;
  63756. private _indexBuffer;
  63757. private _fullscreenViewport;
  63758. /**
  63759. * Creates an effect renderer
  63760. * @param engine the engine to use for rendering
  63761. * @param options defines the options of the effect renderer
  63762. */
  63763. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63764. /**
  63765. * Sets the current viewport in normalized coordinates 0-1
  63766. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63767. */
  63768. setViewport(viewport?: Viewport): void;
  63769. /**
  63770. * Binds the embedded attributes buffer to the effect.
  63771. * @param effect Defines the effect to bind the attributes for
  63772. */
  63773. bindBuffers(effect: Effect): void;
  63774. /**
  63775. * Sets the current effect wrapper to use during draw.
  63776. * The effect needs to be ready before calling this api.
  63777. * This also sets the default full screen position attribute.
  63778. * @param effectWrapper Defines the effect to draw with
  63779. */
  63780. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63781. /**
  63782. * Draws a full screen quad.
  63783. */
  63784. draw(): void;
  63785. private isRenderTargetTexture;
  63786. /**
  63787. * renders one or more effects to a specified texture
  63788. * @param effectWrapper the effect to renderer
  63789. * @param outputTexture texture to draw to, if null it will render to the screen.
  63790. */
  63791. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63792. /**
  63793. * Disposes of the effect renderer
  63794. */
  63795. dispose(): void;
  63796. }
  63797. /**
  63798. * Options to create an EffectWrapper
  63799. */
  63800. interface EffectWrapperCreationOptions {
  63801. /**
  63802. * Engine to use to create the effect
  63803. */
  63804. engine: ThinEngine;
  63805. /**
  63806. * Fragment shader for the effect
  63807. */
  63808. fragmentShader: string;
  63809. /**
  63810. * Vertex shader for the effect
  63811. */
  63812. vertexShader?: string;
  63813. /**
  63814. * Attributes to use in the shader
  63815. */
  63816. attributeNames?: Array<string>;
  63817. /**
  63818. * Uniforms to use in the shader
  63819. */
  63820. uniformNames?: Array<string>;
  63821. /**
  63822. * Texture sampler names to use in the shader
  63823. */
  63824. samplerNames?: Array<string>;
  63825. /**
  63826. * The friendly name of the effect displayed in Spector.
  63827. */
  63828. name?: string;
  63829. }
  63830. /**
  63831. * Wraps an effect to be used for rendering
  63832. */
  63833. export class EffectWrapper {
  63834. /**
  63835. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63836. */
  63837. onApplyObservable: Observable<{}>;
  63838. /**
  63839. * The underlying effect
  63840. */
  63841. effect: Effect;
  63842. /**
  63843. * Creates an effect to be renderer
  63844. * @param creationOptions options to create the effect
  63845. */
  63846. constructor(creationOptions: EffectWrapperCreationOptions);
  63847. /**
  63848. * Disposes of the effect wrapper
  63849. */
  63850. dispose(): void;
  63851. }
  63852. }
  63853. declare module "babylonjs/Materials/index" {
  63854. export * from "babylonjs/Materials/Background/index";
  63855. export * from "babylonjs/Materials/colorCurves";
  63856. export * from "babylonjs/Materials/iEffectFallbacks";
  63857. export * from "babylonjs/Materials/effectFallbacks";
  63858. export * from "babylonjs/Materials/effect";
  63859. export * from "babylonjs/Materials/fresnelParameters";
  63860. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63861. export * from "babylonjs/Materials/material";
  63862. export * from "babylonjs/Materials/materialDefines";
  63863. export * from "babylonjs/Materials/materialHelper";
  63864. export * from "babylonjs/Materials/multiMaterial";
  63865. export * from "babylonjs/Materials/PBR/index";
  63866. export * from "babylonjs/Materials/pushMaterial";
  63867. export * from "babylonjs/Materials/shaderMaterial";
  63868. export * from "babylonjs/Materials/standardMaterial";
  63869. export * from "babylonjs/Materials/Textures/index";
  63870. export * from "babylonjs/Materials/uniformBuffer";
  63871. export * from "babylonjs/Materials/materialFlags";
  63872. export * from "babylonjs/Materials/Node/index";
  63873. export * from "babylonjs/Materials/effectRenderer";
  63874. }
  63875. declare module "babylonjs/Maths/index" {
  63876. export * from "babylonjs/Maths/math.scalar";
  63877. export * from "babylonjs/Maths/math";
  63878. export * from "babylonjs/Maths/sphericalPolynomial";
  63879. }
  63880. declare module "babylonjs/Misc/workerPool" {
  63881. import { IDisposable } from "babylonjs/scene";
  63882. /**
  63883. * Helper class to push actions to a pool of workers.
  63884. */
  63885. export class WorkerPool implements IDisposable {
  63886. private _workerInfos;
  63887. private _pendingActions;
  63888. /**
  63889. * Constructor
  63890. * @param workers Array of workers to use for actions
  63891. */
  63892. constructor(workers: Array<Worker>);
  63893. /**
  63894. * Terminates all workers and clears any pending actions.
  63895. */
  63896. dispose(): void;
  63897. /**
  63898. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63899. * pended until a worker has completed its action.
  63900. * @param action The action to perform. Call onComplete when the action is complete.
  63901. */
  63902. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63903. private _execute;
  63904. }
  63905. }
  63906. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63907. import { IDisposable } from "babylonjs/scene";
  63908. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63909. /**
  63910. * Configuration for Draco compression
  63911. */
  63912. export interface IDracoCompressionConfiguration {
  63913. /**
  63914. * Configuration for the decoder.
  63915. */
  63916. decoder: {
  63917. /**
  63918. * The url to the WebAssembly module.
  63919. */
  63920. wasmUrl?: string;
  63921. /**
  63922. * The url to the WebAssembly binary.
  63923. */
  63924. wasmBinaryUrl?: string;
  63925. /**
  63926. * The url to the fallback JavaScript module.
  63927. */
  63928. fallbackUrl?: string;
  63929. };
  63930. }
  63931. /**
  63932. * Draco compression (https://google.github.io/draco/)
  63933. *
  63934. * This class wraps the Draco module.
  63935. *
  63936. * **Encoder**
  63937. *
  63938. * The encoder is not currently implemented.
  63939. *
  63940. * **Decoder**
  63941. *
  63942. * 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.
  63943. *
  63944. * To update the configuration, use the following code:
  63945. * ```javascript
  63946. * DracoCompression.Configuration = {
  63947. * decoder: {
  63948. * wasmUrl: "<url to the WebAssembly library>",
  63949. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63950. * fallbackUrl: "<url to the fallback JavaScript library>",
  63951. * }
  63952. * };
  63953. * ```
  63954. *
  63955. * 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.
  63956. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63957. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63958. *
  63959. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63960. * ```javascript
  63961. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63962. * ```
  63963. *
  63964. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63965. */
  63966. export class DracoCompression implements IDisposable {
  63967. private _workerPoolPromise?;
  63968. private _decoderModulePromise?;
  63969. /**
  63970. * The configuration. Defaults to the following urls:
  63971. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63972. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63973. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63974. */
  63975. static Configuration: IDracoCompressionConfiguration;
  63976. /**
  63977. * Returns true if the decoder configuration is available.
  63978. */
  63979. static get DecoderAvailable(): boolean;
  63980. /**
  63981. * Default number of workers to create when creating the draco compression object.
  63982. */
  63983. static DefaultNumWorkers: number;
  63984. private static GetDefaultNumWorkers;
  63985. private static _Default;
  63986. /**
  63987. * Default instance for the draco compression object.
  63988. */
  63989. static get Default(): DracoCompression;
  63990. /**
  63991. * Constructor
  63992. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63993. */
  63994. constructor(numWorkers?: number);
  63995. /**
  63996. * Stop all async operations and release resources.
  63997. */
  63998. dispose(): void;
  63999. /**
  64000. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64001. * @returns a promise that resolves when ready
  64002. */
  64003. whenReadyAsync(): Promise<void>;
  64004. /**
  64005. * Decode Draco compressed mesh data to vertex data.
  64006. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64007. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64008. * @returns A promise that resolves with the decoded vertex data
  64009. */
  64010. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64011. [kind: string]: number;
  64012. }): Promise<VertexData>;
  64013. }
  64014. }
  64015. declare module "babylonjs/Meshes/Compression/index" {
  64016. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64017. }
  64018. declare module "babylonjs/Meshes/csg" {
  64019. import { Nullable } from "babylonjs/types";
  64020. import { Scene } from "babylonjs/scene";
  64021. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64022. import { Mesh } from "babylonjs/Meshes/mesh";
  64023. import { Material } from "babylonjs/Materials/material";
  64024. /**
  64025. * Class for building Constructive Solid Geometry
  64026. */
  64027. export class CSG {
  64028. private polygons;
  64029. /**
  64030. * The world matrix
  64031. */
  64032. matrix: Matrix;
  64033. /**
  64034. * Stores the position
  64035. */
  64036. position: Vector3;
  64037. /**
  64038. * Stores the rotation
  64039. */
  64040. rotation: Vector3;
  64041. /**
  64042. * Stores the rotation quaternion
  64043. */
  64044. rotationQuaternion: Nullable<Quaternion>;
  64045. /**
  64046. * Stores the scaling vector
  64047. */
  64048. scaling: Vector3;
  64049. /**
  64050. * Convert the Mesh to CSG
  64051. * @param mesh The Mesh to convert to CSG
  64052. * @returns A new CSG from the Mesh
  64053. */
  64054. static FromMesh(mesh: Mesh): CSG;
  64055. /**
  64056. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64057. * @param polygons Polygons used to construct a CSG solid
  64058. */
  64059. private static FromPolygons;
  64060. /**
  64061. * Clones, or makes a deep copy, of the CSG
  64062. * @returns A new CSG
  64063. */
  64064. clone(): CSG;
  64065. /**
  64066. * Unions this CSG with another CSG
  64067. * @param csg The CSG to union against this CSG
  64068. * @returns The unioned CSG
  64069. */
  64070. union(csg: CSG): CSG;
  64071. /**
  64072. * Unions this CSG with another CSG in place
  64073. * @param csg The CSG to union against this CSG
  64074. */
  64075. unionInPlace(csg: CSG): void;
  64076. /**
  64077. * Subtracts this CSG with another CSG
  64078. * @param csg The CSG to subtract against this CSG
  64079. * @returns A new CSG
  64080. */
  64081. subtract(csg: CSG): CSG;
  64082. /**
  64083. * Subtracts this CSG with another CSG in place
  64084. * @param csg The CSG to subtact against this CSG
  64085. */
  64086. subtractInPlace(csg: CSG): void;
  64087. /**
  64088. * Intersect this CSG with another CSG
  64089. * @param csg The CSG to intersect against this CSG
  64090. * @returns A new CSG
  64091. */
  64092. intersect(csg: CSG): CSG;
  64093. /**
  64094. * Intersects this CSG with another CSG in place
  64095. * @param csg The CSG to intersect against this CSG
  64096. */
  64097. intersectInPlace(csg: CSG): void;
  64098. /**
  64099. * Return a new CSG solid with solid and empty space switched. This solid is
  64100. * not modified.
  64101. * @returns A new CSG solid with solid and empty space switched
  64102. */
  64103. inverse(): CSG;
  64104. /**
  64105. * Inverses the CSG in place
  64106. */
  64107. inverseInPlace(): void;
  64108. /**
  64109. * This is used to keep meshes transformations so they can be restored
  64110. * when we build back a Babylon Mesh
  64111. * NB : All CSG operations are performed in world coordinates
  64112. * @param csg The CSG to copy the transform attributes from
  64113. * @returns This CSG
  64114. */
  64115. copyTransformAttributes(csg: CSG): CSG;
  64116. /**
  64117. * Build Raw mesh from CSG
  64118. * Coordinates here are in world space
  64119. * @param name The name of the mesh geometry
  64120. * @param scene The Scene
  64121. * @param keepSubMeshes Specifies if the submeshes should be kept
  64122. * @returns A new Mesh
  64123. */
  64124. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64125. /**
  64126. * Build Mesh from CSG taking material and transforms into account
  64127. * @param name The name of the Mesh
  64128. * @param material The material of the Mesh
  64129. * @param scene The Scene
  64130. * @param keepSubMeshes Specifies if submeshes should be kept
  64131. * @returns The new Mesh
  64132. */
  64133. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64134. }
  64135. }
  64136. declare module "babylonjs/Meshes/trailMesh" {
  64137. import { Mesh } from "babylonjs/Meshes/mesh";
  64138. import { Scene } from "babylonjs/scene";
  64139. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64140. /**
  64141. * Class used to create a trail following a mesh
  64142. */
  64143. export class TrailMesh extends Mesh {
  64144. private _generator;
  64145. private _autoStart;
  64146. private _running;
  64147. private _diameter;
  64148. private _length;
  64149. private _sectionPolygonPointsCount;
  64150. private _sectionVectors;
  64151. private _sectionNormalVectors;
  64152. private _beforeRenderObserver;
  64153. /**
  64154. * @constructor
  64155. * @param name The value used by scene.getMeshByName() to do a lookup.
  64156. * @param generator The mesh or transform node to generate a trail.
  64157. * @param scene The scene to add this mesh to.
  64158. * @param diameter Diameter of trailing mesh. Default is 1.
  64159. * @param length Length of trailing mesh. Default is 60.
  64160. * @param autoStart Automatically start trailing mesh. Default true.
  64161. */
  64162. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64163. /**
  64164. * "TrailMesh"
  64165. * @returns "TrailMesh"
  64166. */
  64167. getClassName(): string;
  64168. private _createMesh;
  64169. /**
  64170. * Start trailing mesh.
  64171. */
  64172. start(): void;
  64173. /**
  64174. * Stop trailing mesh.
  64175. */
  64176. stop(): void;
  64177. /**
  64178. * Update trailing mesh geometry.
  64179. */
  64180. update(): void;
  64181. /**
  64182. * Returns a new TrailMesh object.
  64183. * @param name is a string, the name given to the new mesh
  64184. * @param newGenerator use new generator object for cloned trail mesh
  64185. * @returns a new mesh
  64186. */
  64187. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64188. /**
  64189. * Serializes this trail mesh
  64190. * @param serializationObject object to write serialization to
  64191. */
  64192. serialize(serializationObject: any): void;
  64193. /**
  64194. * Parses a serialized trail mesh
  64195. * @param parsedMesh the serialized mesh
  64196. * @param scene the scene to create the trail mesh in
  64197. * @returns the created trail mesh
  64198. */
  64199. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64200. }
  64201. }
  64202. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64203. import { Nullable } from "babylonjs/types";
  64204. import { Scene } from "babylonjs/scene";
  64205. import { Vector4 } from "babylonjs/Maths/math.vector";
  64206. import { Color4 } from "babylonjs/Maths/math.color";
  64207. import { Mesh } from "babylonjs/Meshes/mesh";
  64208. /**
  64209. * Class containing static functions to help procedurally build meshes
  64210. */
  64211. export class TiledBoxBuilder {
  64212. /**
  64213. * Creates a box mesh
  64214. * 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)
  64215. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64219. * @param name defines the name of the mesh
  64220. * @param options defines the options used to create the mesh
  64221. * @param scene defines the hosting scene
  64222. * @returns the box mesh
  64223. */
  64224. static CreateTiledBox(name: string, options: {
  64225. pattern?: number;
  64226. width?: number;
  64227. height?: number;
  64228. depth?: number;
  64229. tileSize?: number;
  64230. tileWidth?: number;
  64231. tileHeight?: number;
  64232. alignHorizontal?: number;
  64233. alignVertical?: number;
  64234. faceUV?: Vector4[];
  64235. faceColors?: Color4[];
  64236. sideOrientation?: number;
  64237. updatable?: boolean;
  64238. }, scene?: Nullable<Scene>): Mesh;
  64239. }
  64240. }
  64241. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64242. import { Vector4 } from "babylonjs/Maths/math.vector";
  64243. import { Mesh } from "babylonjs/Meshes/mesh";
  64244. /**
  64245. * Class containing static functions to help procedurally build meshes
  64246. */
  64247. export class TorusKnotBuilder {
  64248. /**
  64249. * Creates a torus knot mesh
  64250. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64251. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64252. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64253. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64257. * @param name defines the name of the mesh
  64258. * @param options defines the options used to create the mesh
  64259. * @param scene defines the hosting scene
  64260. * @returns the torus knot mesh
  64261. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64262. */
  64263. static CreateTorusKnot(name: string, options: {
  64264. radius?: number;
  64265. tube?: number;
  64266. radialSegments?: number;
  64267. tubularSegments?: number;
  64268. p?: number;
  64269. q?: number;
  64270. updatable?: boolean;
  64271. sideOrientation?: number;
  64272. frontUVs?: Vector4;
  64273. backUVs?: Vector4;
  64274. }, scene: any): Mesh;
  64275. }
  64276. }
  64277. declare module "babylonjs/Meshes/polygonMesh" {
  64278. import { Scene } from "babylonjs/scene";
  64279. import { Vector2 } from "babylonjs/Maths/math.vector";
  64280. import { Mesh } from "babylonjs/Meshes/mesh";
  64281. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64282. import { Path2 } from "babylonjs/Maths/math.path";
  64283. /**
  64284. * Polygon
  64285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64286. */
  64287. export class Polygon {
  64288. /**
  64289. * Creates a rectangle
  64290. * @param xmin bottom X coord
  64291. * @param ymin bottom Y coord
  64292. * @param xmax top X coord
  64293. * @param ymax top Y coord
  64294. * @returns points that make the resulting rectation
  64295. */
  64296. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64297. /**
  64298. * Creates a circle
  64299. * @param radius radius of circle
  64300. * @param cx scale in x
  64301. * @param cy scale in y
  64302. * @param numberOfSides number of sides that make up the circle
  64303. * @returns points that make the resulting circle
  64304. */
  64305. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64306. /**
  64307. * Creates a polygon from input string
  64308. * @param input Input polygon data
  64309. * @returns the parsed points
  64310. */
  64311. static Parse(input: string): Vector2[];
  64312. /**
  64313. * Starts building a polygon from x and y coordinates
  64314. * @param x x coordinate
  64315. * @param y y coordinate
  64316. * @returns the started path2
  64317. */
  64318. static StartingAt(x: number, y: number): Path2;
  64319. }
  64320. /**
  64321. * Builds a polygon
  64322. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64323. */
  64324. export class PolygonMeshBuilder {
  64325. private _points;
  64326. private _outlinepoints;
  64327. private _holes;
  64328. private _name;
  64329. private _scene;
  64330. private _epoints;
  64331. private _eholes;
  64332. private _addToepoint;
  64333. /**
  64334. * Babylon reference to the earcut plugin.
  64335. */
  64336. bjsEarcut: any;
  64337. /**
  64338. * Creates a PolygonMeshBuilder
  64339. * @param name name of the builder
  64340. * @param contours Path of the polygon
  64341. * @param scene scene to add to when creating the mesh
  64342. * @param earcutInjection can be used to inject your own earcut reference
  64343. */
  64344. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64345. /**
  64346. * Adds a whole within the polygon
  64347. * @param hole Array of points defining the hole
  64348. * @returns this
  64349. */
  64350. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64351. /**
  64352. * Creates the polygon
  64353. * @param updatable If the mesh should be updatable
  64354. * @param depth The depth of the mesh created
  64355. * @returns the created mesh
  64356. */
  64357. build(updatable?: boolean, depth?: number): Mesh;
  64358. /**
  64359. * Creates the polygon
  64360. * @param depth The depth of the mesh created
  64361. * @returns the created VertexData
  64362. */
  64363. buildVertexData(depth?: number): VertexData;
  64364. /**
  64365. * Adds a side to the polygon
  64366. * @param positions points that make the polygon
  64367. * @param normals normals of the polygon
  64368. * @param uvs uvs of the polygon
  64369. * @param indices indices of the polygon
  64370. * @param bounds bounds of the polygon
  64371. * @param points points of the polygon
  64372. * @param depth depth of the polygon
  64373. * @param flip flip of the polygon
  64374. */
  64375. private addSide;
  64376. }
  64377. }
  64378. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64379. import { Scene } from "babylonjs/scene";
  64380. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64381. import { Color4 } from "babylonjs/Maths/math.color";
  64382. import { Mesh } from "babylonjs/Meshes/mesh";
  64383. import { Nullable } from "babylonjs/types";
  64384. /**
  64385. * Class containing static functions to help procedurally build meshes
  64386. */
  64387. export class PolygonBuilder {
  64388. /**
  64389. * Creates a polygon mesh
  64390. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64391. * * 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
  64392. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64395. * * Remember you can only change the shape positions, not their number when updating a polygon
  64396. * @param name defines the name of the mesh
  64397. * @param options defines the options used to create the mesh
  64398. * @param scene defines the hosting scene
  64399. * @param earcutInjection can be used to inject your own earcut reference
  64400. * @returns the polygon mesh
  64401. */
  64402. static CreatePolygon(name: string, options: {
  64403. shape: Vector3[];
  64404. holes?: Vector3[][];
  64405. depth?: number;
  64406. faceUV?: Vector4[];
  64407. faceColors?: Color4[];
  64408. updatable?: boolean;
  64409. sideOrientation?: number;
  64410. frontUVs?: Vector4;
  64411. backUVs?: Vector4;
  64412. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64413. /**
  64414. * Creates an extruded polygon mesh, with depth in the Y direction.
  64415. * * 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)
  64416. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64417. * @param name defines the name of the mesh
  64418. * @param options defines the options used to create the mesh
  64419. * @param scene defines the hosting scene
  64420. * @param earcutInjection can be used to inject your own earcut reference
  64421. * @returns the polygon mesh
  64422. */
  64423. static ExtrudePolygon(name: string, options: {
  64424. shape: Vector3[];
  64425. holes?: Vector3[][];
  64426. depth?: number;
  64427. faceUV?: Vector4[];
  64428. faceColors?: Color4[];
  64429. updatable?: boolean;
  64430. sideOrientation?: number;
  64431. frontUVs?: Vector4;
  64432. backUVs?: Vector4;
  64433. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64434. }
  64435. }
  64436. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64437. import { Scene } from "babylonjs/scene";
  64438. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64439. import { Mesh } from "babylonjs/Meshes/mesh";
  64440. import { Nullable } from "babylonjs/types";
  64441. /**
  64442. * Class containing static functions to help procedurally build meshes
  64443. */
  64444. export class LatheBuilder {
  64445. /**
  64446. * Creates lathe mesh.
  64447. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64448. * * 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
  64449. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64450. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64451. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64452. * * 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
  64453. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64454. * * 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
  64455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64457. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64459. * @param name defines the name of the mesh
  64460. * @param options defines the options used to create the mesh
  64461. * @param scene defines the hosting scene
  64462. * @returns the lathe mesh
  64463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64464. */
  64465. static CreateLathe(name: string, options: {
  64466. shape: Vector3[];
  64467. radius?: number;
  64468. tessellation?: number;
  64469. clip?: number;
  64470. arc?: number;
  64471. closed?: boolean;
  64472. updatable?: boolean;
  64473. sideOrientation?: number;
  64474. frontUVs?: Vector4;
  64475. backUVs?: Vector4;
  64476. cap?: number;
  64477. invertUV?: boolean;
  64478. }, scene?: Nullable<Scene>): Mesh;
  64479. }
  64480. }
  64481. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64482. import { Nullable } from "babylonjs/types";
  64483. import { Scene } from "babylonjs/scene";
  64484. import { Vector4 } from "babylonjs/Maths/math.vector";
  64485. import { Mesh } from "babylonjs/Meshes/mesh";
  64486. /**
  64487. * Class containing static functions to help procedurally build meshes
  64488. */
  64489. export class TiledPlaneBuilder {
  64490. /**
  64491. * Creates a tiled plane mesh
  64492. * * The parameter `pattern` will, depending on value, do nothing or
  64493. * * * flip (reflect about central vertical) alternate tiles across and up
  64494. * * * flip every tile on alternate rows
  64495. * * * rotate (180 degs) alternate tiles across and up
  64496. * * * rotate every tile on alternate rows
  64497. * * * flip and rotate alternate tiles across and up
  64498. * * * flip and rotate every tile on alternate rows
  64499. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64500. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64503. * * 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)
  64504. * * 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)
  64505. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64506. * @param name defines the name of the mesh
  64507. * @param options defines the options used to create the mesh
  64508. * @param scene defines the hosting scene
  64509. * @returns the box mesh
  64510. */
  64511. static CreateTiledPlane(name: string, options: {
  64512. pattern?: number;
  64513. tileSize?: number;
  64514. tileWidth?: number;
  64515. tileHeight?: number;
  64516. size?: number;
  64517. width?: number;
  64518. height?: number;
  64519. alignHorizontal?: number;
  64520. alignVertical?: number;
  64521. sideOrientation?: number;
  64522. frontUVs?: Vector4;
  64523. backUVs?: Vector4;
  64524. updatable?: boolean;
  64525. }, scene?: Nullable<Scene>): Mesh;
  64526. }
  64527. }
  64528. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64529. import { Nullable } from "babylonjs/types";
  64530. import { Scene } from "babylonjs/scene";
  64531. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64532. import { Mesh } from "babylonjs/Meshes/mesh";
  64533. /**
  64534. * Class containing static functions to help procedurally build meshes
  64535. */
  64536. export class TubeBuilder {
  64537. /**
  64538. * Creates a tube mesh.
  64539. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64540. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64541. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64542. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64543. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64544. * * 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)
  64545. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64546. * * 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
  64547. * * 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
  64548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64552. * @param name defines the name of the mesh
  64553. * @param options defines the options used to create the mesh
  64554. * @param scene defines the hosting scene
  64555. * @returns the tube mesh
  64556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64557. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64558. */
  64559. static CreateTube(name: string, options: {
  64560. path: Vector3[];
  64561. radius?: number;
  64562. tessellation?: number;
  64563. radiusFunction?: {
  64564. (i: number, distance: number): number;
  64565. };
  64566. cap?: number;
  64567. arc?: number;
  64568. updatable?: boolean;
  64569. sideOrientation?: number;
  64570. frontUVs?: Vector4;
  64571. backUVs?: Vector4;
  64572. instance?: Mesh;
  64573. invertUV?: boolean;
  64574. }, scene?: Nullable<Scene>): Mesh;
  64575. }
  64576. }
  64577. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64578. import { Scene } from "babylonjs/scene";
  64579. import { Vector4 } from "babylonjs/Maths/math.vector";
  64580. import { Mesh } from "babylonjs/Meshes/mesh";
  64581. import { Nullable } from "babylonjs/types";
  64582. /**
  64583. * Class containing static functions to help procedurally build meshes
  64584. */
  64585. export class IcoSphereBuilder {
  64586. /**
  64587. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64588. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64589. * * 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`)
  64590. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64591. * * 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
  64592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64595. * @param name defines the name of the mesh
  64596. * @param options defines the options used to create the mesh
  64597. * @param scene defines the hosting scene
  64598. * @returns the icosahedron mesh
  64599. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64600. */
  64601. static CreateIcoSphere(name: string, options: {
  64602. radius?: number;
  64603. radiusX?: number;
  64604. radiusY?: number;
  64605. radiusZ?: number;
  64606. flat?: boolean;
  64607. subdivisions?: number;
  64608. sideOrientation?: number;
  64609. frontUVs?: Vector4;
  64610. backUVs?: Vector4;
  64611. updatable?: boolean;
  64612. }, scene?: Nullable<Scene>): Mesh;
  64613. }
  64614. }
  64615. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64616. import { Vector3 } from "babylonjs/Maths/math.vector";
  64617. import { Mesh } from "babylonjs/Meshes/mesh";
  64618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64619. /**
  64620. * Class containing static functions to help procedurally build meshes
  64621. */
  64622. export class DecalBuilder {
  64623. /**
  64624. * Creates a decal mesh.
  64625. * 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
  64626. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64627. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64628. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64629. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64630. * @param name defines the name of the mesh
  64631. * @param sourceMesh defines the mesh where the decal must be applied
  64632. * @param options defines the options used to create the mesh
  64633. * @param scene defines the hosting scene
  64634. * @returns the decal mesh
  64635. * @see https://doc.babylonjs.com/how_to/decals
  64636. */
  64637. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64638. position?: Vector3;
  64639. normal?: Vector3;
  64640. size?: Vector3;
  64641. angle?: number;
  64642. }): Mesh;
  64643. }
  64644. }
  64645. declare module "babylonjs/Meshes/meshBuilder" {
  64646. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64647. import { Nullable } from "babylonjs/types";
  64648. import { Scene } from "babylonjs/scene";
  64649. import { Mesh } from "babylonjs/Meshes/mesh";
  64650. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64651. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64653. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64654. import { Plane } from "babylonjs/Maths/math.plane";
  64655. /**
  64656. * Class containing static functions to help procedurally build meshes
  64657. */
  64658. export class MeshBuilder {
  64659. /**
  64660. * Creates a box mesh
  64661. * * The parameter `size` sets the size (float) of each box side (default 1)
  64662. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64663. * * 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)
  64664. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64668. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64669. * @param name defines the name of the mesh
  64670. * @param options defines the options used to create the mesh
  64671. * @param scene defines the hosting scene
  64672. * @returns the box mesh
  64673. */
  64674. static CreateBox(name: string, options: {
  64675. size?: number;
  64676. width?: number;
  64677. height?: number;
  64678. depth?: number;
  64679. faceUV?: Vector4[];
  64680. faceColors?: Color4[];
  64681. sideOrientation?: number;
  64682. frontUVs?: Vector4;
  64683. backUVs?: Vector4;
  64684. wrap?: boolean;
  64685. topBaseAt?: number;
  64686. bottomBaseAt?: number;
  64687. updatable?: boolean;
  64688. }, scene?: Nullable<Scene>): Mesh;
  64689. /**
  64690. * Creates a tiled box mesh
  64691. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64693. * @param name defines the name of the mesh
  64694. * @param options defines the options used to create the mesh
  64695. * @param scene defines the hosting scene
  64696. * @returns the tiled box mesh
  64697. */
  64698. static CreateTiledBox(name: string, options: {
  64699. pattern?: number;
  64700. size?: number;
  64701. width?: number;
  64702. height?: number;
  64703. depth: number;
  64704. tileSize?: number;
  64705. tileWidth?: number;
  64706. tileHeight?: number;
  64707. faceUV?: Vector4[];
  64708. faceColors?: Color4[];
  64709. alignHorizontal?: number;
  64710. alignVertical?: number;
  64711. sideOrientation?: number;
  64712. updatable?: boolean;
  64713. }, scene?: Nullable<Scene>): Mesh;
  64714. /**
  64715. * Creates a sphere mesh
  64716. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64717. * * 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`)
  64718. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64719. * * 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
  64720. * * 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)
  64721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64724. * @param name defines the name of the mesh
  64725. * @param options defines the options used to create the mesh
  64726. * @param scene defines the hosting scene
  64727. * @returns the sphere mesh
  64728. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64729. */
  64730. static CreateSphere(name: string, options: {
  64731. segments?: number;
  64732. diameter?: number;
  64733. diameterX?: number;
  64734. diameterY?: number;
  64735. diameterZ?: number;
  64736. arc?: number;
  64737. slice?: number;
  64738. sideOrientation?: number;
  64739. frontUVs?: Vector4;
  64740. backUVs?: Vector4;
  64741. updatable?: boolean;
  64742. }, scene?: Nullable<Scene>): Mesh;
  64743. /**
  64744. * Creates a plane polygonal mesh. By default, this is a disc
  64745. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64746. * * 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
  64747. * * 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
  64748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64751. * @param name defines the name of the mesh
  64752. * @param options defines the options used to create the mesh
  64753. * @param scene defines the hosting scene
  64754. * @returns the plane polygonal mesh
  64755. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64756. */
  64757. static CreateDisc(name: string, options: {
  64758. radius?: number;
  64759. tessellation?: number;
  64760. arc?: number;
  64761. updatable?: boolean;
  64762. sideOrientation?: number;
  64763. frontUVs?: Vector4;
  64764. backUVs?: Vector4;
  64765. }, scene?: Nullable<Scene>): Mesh;
  64766. /**
  64767. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64768. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64769. * * 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`)
  64770. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64771. * * 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
  64772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64775. * @param name defines the name of the mesh
  64776. * @param options defines the options used to create the mesh
  64777. * @param scene defines the hosting scene
  64778. * @returns the icosahedron mesh
  64779. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64780. */
  64781. static CreateIcoSphere(name: string, options: {
  64782. radius?: number;
  64783. radiusX?: number;
  64784. radiusY?: number;
  64785. radiusZ?: number;
  64786. flat?: boolean;
  64787. subdivisions?: number;
  64788. sideOrientation?: number;
  64789. frontUVs?: Vector4;
  64790. backUVs?: Vector4;
  64791. updatable?: boolean;
  64792. }, scene?: Nullable<Scene>): Mesh;
  64793. /**
  64794. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64795. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64796. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64797. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64798. * * 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
  64799. * * 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
  64800. * * 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
  64801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64804. * * 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
  64805. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64806. * * 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
  64807. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64809. * @param name defines the name of the mesh
  64810. * @param options defines the options used to create the mesh
  64811. * @param scene defines the hosting scene
  64812. * @returns the ribbon mesh
  64813. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64814. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64815. */
  64816. static CreateRibbon(name: string, options: {
  64817. pathArray: Vector3[][];
  64818. closeArray?: boolean;
  64819. closePath?: boolean;
  64820. offset?: number;
  64821. updatable?: boolean;
  64822. sideOrientation?: number;
  64823. frontUVs?: Vector4;
  64824. backUVs?: Vector4;
  64825. instance?: Mesh;
  64826. invertUV?: boolean;
  64827. uvs?: Vector2[];
  64828. colors?: Color4[];
  64829. }, scene?: Nullable<Scene>): Mesh;
  64830. /**
  64831. * Creates a cylinder or a cone mesh
  64832. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64833. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64834. * * 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.
  64835. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64836. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64837. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64838. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64839. * * 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).
  64840. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64841. * * 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).
  64842. * * 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
  64843. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64844. * * 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
  64845. * * 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.
  64846. * * If `enclose` is false, a ring surface is one element.
  64847. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64848. * * 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
  64849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64852. * @param name defines the name of the mesh
  64853. * @param options defines the options used to create the mesh
  64854. * @param scene defines the hosting scene
  64855. * @returns the cylinder mesh
  64856. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64857. */
  64858. static CreateCylinder(name: string, options: {
  64859. height?: number;
  64860. diameterTop?: number;
  64861. diameterBottom?: number;
  64862. diameter?: number;
  64863. tessellation?: number;
  64864. subdivisions?: number;
  64865. arc?: number;
  64866. faceColors?: Color4[];
  64867. faceUV?: Vector4[];
  64868. updatable?: boolean;
  64869. hasRings?: boolean;
  64870. enclose?: boolean;
  64871. cap?: number;
  64872. sideOrientation?: number;
  64873. frontUVs?: Vector4;
  64874. backUVs?: Vector4;
  64875. }, scene?: Nullable<Scene>): Mesh;
  64876. /**
  64877. * Creates a torus mesh
  64878. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64879. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64880. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64884. * @param name defines the name of the mesh
  64885. * @param options defines the options used to create the mesh
  64886. * @param scene defines the hosting scene
  64887. * @returns the torus mesh
  64888. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64889. */
  64890. static CreateTorus(name: string, options: {
  64891. diameter?: number;
  64892. thickness?: number;
  64893. tessellation?: number;
  64894. updatable?: boolean;
  64895. sideOrientation?: number;
  64896. frontUVs?: Vector4;
  64897. backUVs?: Vector4;
  64898. }, scene?: Nullable<Scene>): Mesh;
  64899. /**
  64900. * Creates a torus knot mesh
  64901. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64902. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64903. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64904. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64908. * @param name defines the name of the mesh
  64909. * @param options defines the options used to create the mesh
  64910. * @param scene defines the hosting scene
  64911. * @returns the torus knot mesh
  64912. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64913. */
  64914. static CreateTorusKnot(name: string, options: {
  64915. radius?: number;
  64916. tube?: number;
  64917. radialSegments?: number;
  64918. tubularSegments?: number;
  64919. p?: number;
  64920. q?: number;
  64921. updatable?: boolean;
  64922. sideOrientation?: number;
  64923. frontUVs?: Vector4;
  64924. backUVs?: Vector4;
  64925. }, scene?: Nullable<Scene>): Mesh;
  64926. /**
  64927. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64928. * * 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
  64929. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64930. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64931. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64932. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64933. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64934. * * 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
  64935. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64938. * @param name defines the name of the new line system
  64939. * @param options defines the options used to create the line system
  64940. * @param scene defines the hosting scene
  64941. * @returns a new line system mesh
  64942. */
  64943. static CreateLineSystem(name: string, options: {
  64944. lines: Vector3[][];
  64945. updatable?: boolean;
  64946. instance?: Nullable<LinesMesh>;
  64947. colors?: Nullable<Color4[][]>;
  64948. useVertexAlpha?: boolean;
  64949. }, scene: Nullable<Scene>): LinesMesh;
  64950. /**
  64951. * Creates a line mesh
  64952. * 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
  64953. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64954. * * The parameter `points` is an array successive Vector3
  64955. * * 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
  64956. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64957. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64958. * * When updating an instance, remember that only point positions can change, not the number of points
  64959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64961. * @param name defines the name of the new line system
  64962. * @param options defines the options used to create the line system
  64963. * @param scene defines the hosting scene
  64964. * @returns a new line mesh
  64965. */
  64966. static CreateLines(name: string, options: {
  64967. points: Vector3[];
  64968. updatable?: boolean;
  64969. instance?: Nullable<LinesMesh>;
  64970. colors?: Color4[];
  64971. useVertexAlpha?: boolean;
  64972. }, scene?: Nullable<Scene>): LinesMesh;
  64973. /**
  64974. * Creates a dashed line mesh
  64975. * * 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
  64976. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64977. * * The parameter `points` is an array successive Vector3
  64978. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64979. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64980. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64981. * * 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
  64982. * * When updating an instance, remember that only point positions can change, not the number of points
  64983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64984. * @param name defines the name of the mesh
  64985. * @param options defines the options used to create the mesh
  64986. * @param scene defines the hosting scene
  64987. * @returns the dashed line mesh
  64988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64989. */
  64990. static CreateDashedLines(name: string, options: {
  64991. points: Vector3[];
  64992. dashSize?: number;
  64993. gapSize?: number;
  64994. dashNb?: number;
  64995. updatable?: boolean;
  64996. instance?: LinesMesh;
  64997. }, scene?: Nullable<Scene>): LinesMesh;
  64998. /**
  64999. * 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.
  65000. * * 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.
  65001. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65002. * * 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.
  65003. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65004. * * 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
  65005. * * 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
  65006. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65009. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65011. * @param name defines the name of the mesh
  65012. * @param options defines the options used to create the mesh
  65013. * @param scene defines the hosting scene
  65014. * @returns the extruded shape mesh
  65015. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65017. */
  65018. static ExtrudeShape(name: string, options: {
  65019. shape: Vector3[];
  65020. path: Vector3[];
  65021. scale?: number;
  65022. rotation?: number;
  65023. cap?: number;
  65024. updatable?: boolean;
  65025. sideOrientation?: number;
  65026. frontUVs?: Vector4;
  65027. backUVs?: Vector4;
  65028. instance?: Mesh;
  65029. invertUV?: boolean;
  65030. }, scene?: Nullable<Scene>): Mesh;
  65031. /**
  65032. * Creates an custom extruded shape mesh.
  65033. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65034. * * 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.
  65035. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65036. * * 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
  65037. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65038. * * 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
  65039. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65040. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65041. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65042. * * 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
  65043. * * 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
  65044. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65047. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65049. * @param name defines the name of the mesh
  65050. * @param options defines the options used to create the mesh
  65051. * @param scene defines the hosting scene
  65052. * @returns the custom extruded shape mesh
  65053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65056. */
  65057. static ExtrudeShapeCustom(name: string, options: {
  65058. shape: Vector3[];
  65059. path: Vector3[];
  65060. scaleFunction?: any;
  65061. rotationFunction?: any;
  65062. ribbonCloseArray?: boolean;
  65063. ribbonClosePath?: boolean;
  65064. cap?: number;
  65065. updatable?: boolean;
  65066. sideOrientation?: number;
  65067. frontUVs?: Vector4;
  65068. backUVs?: Vector4;
  65069. instance?: Mesh;
  65070. invertUV?: boolean;
  65071. }, scene?: Nullable<Scene>): Mesh;
  65072. /**
  65073. * Creates lathe mesh.
  65074. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65075. * * 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
  65076. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65077. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65078. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65079. * * 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
  65080. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65081. * * 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
  65082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65086. * @param name defines the name of the mesh
  65087. * @param options defines the options used to create the mesh
  65088. * @param scene defines the hosting scene
  65089. * @returns the lathe mesh
  65090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65091. */
  65092. static CreateLathe(name: string, options: {
  65093. shape: Vector3[];
  65094. radius?: number;
  65095. tessellation?: number;
  65096. clip?: number;
  65097. arc?: number;
  65098. closed?: boolean;
  65099. updatable?: boolean;
  65100. sideOrientation?: number;
  65101. frontUVs?: Vector4;
  65102. backUVs?: Vector4;
  65103. cap?: number;
  65104. invertUV?: boolean;
  65105. }, scene?: Nullable<Scene>): Mesh;
  65106. /**
  65107. * Creates a tiled plane mesh
  65108. * * You can set a limited pattern arrangement with the tiles
  65109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65112. * @param name defines the name of the mesh
  65113. * @param options defines the options used to create the mesh
  65114. * @param scene defines the hosting scene
  65115. * @returns the plane mesh
  65116. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65117. */
  65118. static CreateTiledPlane(name: string, options: {
  65119. pattern?: number;
  65120. tileSize?: number;
  65121. tileWidth?: number;
  65122. tileHeight?: number;
  65123. size?: number;
  65124. width?: number;
  65125. height?: number;
  65126. alignHorizontal?: number;
  65127. alignVertical?: number;
  65128. sideOrientation?: number;
  65129. frontUVs?: Vector4;
  65130. backUVs?: Vector4;
  65131. updatable?: boolean;
  65132. }, scene?: Nullable<Scene>): Mesh;
  65133. /**
  65134. * Creates a plane mesh
  65135. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65136. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65137. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65141. * @param name defines the name of the mesh
  65142. * @param options defines the options used to create the mesh
  65143. * @param scene defines the hosting scene
  65144. * @returns the plane mesh
  65145. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65146. */
  65147. static CreatePlane(name: string, options: {
  65148. size?: number;
  65149. width?: number;
  65150. height?: number;
  65151. sideOrientation?: number;
  65152. frontUVs?: Vector4;
  65153. backUVs?: Vector4;
  65154. updatable?: boolean;
  65155. sourcePlane?: Plane;
  65156. }, scene?: Nullable<Scene>): Mesh;
  65157. /**
  65158. * Creates a ground mesh
  65159. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65160. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65162. * @param name defines the name of the mesh
  65163. * @param options defines the options used to create the mesh
  65164. * @param scene defines the hosting scene
  65165. * @returns the ground mesh
  65166. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65167. */
  65168. static CreateGround(name: string, options: {
  65169. width?: number;
  65170. height?: number;
  65171. subdivisions?: number;
  65172. subdivisionsX?: number;
  65173. subdivisionsY?: number;
  65174. updatable?: boolean;
  65175. }, scene?: Nullable<Scene>): Mesh;
  65176. /**
  65177. * Creates a tiled ground mesh
  65178. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65179. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65180. * * 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
  65181. * * 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
  65182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65183. * @param name defines the name of the mesh
  65184. * @param options defines the options used to create the mesh
  65185. * @param scene defines the hosting scene
  65186. * @returns the tiled ground mesh
  65187. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65188. */
  65189. static CreateTiledGround(name: string, options: {
  65190. xmin: number;
  65191. zmin: number;
  65192. xmax: number;
  65193. zmax: number;
  65194. subdivisions?: {
  65195. w: number;
  65196. h: number;
  65197. };
  65198. precision?: {
  65199. w: number;
  65200. h: number;
  65201. };
  65202. updatable?: boolean;
  65203. }, scene?: Nullable<Scene>): Mesh;
  65204. /**
  65205. * Creates a ground mesh from a height map
  65206. * * The parameter `url` sets the URL of the height map image resource.
  65207. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65208. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65209. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65210. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65211. * * 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.
  65212. * * 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).
  65213. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65215. * @param name defines the name of the mesh
  65216. * @param url defines the url to the height map
  65217. * @param options defines the options used to create the mesh
  65218. * @param scene defines the hosting scene
  65219. * @returns the ground mesh
  65220. * @see https://doc.babylonjs.com/babylon101/height_map
  65221. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65222. */
  65223. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65224. width?: number;
  65225. height?: number;
  65226. subdivisions?: number;
  65227. minHeight?: number;
  65228. maxHeight?: number;
  65229. colorFilter?: Color3;
  65230. alphaFilter?: number;
  65231. updatable?: boolean;
  65232. onReady?: (mesh: GroundMesh) => void;
  65233. }, scene?: Nullable<Scene>): GroundMesh;
  65234. /**
  65235. * Creates a polygon mesh
  65236. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65237. * * 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
  65238. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65241. * * Remember you can only change the shape positions, not their number when updating a polygon
  65242. * @param name defines the name of the mesh
  65243. * @param options defines the options used to create the mesh
  65244. * @param scene defines the hosting scene
  65245. * @param earcutInjection can be used to inject your own earcut reference
  65246. * @returns the polygon mesh
  65247. */
  65248. static CreatePolygon(name: string, options: {
  65249. shape: Vector3[];
  65250. holes?: Vector3[][];
  65251. depth?: number;
  65252. faceUV?: Vector4[];
  65253. faceColors?: Color4[];
  65254. updatable?: boolean;
  65255. sideOrientation?: number;
  65256. frontUVs?: Vector4;
  65257. backUVs?: Vector4;
  65258. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65259. /**
  65260. * Creates an extruded polygon mesh, with depth in the Y direction.
  65261. * * 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)
  65262. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65263. * @param name defines the name of the mesh
  65264. * @param options defines the options used to create the mesh
  65265. * @param scene defines the hosting scene
  65266. * @param earcutInjection can be used to inject your own earcut reference
  65267. * @returns the polygon mesh
  65268. */
  65269. static ExtrudePolygon(name: string, options: {
  65270. shape: Vector3[];
  65271. holes?: Vector3[][];
  65272. depth?: number;
  65273. faceUV?: Vector4[];
  65274. faceColors?: Color4[];
  65275. updatable?: boolean;
  65276. sideOrientation?: number;
  65277. frontUVs?: Vector4;
  65278. backUVs?: Vector4;
  65279. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65280. /**
  65281. * Creates a tube mesh.
  65282. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65283. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65284. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65285. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65286. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65287. * * 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)
  65288. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65289. * * 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
  65290. * * 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
  65291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65295. * @param name defines the name of the mesh
  65296. * @param options defines the options used to create the mesh
  65297. * @param scene defines the hosting scene
  65298. * @returns the tube mesh
  65299. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65300. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65301. */
  65302. static CreateTube(name: string, options: {
  65303. path: Vector3[];
  65304. radius?: number;
  65305. tessellation?: number;
  65306. radiusFunction?: {
  65307. (i: number, distance: number): number;
  65308. };
  65309. cap?: number;
  65310. arc?: number;
  65311. updatable?: boolean;
  65312. sideOrientation?: number;
  65313. frontUVs?: Vector4;
  65314. backUVs?: Vector4;
  65315. instance?: Mesh;
  65316. invertUV?: boolean;
  65317. }, scene?: Nullable<Scene>): Mesh;
  65318. /**
  65319. * Creates a polyhedron mesh
  65320. * * 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
  65321. * * The parameter `size` (positive float, default 1) sets the polygon size
  65322. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65323. * * 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`
  65324. * * 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
  65325. * * 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)`)
  65326. * * 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
  65327. * * 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
  65328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65331. * @param name defines the name of the mesh
  65332. * @param options defines the options used to create the mesh
  65333. * @param scene defines the hosting scene
  65334. * @returns the polyhedron mesh
  65335. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65336. */
  65337. static CreatePolyhedron(name: string, options: {
  65338. type?: number;
  65339. size?: number;
  65340. sizeX?: number;
  65341. sizeY?: number;
  65342. sizeZ?: number;
  65343. custom?: any;
  65344. faceUV?: Vector4[];
  65345. faceColors?: Color4[];
  65346. flat?: boolean;
  65347. updatable?: boolean;
  65348. sideOrientation?: number;
  65349. frontUVs?: Vector4;
  65350. backUVs?: Vector4;
  65351. }, scene?: Nullable<Scene>): Mesh;
  65352. /**
  65353. * Creates a decal mesh.
  65354. * 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
  65355. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65356. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65357. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65358. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65359. * @param name defines the name of the mesh
  65360. * @param sourceMesh defines the mesh where the decal must be applied
  65361. * @param options defines the options used to create the mesh
  65362. * @param scene defines the hosting scene
  65363. * @returns the decal mesh
  65364. * @see https://doc.babylonjs.com/how_to/decals
  65365. */
  65366. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65367. position?: Vector3;
  65368. normal?: Vector3;
  65369. size?: Vector3;
  65370. angle?: number;
  65371. }): Mesh;
  65372. }
  65373. }
  65374. declare module "babylonjs/Meshes/meshSimplification" {
  65375. import { Mesh } from "babylonjs/Meshes/mesh";
  65376. /**
  65377. * A simplifier interface for future simplification implementations
  65378. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65379. */
  65380. export interface ISimplifier {
  65381. /**
  65382. * Simplification of a given mesh according to the given settings.
  65383. * Since this requires computation, it is assumed that the function runs async.
  65384. * @param settings The settings of the simplification, including quality and distance
  65385. * @param successCallback A callback that will be called after the mesh was simplified.
  65386. * @param errorCallback in case of an error, this callback will be called. optional.
  65387. */
  65388. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65389. }
  65390. /**
  65391. * Expected simplification settings.
  65392. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65393. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65394. */
  65395. export interface ISimplificationSettings {
  65396. /**
  65397. * Gets or sets the expected quality
  65398. */
  65399. quality: number;
  65400. /**
  65401. * Gets or sets the distance when this optimized version should be used
  65402. */
  65403. distance: number;
  65404. /**
  65405. * Gets an already optimized mesh
  65406. */
  65407. optimizeMesh?: boolean;
  65408. }
  65409. /**
  65410. * Class used to specify simplification options
  65411. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65412. */
  65413. export class SimplificationSettings implements ISimplificationSettings {
  65414. /** expected quality */
  65415. quality: number;
  65416. /** distance when this optimized version should be used */
  65417. distance: number;
  65418. /** already optimized mesh */
  65419. optimizeMesh?: boolean | undefined;
  65420. /**
  65421. * Creates a SimplificationSettings
  65422. * @param quality expected quality
  65423. * @param distance distance when this optimized version should be used
  65424. * @param optimizeMesh already optimized mesh
  65425. */
  65426. constructor(
  65427. /** expected quality */
  65428. quality: number,
  65429. /** distance when this optimized version should be used */
  65430. distance: number,
  65431. /** already optimized mesh */
  65432. optimizeMesh?: boolean | undefined);
  65433. }
  65434. /**
  65435. * Interface used to define a simplification task
  65436. */
  65437. export interface ISimplificationTask {
  65438. /**
  65439. * Array of settings
  65440. */
  65441. settings: Array<ISimplificationSettings>;
  65442. /**
  65443. * Simplification type
  65444. */
  65445. simplificationType: SimplificationType;
  65446. /**
  65447. * Mesh to simplify
  65448. */
  65449. mesh: Mesh;
  65450. /**
  65451. * Callback called on success
  65452. */
  65453. successCallback?: () => void;
  65454. /**
  65455. * Defines if parallel processing can be used
  65456. */
  65457. parallelProcessing: boolean;
  65458. }
  65459. /**
  65460. * Queue used to order the simplification tasks
  65461. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65462. */
  65463. export class SimplificationQueue {
  65464. private _simplificationArray;
  65465. /**
  65466. * Gets a boolean indicating that the process is still running
  65467. */
  65468. running: boolean;
  65469. /**
  65470. * Creates a new queue
  65471. */
  65472. constructor();
  65473. /**
  65474. * Adds a new simplification task
  65475. * @param task defines a task to add
  65476. */
  65477. addTask(task: ISimplificationTask): void;
  65478. /**
  65479. * Execute next task
  65480. */
  65481. executeNext(): void;
  65482. /**
  65483. * Execute a simplification task
  65484. * @param task defines the task to run
  65485. */
  65486. runSimplification(task: ISimplificationTask): void;
  65487. private getSimplifier;
  65488. }
  65489. /**
  65490. * The implemented types of simplification
  65491. * At the moment only Quadratic Error Decimation is implemented
  65492. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65493. */
  65494. export enum SimplificationType {
  65495. /** Quadratic error decimation */
  65496. QUADRATIC = 0
  65497. }
  65498. /**
  65499. * An implementation of the Quadratic Error simplification algorithm.
  65500. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65501. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65502. * @author RaananW
  65503. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65504. */
  65505. export class QuadraticErrorSimplification implements ISimplifier {
  65506. private _mesh;
  65507. private triangles;
  65508. private vertices;
  65509. private references;
  65510. private _reconstructedMesh;
  65511. /** Gets or sets the number pf sync interations */
  65512. syncIterations: number;
  65513. /** Gets or sets the aggressiveness of the simplifier */
  65514. aggressiveness: number;
  65515. /** Gets or sets the number of allowed iterations for decimation */
  65516. decimationIterations: number;
  65517. /** Gets or sets the espilon to use for bounding box computation */
  65518. boundingBoxEpsilon: number;
  65519. /**
  65520. * Creates a new QuadraticErrorSimplification
  65521. * @param _mesh defines the target mesh
  65522. */
  65523. constructor(_mesh: Mesh);
  65524. /**
  65525. * Simplification of a given mesh according to the given settings.
  65526. * Since this requires computation, it is assumed that the function runs async.
  65527. * @param settings The settings of the simplification, including quality and distance
  65528. * @param successCallback A callback that will be called after the mesh was simplified.
  65529. */
  65530. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65531. private runDecimation;
  65532. private initWithMesh;
  65533. private init;
  65534. private reconstructMesh;
  65535. private initDecimatedMesh;
  65536. private isFlipped;
  65537. private updateTriangles;
  65538. private identifyBorder;
  65539. private updateMesh;
  65540. private vertexError;
  65541. private calculateError;
  65542. }
  65543. }
  65544. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65545. import { Scene } from "babylonjs/scene";
  65546. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65547. import { ISceneComponent } from "babylonjs/sceneComponent";
  65548. module "babylonjs/scene" {
  65549. interface Scene {
  65550. /** @hidden (Backing field) */
  65551. _simplificationQueue: SimplificationQueue;
  65552. /**
  65553. * Gets or sets the simplification queue attached to the scene
  65554. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65555. */
  65556. simplificationQueue: SimplificationQueue;
  65557. }
  65558. }
  65559. module "babylonjs/Meshes/mesh" {
  65560. interface Mesh {
  65561. /**
  65562. * Simplify the mesh according to the given array of settings.
  65563. * Function will return immediately and will simplify async
  65564. * @param settings a collection of simplification settings
  65565. * @param parallelProcessing should all levels calculate parallel or one after the other
  65566. * @param simplificationType the type of simplification to run
  65567. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65568. * @returns the current mesh
  65569. */
  65570. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65571. }
  65572. }
  65573. /**
  65574. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65575. * created in a scene
  65576. */
  65577. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65578. /**
  65579. * The component name helpfull to identify the component in the list of scene components.
  65580. */
  65581. readonly name: string;
  65582. /**
  65583. * The scene the component belongs to.
  65584. */
  65585. scene: Scene;
  65586. /**
  65587. * Creates a new instance of the component for the given scene
  65588. * @param scene Defines the scene to register the component in
  65589. */
  65590. constructor(scene: Scene);
  65591. /**
  65592. * Registers the component in a given scene
  65593. */
  65594. register(): void;
  65595. /**
  65596. * Rebuilds the elements related to this component in case of
  65597. * context lost for instance.
  65598. */
  65599. rebuild(): void;
  65600. /**
  65601. * Disposes the component and the associated ressources
  65602. */
  65603. dispose(): void;
  65604. private _beforeCameraUpdate;
  65605. }
  65606. }
  65607. declare module "babylonjs/Meshes/Builders/index" {
  65608. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65609. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65610. export * from "babylonjs/Meshes/Builders/discBuilder";
  65611. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65612. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65613. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65614. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65615. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65616. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65617. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65618. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65619. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65620. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65621. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65622. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65623. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65624. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65625. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65626. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65627. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65628. }
  65629. declare module "babylonjs/Meshes/index" {
  65630. export * from "babylonjs/Meshes/abstractMesh";
  65631. export * from "babylonjs/Meshes/buffer";
  65632. export * from "babylonjs/Meshes/Compression/index";
  65633. export * from "babylonjs/Meshes/csg";
  65634. export * from "babylonjs/Meshes/geometry";
  65635. export * from "babylonjs/Meshes/groundMesh";
  65636. export * from "babylonjs/Meshes/trailMesh";
  65637. export * from "babylonjs/Meshes/instancedMesh";
  65638. export * from "babylonjs/Meshes/linesMesh";
  65639. export * from "babylonjs/Meshes/mesh";
  65640. export * from "babylonjs/Meshes/mesh.vertexData";
  65641. export * from "babylonjs/Meshes/meshBuilder";
  65642. export * from "babylonjs/Meshes/meshSimplification";
  65643. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65644. export * from "babylonjs/Meshes/polygonMesh";
  65645. export * from "babylonjs/Meshes/subMesh";
  65646. export * from "babylonjs/Meshes/meshLODLevel";
  65647. export * from "babylonjs/Meshes/transformNode";
  65648. export * from "babylonjs/Meshes/Builders/index";
  65649. export * from "babylonjs/Meshes/dataBuffer";
  65650. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65651. }
  65652. declare module "babylonjs/Morph/index" {
  65653. export * from "babylonjs/Morph/morphTarget";
  65654. export * from "babylonjs/Morph/morphTargetManager";
  65655. }
  65656. declare module "babylonjs/Navigation/INavigationEngine" {
  65657. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65658. import { Vector3 } from "babylonjs/Maths/math";
  65659. import { Mesh } from "babylonjs/Meshes/mesh";
  65660. import { Scene } from "babylonjs/scene";
  65661. /**
  65662. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65663. */
  65664. export interface INavigationEnginePlugin {
  65665. /**
  65666. * plugin name
  65667. */
  65668. name: string;
  65669. /**
  65670. * Creates a navigation mesh
  65671. * @param meshes array of all the geometry used to compute the navigatio mesh
  65672. * @param parameters bunch of parameters used to filter geometry
  65673. */
  65674. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65675. /**
  65676. * Create a navigation mesh debug mesh
  65677. * @param scene is where the mesh will be added
  65678. * @returns debug display mesh
  65679. */
  65680. createDebugNavMesh(scene: Scene): Mesh;
  65681. /**
  65682. * Get a navigation mesh constrained position, closest to the parameter position
  65683. * @param position world position
  65684. * @returns the closest point to position constrained by the navigation mesh
  65685. */
  65686. getClosestPoint(position: Vector3): Vector3;
  65687. /**
  65688. * Get a navigation mesh constrained position, closest to the parameter position
  65689. * @param position world position
  65690. * @param result output the closest point to position constrained by the navigation mesh
  65691. */
  65692. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65693. /**
  65694. * Get a navigation mesh constrained position, within a particular radius
  65695. * @param position world position
  65696. * @param maxRadius the maximum distance to the constrained world position
  65697. * @returns the closest point to position constrained by the navigation mesh
  65698. */
  65699. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65700. /**
  65701. * Get a navigation mesh constrained position, within a particular radius
  65702. * @param position world position
  65703. * @param maxRadius the maximum distance to the constrained world position
  65704. * @param result output the closest point to position constrained by the navigation mesh
  65705. */
  65706. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65707. /**
  65708. * Compute the final position from a segment made of destination-position
  65709. * @param position world position
  65710. * @param destination world position
  65711. * @returns the resulting point along the navmesh
  65712. */
  65713. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65714. /**
  65715. * Compute the final position from a segment made of destination-position
  65716. * @param position world position
  65717. * @param destination world position
  65718. * @param result output the resulting point along the navmesh
  65719. */
  65720. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65721. /**
  65722. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65723. * @param start world position
  65724. * @param end world position
  65725. * @returns array containing world position composing the path
  65726. */
  65727. computePath(start: Vector3, end: Vector3): Vector3[];
  65728. /**
  65729. * If this plugin is supported
  65730. * @returns true if plugin is supported
  65731. */
  65732. isSupported(): boolean;
  65733. /**
  65734. * Create a new Crowd so you can add agents
  65735. * @param maxAgents the maximum agent count in the crowd
  65736. * @param maxAgentRadius the maximum radius an agent can have
  65737. * @param scene to attach the crowd to
  65738. * @returns the crowd you can add agents to
  65739. */
  65740. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65741. /**
  65742. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65743. * The queries will try to find a solution within those bounds
  65744. * default is (1,1,1)
  65745. * @param extent x,y,z value that define the extent around the queries point of reference
  65746. */
  65747. setDefaultQueryExtent(extent: Vector3): void;
  65748. /**
  65749. * Get the Bounding box extent specified by setDefaultQueryExtent
  65750. * @returns the box extent values
  65751. */
  65752. getDefaultQueryExtent(): Vector3;
  65753. /**
  65754. * build the navmesh from a previously saved state using getNavmeshData
  65755. * @param data the Uint8Array returned by getNavmeshData
  65756. */
  65757. buildFromNavmeshData(data: Uint8Array): void;
  65758. /**
  65759. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65760. * @returns data the Uint8Array that can be saved and reused
  65761. */
  65762. getNavmeshData(): Uint8Array;
  65763. /**
  65764. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65765. * @param result output the box extent values
  65766. */
  65767. getDefaultQueryExtentToRef(result: Vector3): void;
  65768. /**
  65769. * Release all resources
  65770. */
  65771. dispose(): void;
  65772. }
  65773. /**
  65774. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65775. */
  65776. export interface ICrowd {
  65777. /**
  65778. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65779. * You can attach anything to that node. The node position is updated in the scene update tick.
  65780. * @param pos world position that will be constrained by the navigation mesh
  65781. * @param parameters agent parameters
  65782. * @param transform hooked to the agent that will be update by the scene
  65783. * @returns agent index
  65784. */
  65785. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65786. /**
  65787. * Returns the agent position in world space
  65788. * @param index agent index returned by addAgent
  65789. * @returns world space position
  65790. */
  65791. getAgentPosition(index: number): Vector3;
  65792. /**
  65793. * Gets the agent position result in world space
  65794. * @param index agent index returned by addAgent
  65795. * @param result output world space position
  65796. */
  65797. getAgentPositionToRef(index: number, result: Vector3): void;
  65798. /**
  65799. * Gets the agent velocity in world space
  65800. * @param index agent index returned by addAgent
  65801. * @returns world space velocity
  65802. */
  65803. getAgentVelocity(index: number): Vector3;
  65804. /**
  65805. * Gets the agent velocity result in world space
  65806. * @param index agent index returned by addAgent
  65807. * @param result output world space velocity
  65808. */
  65809. getAgentVelocityToRef(index: number, result: Vector3): void;
  65810. /**
  65811. * remove a particular agent previously created
  65812. * @param index agent index returned by addAgent
  65813. */
  65814. removeAgent(index: number): void;
  65815. /**
  65816. * get the list of all agents attached to this crowd
  65817. * @returns list of agent indices
  65818. */
  65819. getAgents(): number[];
  65820. /**
  65821. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65822. * @param deltaTime in seconds
  65823. */
  65824. update(deltaTime: number): void;
  65825. /**
  65826. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65827. * @param index agent index returned by addAgent
  65828. * @param destination targeted world position
  65829. */
  65830. agentGoto(index: number, destination: Vector3): void;
  65831. /**
  65832. * Teleport the agent to a new position
  65833. * @param index agent index returned by addAgent
  65834. * @param destination targeted world position
  65835. */
  65836. agentTeleport(index: number, destination: Vector3): void;
  65837. /**
  65838. * Update agent parameters
  65839. * @param index agent index returned by addAgent
  65840. * @param parameters agent parameters
  65841. */
  65842. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65843. /**
  65844. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65845. * The queries will try to find a solution within those bounds
  65846. * default is (1,1,1)
  65847. * @param extent x,y,z value that define the extent around the queries point of reference
  65848. */
  65849. setDefaultQueryExtent(extent: Vector3): void;
  65850. /**
  65851. * Get the Bounding box extent specified by setDefaultQueryExtent
  65852. * @returns the box extent values
  65853. */
  65854. getDefaultQueryExtent(): Vector3;
  65855. /**
  65856. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65857. * @param result output the box extent values
  65858. */
  65859. getDefaultQueryExtentToRef(result: Vector3): void;
  65860. /**
  65861. * Release all resources
  65862. */
  65863. dispose(): void;
  65864. }
  65865. /**
  65866. * Configures an agent
  65867. */
  65868. export interface IAgentParameters {
  65869. /**
  65870. * Agent radius. [Limit: >= 0]
  65871. */
  65872. radius: number;
  65873. /**
  65874. * Agent height. [Limit: > 0]
  65875. */
  65876. height: number;
  65877. /**
  65878. * Maximum allowed acceleration. [Limit: >= 0]
  65879. */
  65880. maxAcceleration: number;
  65881. /**
  65882. * Maximum allowed speed. [Limit: >= 0]
  65883. */
  65884. maxSpeed: number;
  65885. /**
  65886. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65887. */
  65888. collisionQueryRange: number;
  65889. /**
  65890. * The path visibility optimization range. [Limit: > 0]
  65891. */
  65892. pathOptimizationRange: number;
  65893. /**
  65894. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65895. */
  65896. separationWeight: number;
  65897. }
  65898. /**
  65899. * Configures the navigation mesh creation
  65900. */
  65901. export interface INavMeshParameters {
  65902. /**
  65903. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65904. */
  65905. cs: number;
  65906. /**
  65907. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65908. */
  65909. ch: number;
  65910. /**
  65911. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65912. */
  65913. walkableSlopeAngle: number;
  65914. /**
  65915. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65916. * be considered walkable. [Limit: >= 3] [Units: vx]
  65917. */
  65918. walkableHeight: number;
  65919. /**
  65920. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65921. */
  65922. walkableClimb: number;
  65923. /**
  65924. * The distance to erode/shrink the walkable area of the heightfield away from
  65925. * obstructions. [Limit: >=0] [Units: vx]
  65926. */
  65927. walkableRadius: number;
  65928. /**
  65929. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65930. */
  65931. maxEdgeLen: number;
  65932. /**
  65933. * The maximum distance a simplfied contour's border edges should deviate
  65934. * the original raw contour. [Limit: >=0] [Units: vx]
  65935. */
  65936. maxSimplificationError: number;
  65937. /**
  65938. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65939. */
  65940. minRegionArea: number;
  65941. /**
  65942. * Any regions with a span count smaller than this value will, if possible,
  65943. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65944. */
  65945. mergeRegionArea: number;
  65946. /**
  65947. * The maximum number of vertices allowed for polygons generated during the
  65948. * contour to polygon conversion process. [Limit: >= 3]
  65949. */
  65950. maxVertsPerPoly: number;
  65951. /**
  65952. * Sets the sampling distance to use when generating the detail mesh.
  65953. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65954. */
  65955. detailSampleDist: number;
  65956. /**
  65957. * The maximum distance the detail mesh surface should deviate from heightfield
  65958. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65959. */
  65960. detailSampleMaxError: number;
  65961. }
  65962. }
  65963. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65964. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65965. import { Mesh } from "babylonjs/Meshes/mesh";
  65966. import { Scene } from "babylonjs/scene";
  65967. import { Vector3 } from "babylonjs/Maths/math";
  65968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65969. /**
  65970. * RecastJS navigation plugin
  65971. */
  65972. export class RecastJSPlugin implements INavigationEnginePlugin {
  65973. /**
  65974. * Reference to the Recast library
  65975. */
  65976. bjsRECAST: any;
  65977. /**
  65978. * plugin name
  65979. */
  65980. name: string;
  65981. /**
  65982. * the first navmesh created. We might extend this to support multiple navmeshes
  65983. */
  65984. navMesh: any;
  65985. /**
  65986. * Initializes the recastJS plugin
  65987. * @param recastInjection can be used to inject your own recast reference
  65988. */
  65989. constructor(recastInjection?: any);
  65990. /**
  65991. * Creates a navigation mesh
  65992. * @param meshes array of all the geometry used to compute the navigatio mesh
  65993. * @param parameters bunch of parameters used to filter geometry
  65994. */
  65995. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65996. /**
  65997. * Create a navigation mesh debug mesh
  65998. * @param scene is where the mesh will be added
  65999. * @returns debug display mesh
  66000. */
  66001. createDebugNavMesh(scene: Scene): Mesh;
  66002. /**
  66003. * Get a navigation mesh constrained position, closest to the parameter position
  66004. * @param position world position
  66005. * @returns the closest point to position constrained by the navigation mesh
  66006. */
  66007. getClosestPoint(position: Vector3): Vector3;
  66008. /**
  66009. * Get a navigation mesh constrained position, closest to the parameter position
  66010. * @param position world position
  66011. * @param result output the closest point to position constrained by the navigation mesh
  66012. */
  66013. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66014. /**
  66015. * Get a navigation mesh constrained position, within a particular radius
  66016. * @param position world position
  66017. * @param maxRadius the maximum distance to the constrained world position
  66018. * @returns the closest point to position constrained by the navigation mesh
  66019. */
  66020. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66021. /**
  66022. * Get a navigation mesh constrained position, within a particular radius
  66023. * @param position world position
  66024. * @param maxRadius the maximum distance to the constrained world position
  66025. * @param result output the closest point to position constrained by the navigation mesh
  66026. */
  66027. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66028. /**
  66029. * Compute the final position from a segment made of destination-position
  66030. * @param position world position
  66031. * @param destination world position
  66032. * @returns the resulting point along the navmesh
  66033. */
  66034. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66035. /**
  66036. * Compute the final position from a segment made of destination-position
  66037. * @param position world position
  66038. * @param destination world position
  66039. * @param result output the resulting point along the navmesh
  66040. */
  66041. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66042. /**
  66043. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66044. * @param start world position
  66045. * @param end world position
  66046. * @returns array containing world position composing the path
  66047. */
  66048. computePath(start: Vector3, end: Vector3): Vector3[];
  66049. /**
  66050. * Create a new Crowd so you can add agents
  66051. * @param maxAgents the maximum agent count in the crowd
  66052. * @param maxAgentRadius the maximum radius an agent can have
  66053. * @param scene to attach the crowd to
  66054. * @returns the crowd you can add agents to
  66055. */
  66056. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66057. /**
  66058. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66059. * The queries will try to find a solution within those bounds
  66060. * default is (1,1,1)
  66061. * @param extent x,y,z value that define the extent around the queries point of reference
  66062. */
  66063. setDefaultQueryExtent(extent: Vector3): void;
  66064. /**
  66065. * Get the Bounding box extent specified by setDefaultQueryExtent
  66066. * @returns the box extent values
  66067. */
  66068. getDefaultQueryExtent(): Vector3;
  66069. /**
  66070. * build the navmesh from a previously saved state using getNavmeshData
  66071. * @param data the Uint8Array returned by getNavmeshData
  66072. */
  66073. buildFromNavmeshData(data: Uint8Array): void;
  66074. /**
  66075. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66076. * @returns data the Uint8Array that can be saved and reused
  66077. */
  66078. getNavmeshData(): Uint8Array;
  66079. /**
  66080. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66081. * @param result output the box extent values
  66082. */
  66083. getDefaultQueryExtentToRef(result: Vector3): void;
  66084. /**
  66085. * Disposes
  66086. */
  66087. dispose(): void;
  66088. /**
  66089. * If this plugin is supported
  66090. * @returns true if plugin is supported
  66091. */
  66092. isSupported(): boolean;
  66093. }
  66094. /**
  66095. * Recast detour crowd implementation
  66096. */
  66097. export class RecastJSCrowd implements ICrowd {
  66098. /**
  66099. * Recast/detour plugin
  66100. */
  66101. bjsRECASTPlugin: RecastJSPlugin;
  66102. /**
  66103. * Link to the detour crowd
  66104. */
  66105. recastCrowd: any;
  66106. /**
  66107. * One transform per agent
  66108. */
  66109. transforms: TransformNode[];
  66110. /**
  66111. * All agents created
  66112. */
  66113. agents: number[];
  66114. /**
  66115. * Link to the scene is kept to unregister the crowd from the scene
  66116. */
  66117. private _scene;
  66118. /**
  66119. * Observer for crowd updates
  66120. */
  66121. private _onBeforeAnimationsObserver;
  66122. /**
  66123. * Constructor
  66124. * @param plugin recastJS plugin
  66125. * @param maxAgents the maximum agent count in the crowd
  66126. * @param maxAgentRadius the maximum radius an agent can have
  66127. * @param scene to attach the crowd to
  66128. * @returns the crowd you can add agents to
  66129. */
  66130. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66131. /**
  66132. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66133. * You can attach anything to that node. The node position is updated in the scene update tick.
  66134. * @param pos world position that will be constrained by the navigation mesh
  66135. * @param parameters agent parameters
  66136. * @param transform hooked to the agent that will be update by the scene
  66137. * @returns agent index
  66138. */
  66139. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66140. /**
  66141. * Returns the agent position in world space
  66142. * @param index agent index returned by addAgent
  66143. * @returns world space position
  66144. */
  66145. getAgentPosition(index: number): Vector3;
  66146. /**
  66147. * Returns the agent position result in world space
  66148. * @param index agent index returned by addAgent
  66149. * @param result output world space position
  66150. */
  66151. getAgentPositionToRef(index: number, result: Vector3): void;
  66152. /**
  66153. * Returns the agent velocity in world space
  66154. * @param index agent index returned by addAgent
  66155. * @returns world space velocity
  66156. */
  66157. getAgentVelocity(index: number): Vector3;
  66158. /**
  66159. * Returns the agent velocity result in world space
  66160. * @param index agent index returned by addAgent
  66161. * @param result output world space velocity
  66162. */
  66163. getAgentVelocityToRef(index: number, result: Vector3): void;
  66164. /**
  66165. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66166. * @param index agent index returned by addAgent
  66167. * @param destination targeted world position
  66168. */
  66169. agentGoto(index: number, destination: Vector3): void;
  66170. /**
  66171. * Teleport the agent to a new position
  66172. * @param index agent index returned by addAgent
  66173. * @param destination targeted world position
  66174. */
  66175. agentTeleport(index: number, destination: Vector3): void;
  66176. /**
  66177. * Update agent parameters
  66178. * @param index agent index returned by addAgent
  66179. * @param parameters agent parameters
  66180. */
  66181. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66182. /**
  66183. * remove a particular agent previously created
  66184. * @param index agent index returned by addAgent
  66185. */
  66186. removeAgent(index: number): void;
  66187. /**
  66188. * get the list of all agents attached to this crowd
  66189. * @returns list of agent indices
  66190. */
  66191. getAgents(): number[];
  66192. /**
  66193. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66194. * @param deltaTime in seconds
  66195. */
  66196. update(deltaTime: number): void;
  66197. /**
  66198. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66199. * The queries will try to find a solution within those bounds
  66200. * default is (1,1,1)
  66201. * @param extent x,y,z value that define the extent around the queries point of reference
  66202. */
  66203. setDefaultQueryExtent(extent: Vector3): void;
  66204. /**
  66205. * Get the Bounding box extent specified by setDefaultQueryExtent
  66206. * @returns the box extent values
  66207. */
  66208. getDefaultQueryExtent(): Vector3;
  66209. /**
  66210. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66211. * @param result output the box extent values
  66212. */
  66213. getDefaultQueryExtentToRef(result: Vector3): void;
  66214. /**
  66215. * Release all resources
  66216. */
  66217. dispose(): void;
  66218. }
  66219. }
  66220. declare module "babylonjs/Navigation/Plugins/index" {
  66221. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66222. }
  66223. declare module "babylonjs/Navigation/index" {
  66224. export * from "babylonjs/Navigation/INavigationEngine";
  66225. export * from "babylonjs/Navigation/Plugins/index";
  66226. }
  66227. declare module "babylonjs/Offline/database" {
  66228. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66229. /**
  66230. * Class used to enable access to IndexedDB
  66231. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66232. */
  66233. export class Database implements IOfflineProvider {
  66234. private _callbackManifestChecked;
  66235. private _currentSceneUrl;
  66236. private _db;
  66237. private _enableSceneOffline;
  66238. private _enableTexturesOffline;
  66239. private _manifestVersionFound;
  66240. private _mustUpdateRessources;
  66241. private _hasReachedQuota;
  66242. private _isSupported;
  66243. private _idbFactory;
  66244. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66245. private static IsUASupportingBlobStorage;
  66246. /**
  66247. * Gets a boolean indicating if Database storate is enabled (off by default)
  66248. */
  66249. static IDBStorageEnabled: boolean;
  66250. /**
  66251. * Gets a boolean indicating if scene must be saved in the database
  66252. */
  66253. get enableSceneOffline(): boolean;
  66254. /**
  66255. * Gets a boolean indicating if textures must be saved in the database
  66256. */
  66257. get enableTexturesOffline(): boolean;
  66258. /**
  66259. * Creates a new Database
  66260. * @param urlToScene defines the url to load the scene
  66261. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66262. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66263. */
  66264. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66265. private static _ParseURL;
  66266. private static _ReturnFullUrlLocation;
  66267. private _checkManifestFile;
  66268. /**
  66269. * Open the database and make it available
  66270. * @param successCallback defines the callback to call on success
  66271. * @param errorCallback defines the callback to call on error
  66272. */
  66273. open(successCallback: () => void, errorCallback: () => void): void;
  66274. /**
  66275. * Loads an image from the database
  66276. * @param url defines the url to load from
  66277. * @param image defines the target DOM image
  66278. */
  66279. loadImage(url: string, image: HTMLImageElement): void;
  66280. private _loadImageFromDBAsync;
  66281. private _saveImageIntoDBAsync;
  66282. private _checkVersionFromDB;
  66283. private _loadVersionFromDBAsync;
  66284. private _saveVersionIntoDBAsync;
  66285. /**
  66286. * Loads a file from database
  66287. * @param url defines the URL to load from
  66288. * @param sceneLoaded defines a callback to call on success
  66289. * @param progressCallBack defines a callback to call when progress changed
  66290. * @param errorCallback defines a callback to call on error
  66291. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66292. */
  66293. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66294. private _loadFileAsync;
  66295. private _saveFileAsync;
  66296. /**
  66297. * Validates if xhr data is correct
  66298. * @param xhr defines the request to validate
  66299. * @param dataType defines the expected data type
  66300. * @returns true if data is correct
  66301. */
  66302. private static _ValidateXHRData;
  66303. }
  66304. }
  66305. declare module "babylonjs/Offline/index" {
  66306. export * from "babylonjs/Offline/database";
  66307. export * from "babylonjs/Offline/IOfflineProvider";
  66308. }
  66309. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66310. /** @hidden */
  66311. export var gpuUpdateParticlesPixelShader: {
  66312. name: string;
  66313. shader: string;
  66314. };
  66315. }
  66316. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66317. /** @hidden */
  66318. export var gpuUpdateParticlesVertexShader: {
  66319. name: string;
  66320. shader: string;
  66321. };
  66322. }
  66323. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66324. /** @hidden */
  66325. export var clipPlaneFragmentDeclaration2: {
  66326. name: string;
  66327. shader: string;
  66328. };
  66329. }
  66330. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66331. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66332. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66334. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66335. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66336. /** @hidden */
  66337. export var gpuRenderParticlesPixelShader: {
  66338. name: string;
  66339. shader: string;
  66340. };
  66341. }
  66342. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66343. /** @hidden */
  66344. export var clipPlaneVertexDeclaration2: {
  66345. name: string;
  66346. shader: string;
  66347. };
  66348. }
  66349. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66350. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66351. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66352. /** @hidden */
  66353. export var gpuRenderParticlesVertexShader: {
  66354. name: string;
  66355. shader: string;
  66356. };
  66357. }
  66358. declare module "babylonjs/Particles/gpuParticleSystem" {
  66359. import { Nullable } from "babylonjs/types";
  66360. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66361. import { Observable } from "babylonjs/Misc/observable";
  66362. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66363. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66364. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66365. import { Scene, IDisposable } from "babylonjs/scene";
  66366. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66368. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66369. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66370. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66371. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66372. /**
  66373. * This represents a GPU particle system in Babylon
  66374. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66375. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66376. */
  66377. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66378. /**
  66379. * The layer mask we are rendering the particles through.
  66380. */
  66381. layerMask: number;
  66382. private _capacity;
  66383. private _activeCount;
  66384. private _currentActiveCount;
  66385. private _accumulatedCount;
  66386. private _renderEffect;
  66387. private _updateEffect;
  66388. private _buffer0;
  66389. private _buffer1;
  66390. private _spriteBuffer;
  66391. private _updateVAO;
  66392. private _renderVAO;
  66393. private _targetIndex;
  66394. private _sourceBuffer;
  66395. private _targetBuffer;
  66396. private _engine;
  66397. private _currentRenderId;
  66398. private _started;
  66399. private _stopped;
  66400. private _timeDelta;
  66401. private _randomTexture;
  66402. private _randomTexture2;
  66403. private _attributesStrideSize;
  66404. private _updateEffectOptions;
  66405. private _randomTextureSize;
  66406. private _actualFrame;
  66407. private readonly _rawTextureWidth;
  66408. /**
  66409. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66410. */
  66411. static get IsSupported(): boolean;
  66412. /**
  66413. * An event triggered when the system is disposed.
  66414. */
  66415. onDisposeObservable: Observable<GPUParticleSystem>;
  66416. /**
  66417. * Gets the maximum number of particles active at the same time.
  66418. * @returns The max number of active particles.
  66419. */
  66420. getCapacity(): number;
  66421. /**
  66422. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66423. * to override the particles.
  66424. */
  66425. forceDepthWrite: boolean;
  66426. /**
  66427. * Gets or set the number of active particles
  66428. */
  66429. get activeParticleCount(): number;
  66430. set activeParticleCount(value: number);
  66431. private _preWarmDone;
  66432. /**
  66433. * Specifies if the particles are updated in emitter local space or world space.
  66434. * This is always false for GPU particles
  66435. */
  66436. get isLocal(): boolean;
  66437. set isLocal(value: boolean);
  66438. /**
  66439. * Is this system ready to be used/rendered
  66440. * @return true if the system is ready
  66441. */
  66442. isReady(): boolean;
  66443. /**
  66444. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66445. * @returns True if it has been started, otherwise false.
  66446. */
  66447. isStarted(): boolean;
  66448. /**
  66449. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66450. * @returns True if it has been stopped, otherwise false.
  66451. */
  66452. isStopped(): boolean;
  66453. /**
  66454. * Gets a boolean indicating that the system is stopping
  66455. * @returns true if the system is currently stopping
  66456. */
  66457. isStopping(): boolean;
  66458. /**
  66459. * Gets the number of particles active at the same time.
  66460. * @returns The number of active particles.
  66461. */
  66462. getActiveCount(): number;
  66463. /**
  66464. * Starts the particle system and begins to emit
  66465. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66466. */
  66467. start(delay?: number): void;
  66468. /**
  66469. * Stops the particle system.
  66470. */
  66471. stop(): void;
  66472. /**
  66473. * Remove all active particles
  66474. */
  66475. reset(): void;
  66476. /**
  66477. * Returns the string "GPUParticleSystem"
  66478. * @returns a string containing the class name
  66479. */
  66480. getClassName(): string;
  66481. private _colorGradientsTexture;
  66482. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66483. /**
  66484. * Adds a new color gradient
  66485. * @param gradient defines the gradient to use (between 0 and 1)
  66486. * @param color1 defines the color to affect to the specified gradient
  66487. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66488. * @returns the current particle system
  66489. */
  66490. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66491. private _refreshColorGradient;
  66492. /** Force the system to rebuild all gradients that need to be resync */
  66493. forceRefreshGradients(): void;
  66494. /**
  66495. * Remove a specific color gradient
  66496. * @param gradient defines the gradient to remove
  66497. * @returns the current particle system
  66498. */
  66499. removeColorGradient(gradient: number): GPUParticleSystem;
  66500. private _angularSpeedGradientsTexture;
  66501. private _sizeGradientsTexture;
  66502. private _velocityGradientsTexture;
  66503. private _limitVelocityGradientsTexture;
  66504. private _dragGradientsTexture;
  66505. private _addFactorGradient;
  66506. /**
  66507. * Adds a new size gradient
  66508. * @param gradient defines the gradient to use (between 0 and 1)
  66509. * @param factor defines the size factor to affect to the specified gradient
  66510. * @returns the current particle system
  66511. */
  66512. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66513. /**
  66514. * Remove a specific size gradient
  66515. * @param gradient defines the gradient to remove
  66516. * @returns the current particle system
  66517. */
  66518. removeSizeGradient(gradient: number): GPUParticleSystem;
  66519. private _refreshFactorGradient;
  66520. /**
  66521. * Adds a new angular speed gradient
  66522. * @param gradient defines the gradient to use (between 0 and 1)
  66523. * @param factor defines the angular speed to affect to the specified gradient
  66524. * @returns the current particle system
  66525. */
  66526. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66527. /**
  66528. * Remove a specific angular speed gradient
  66529. * @param gradient defines the gradient to remove
  66530. * @returns the current particle system
  66531. */
  66532. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66533. /**
  66534. * Adds a new velocity gradient
  66535. * @param gradient defines the gradient to use (between 0 and 1)
  66536. * @param factor defines the velocity to affect to the specified gradient
  66537. * @returns the current particle system
  66538. */
  66539. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66540. /**
  66541. * Remove a specific velocity gradient
  66542. * @param gradient defines the gradient to remove
  66543. * @returns the current particle system
  66544. */
  66545. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66546. /**
  66547. * Adds a new limit velocity gradient
  66548. * @param gradient defines the gradient to use (between 0 and 1)
  66549. * @param factor defines the limit velocity value to affect to the specified gradient
  66550. * @returns the current particle system
  66551. */
  66552. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66553. /**
  66554. * Remove a specific limit velocity gradient
  66555. * @param gradient defines the gradient to remove
  66556. * @returns the current particle system
  66557. */
  66558. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66559. /**
  66560. * Adds a new drag gradient
  66561. * @param gradient defines the gradient to use (between 0 and 1)
  66562. * @param factor defines the drag value to affect to the specified gradient
  66563. * @returns the current particle system
  66564. */
  66565. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66566. /**
  66567. * Remove a specific drag gradient
  66568. * @param gradient defines the gradient to remove
  66569. * @returns the current particle system
  66570. */
  66571. removeDragGradient(gradient: number): GPUParticleSystem;
  66572. /**
  66573. * Not supported by GPUParticleSystem
  66574. * @param gradient defines the gradient to use (between 0 and 1)
  66575. * @param factor defines the emit rate value to affect to the specified gradient
  66576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66577. * @returns the current particle system
  66578. */
  66579. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66580. /**
  66581. * Not supported by GPUParticleSystem
  66582. * @param gradient defines the gradient to remove
  66583. * @returns the current particle system
  66584. */
  66585. removeEmitRateGradient(gradient: number): IParticleSystem;
  66586. /**
  66587. * Not supported by GPUParticleSystem
  66588. * @param gradient defines the gradient to use (between 0 and 1)
  66589. * @param factor defines the start size value to affect to the specified gradient
  66590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66591. * @returns the current particle system
  66592. */
  66593. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66594. /**
  66595. * Not supported by GPUParticleSystem
  66596. * @param gradient defines the gradient to remove
  66597. * @returns the current particle system
  66598. */
  66599. removeStartSizeGradient(gradient: number): IParticleSystem;
  66600. /**
  66601. * Not supported by GPUParticleSystem
  66602. * @param gradient defines the gradient to use (between 0 and 1)
  66603. * @param min defines the color remap minimal range
  66604. * @param max defines the color remap maximal range
  66605. * @returns the current particle system
  66606. */
  66607. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66608. /**
  66609. * Not supported by GPUParticleSystem
  66610. * @param gradient defines the gradient to remove
  66611. * @returns the current particle system
  66612. */
  66613. removeColorRemapGradient(): IParticleSystem;
  66614. /**
  66615. * Not supported by GPUParticleSystem
  66616. * @param gradient defines the gradient to use (between 0 and 1)
  66617. * @param min defines the alpha remap minimal range
  66618. * @param max defines the alpha remap maximal range
  66619. * @returns the current particle system
  66620. */
  66621. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66622. /**
  66623. * Not supported by GPUParticleSystem
  66624. * @param gradient defines the gradient to remove
  66625. * @returns the current particle system
  66626. */
  66627. removeAlphaRemapGradient(): IParticleSystem;
  66628. /**
  66629. * Not supported by GPUParticleSystem
  66630. * @param gradient defines the gradient to use (between 0 and 1)
  66631. * @param color defines the color to affect to the specified gradient
  66632. * @returns the current particle system
  66633. */
  66634. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66635. /**
  66636. * Not supported by GPUParticleSystem
  66637. * @param gradient defines the gradient to remove
  66638. * @returns the current particle system
  66639. */
  66640. removeRampGradient(): IParticleSystem;
  66641. /**
  66642. * Not supported by GPUParticleSystem
  66643. * @returns the list of ramp gradients
  66644. */
  66645. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66646. /**
  66647. * Not supported by GPUParticleSystem
  66648. * Gets or sets a boolean indicating that ramp gradients must be used
  66649. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66650. */
  66651. get useRampGradients(): boolean;
  66652. set useRampGradients(value: boolean);
  66653. /**
  66654. * Not supported by GPUParticleSystem
  66655. * @param gradient defines the gradient to use (between 0 and 1)
  66656. * @param factor defines the life time factor to affect to the specified gradient
  66657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66658. * @returns the current particle system
  66659. */
  66660. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66661. /**
  66662. * Not supported by GPUParticleSystem
  66663. * @param gradient defines the gradient to remove
  66664. * @returns the current particle system
  66665. */
  66666. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66667. /**
  66668. * Instantiates a GPU particle system.
  66669. * 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.
  66670. * @param name The name of the particle system
  66671. * @param options The options used to create the system
  66672. * @param scene The scene the particle system belongs to
  66673. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66674. */
  66675. constructor(name: string, options: Partial<{
  66676. capacity: number;
  66677. randomTextureSize: number;
  66678. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66679. protected _reset(): void;
  66680. private _createUpdateVAO;
  66681. private _createRenderVAO;
  66682. private _initialize;
  66683. /** @hidden */
  66684. _recreateUpdateEffect(): void;
  66685. /** @hidden */
  66686. _recreateRenderEffect(): void;
  66687. /**
  66688. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66689. * @param preWarm defines if we are in the pre-warmimg phase
  66690. */
  66691. animate(preWarm?: boolean): void;
  66692. private _createFactorGradientTexture;
  66693. private _createSizeGradientTexture;
  66694. private _createAngularSpeedGradientTexture;
  66695. private _createVelocityGradientTexture;
  66696. private _createLimitVelocityGradientTexture;
  66697. private _createDragGradientTexture;
  66698. private _createColorGradientTexture;
  66699. /**
  66700. * Renders the particle system in its current state
  66701. * @param preWarm defines if the system should only update the particles but not render them
  66702. * @returns the current number of particles
  66703. */
  66704. render(preWarm?: boolean): number;
  66705. /**
  66706. * Rebuilds the particle system
  66707. */
  66708. rebuild(): void;
  66709. private _releaseBuffers;
  66710. private _releaseVAOs;
  66711. /**
  66712. * Disposes the particle system and free the associated resources
  66713. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66714. */
  66715. dispose(disposeTexture?: boolean): void;
  66716. /**
  66717. * Clones the particle system.
  66718. * @param name The name of the cloned object
  66719. * @param newEmitter The new emitter to use
  66720. * @returns the cloned particle system
  66721. */
  66722. clone(name: string, newEmitter: any): GPUParticleSystem;
  66723. /**
  66724. * Serializes the particle system to a JSON object
  66725. * @param serializeTexture defines if the texture must be serialized as well
  66726. * @returns the JSON object
  66727. */
  66728. serialize(serializeTexture?: boolean): any;
  66729. /**
  66730. * Parses a JSON object to create a GPU particle system.
  66731. * @param parsedParticleSystem The JSON object to parse
  66732. * @param scene The scene to create the particle system in
  66733. * @param rootUrl The root url to use to load external dependencies like texture
  66734. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66735. * @returns the parsed GPU particle system
  66736. */
  66737. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66738. }
  66739. }
  66740. declare module "babylonjs/Particles/particleSystemSet" {
  66741. import { Nullable } from "babylonjs/types";
  66742. import { Color3 } from "babylonjs/Maths/math.color";
  66743. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66745. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66746. import { Scene, IDisposable } from "babylonjs/scene";
  66747. /**
  66748. * Represents a set of particle systems working together to create a specific effect
  66749. */
  66750. export class ParticleSystemSet implements IDisposable {
  66751. /**
  66752. * Gets or sets base Assets URL
  66753. */
  66754. static BaseAssetsUrl: string;
  66755. private _emitterCreationOptions;
  66756. private _emitterNode;
  66757. /**
  66758. * Gets the particle system list
  66759. */
  66760. systems: IParticleSystem[];
  66761. /**
  66762. * Gets the emitter node used with this set
  66763. */
  66764. get emitterNode(): Nullable<TransformNode>;
  66765. /**
  66766. * Creates a new emitter mesh as a sphere
  66767. * @param options defines the options used to create the sphere
  66768. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66769. * @param scene defines the hosting scene
  66770. */
  66771. setEmitterAsSphere(options: {
  66772. diameter: number;
  66773. segments: number;
  66774. color: Color3;
  66775. }, renderingGroupId: number, scene: Scene): void;
  66776. /**
  66777. * Starts all particle systems of the set
  66778. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66779. */
  66780. start(emitter?: AbstractMesh): void;
  66781. /**
  66782. * Release all associated resources
  66783. */
  66784. dispose(): void;
  66785. /**
  66786. * Serialize the set into a JSON compatible object
  66787. * @param serializeTexture defines if the texture must be serialized as well
  66788. * @returns a JSON compatible representation of the set
  66789. */
  66790. serialize(serializeTexture?: boolean): any;
  66791. /**
  66792. * Parse a new ParticleSystemSet from a serialized source
  66793. * @param data defines a JSON compatible representation of the set
  66794. * @param scene defines the hosting scene
  66795. * @param gpu defines if we want GPU particles or CPU particles
  66796. * @returns a new ParticleSystemSet
  66797. */
  66798. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66799. }
  66800. }
  66801. declare module "babylonjs/Particles/particleHelper" {
  66802. import { Nullable } from "babylonjs/types";
  66803. import { Scene } from "babylonjs/scene";
  66804. import { Vector3 } from "babylonjs/Maths/math.vector";
  66805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66806. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66807. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66808. /**
  66809. * This class is made for on one-liner static method to help creating particle system set.
  66810. */
  66811. export class ParticleHelper {
  66812. /**
  66813. * Gets or sets base Assets URL
  66814. */
  66815. static BaseAssetsUrl: string;
  66816. /** Define the Url to load snippets */
  66817. static SnippetUrl: string;
  66818. /**
  66819. * Create a default particle system that you can tweak
  66820. * @param emitter defines the emitter to use
  66821. * @param capacity defines the system capacity (default is 500 particles)
  66822. * @param scene defines the hosting scene
  66823. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66824. * @returns the new Particle system
  66825. */
  66826. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66827. /**
  66828. * This is the main static method (one-liner) of this helper to create different particle systems
  66829. * @param type This string represents the type to the particle system to create
  66830. * @param scene The scene where the particle system should live
  66831. * @param gpu If the system will use gpu
  66832. * @returns the ParticleSystemSet created
  66833. */
  66834. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66835. /**
  66836. * Static function used to export a particle system to a ParticleSystemSet variable.
  66837. * Please note that the emitter shape is not exported
  66838. * @param systems defines the particle systems to export
  66839. * @returns the created particle system set
  66840. */
  66841. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66842. /**
  66843. * Creates a particle system from a snippet saved in a remote file
  66844. * @param name defines the name of the particle system to create
  66845. * @param url defines the url to load from
  66846. * @param scene defines the hosting scene
  66847. * @param gpu If the system will use gpu
  66848. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66849. * @returns a promise that will resolve to the new particle system
  66850. */
  66851. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66852. /**
  66853. * Creates a particle system from a snippet saved by the particle system editor
  66854. * @param snippetId defines the snippet to load
  66855. * @param scene defines the hosting scene
  66856. * @param gpu If the system will use gpu
  66857. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66858. * @returns a promise that will resolve to the new particle system
  66859. */
  66860. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66861. }
  66862. }
  66863. declare module "babylonjs/Particles/particleSystemComponent" {
  66864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66865. import { Effect } from "babylonjs/Materials/effect";
  66866. import "babylonjs/Shaders/particles.vertex";
  66867. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66868. module "babylonjs/Engines/engine" {
  66869. interface Engine {
  66870. /**
  66871. * Create an effect to use with particle systems.
  66872. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66873. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66874. * @param uniformsNames defines a list of attribute names
  66875. * @param samplers defines an array of string used to represent textures
  66876. * @param defines defines the string containing the defines to use to compile the shaders
  66877. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66878. * @param onCompiled defines a function to call when the effect creation is successful
  66879. * @param onError defines a function to call when the effect creation has failed
  66880. * @returns the new Effect
  66881. */
  66882. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66883. }
  66884. }
  66885. module "babylonjs/Meshes/mesh" {
  66886. interface Mesh {
  66887. /**
  66888. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66889. * @returns an array of IParticleSystem
  66890. */
  66891. getEmittedParticleSystems(): IParticleSystem[];
  66892. /**
  66893. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66894. * @returns an array of IParticleSystem
  66895. */
  66896. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66897. }
  66898. }
  66899. /**
  66900. * @hidden
  66901. */
  66902. export var _IDoNeedToBeInTheBuild: number;
  66903. }
  66904. declare module "babylonjs/Particles/pointsCloudSystem" {
  66905. import { Color4 } from "babylonjs/Maths/math";
  66906. import { Mesh } from "babylonjs/Meshes/mesh";
  66907. import { Scene, IDisposable } from "babylonjs/scene";
  66908. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66909. /** Defines the 4 color options */
  66910. export enum PointColor {
  66911. /** color value */
  66912. Color = 2,
  66913. /** uv value */
  66914. UV = 1,
  66915. /** random value */
  66916. Random = 0,
  66917. /** stated value */
  66918. Stated = 3
  66919. }
  66920. /**
  66921. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66922. * 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.
  66923. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66924. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66925. *
  66926. * Full documentation here : TO BE ENTERED
  66927. */
  66928. export class PointsCloudSystem implements IDisposable {
  66929. /**
  66930. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66931. * Example : var p = SPS.particles[i];
  66932. */
  66933. particles: CloudPoint[];
  66934. /**
  66935. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66936. */
  66937. nbParticles: number;
  66938. /**
  66939. * This a counter for your own usage. It's not set by any SPS functions.
  66940. */
  66941. counter: number;
  66942. /**
  66943. * The PCS name. This name is also given to the underlying mesh.
  66944. */
  66945. name: string;
  66946. /**
  66947. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66948. */
  66949. mesh: Mesh;
  66950. /**
  66951. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66952. * Please read :
  66953. */
  66954. vars: any;
  66955. /**
  66956. * @hidden
  66957. */
  66958. _size: number;
  66959. private _scene;
  66960. private _promises;
  66961. private _positions;
  66962. private _indices;
  66963. private _normals;
  66964. private _colors;
  66965. private _uvs;
  66966. private _indices32;
  66967. private _positions32;
  66968. private _colors32;
  66969. private _uvs32;
  66970. private _updatable;
  66971. private _isVisibilityBoxLocked;
  66972. private _alwaysVisible;
  66973. private _groups;
  66974. private _groupCounter;
  66975. private _computeParticleColor;
  66976. private _computeParticleTexture;
  66977. private _computeParticleRotation;
  66978. private _computeBoundingBox;
  66979. private _isReady;
  66980. /**
  66981. * Creates a PCS (Points Cloud System) object
  66982. * @param name (String) is the PCS name, this will be the underlying mesh name
  66983. * @param pointSize (number) is the size for each point
  66984. * @param scene (Scene) is the scene in which the PCS is added
  66985. * @param options defines the options of the PCS e.g.
  66986. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66987. */
  66988. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66989. updatable?: boolean;
  66990. });
  66991. /**
  66992. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66993. * If no points were added to the PCS, the returned mesh is just a single point.
  66994. * @returns a promise for the created mesh
  66995. */
  66996. buildMeshAsync(): Promise<Mesh>;
  66997. /**
  66998. * @hidden
  66999. */
  67000. private _buildMesh;
  67001. private _addParticle;
  67002. private _randomUnitVector;
  67003. private _getColorIndicesForCoord;
  67004. private _setPointsColorOrUV;
  67005. private _colorFromTexture;
  67006. private _calculateDensity;
  67007. /**
  67008. * Adds points to the PCS in random positions within a unit sphere
  67009. * @param nb (positive integer) the number of particles to be created from this model
  67010. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67011. * @returns the number of groups in the system
  67012. */
  67013. addPoints(nb: number, pointFunction?: any): number;
  67014. /**
  67015. * Adds points to the PCS from the surface of the model shape
  67016. * @param mesh is any Mesh object that will be used as a surface model for the points
  67017. * @param nb (positive integer) the number of particles to be created from this model
  67018. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67019. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67020. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67021. * @returns the number of groups in the system
  67022. */
  67023. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67024. /**
  67025. * Adds points to the PCS inside the model shape
  67026. * @param mesh is any Mesh object that will be used as a surface model for the points
  67027. * @param nb (positive integer) the number of particles to be created from this model
  67028. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67029. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67030. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67031. * @returns the number of groups in the system
  67032. */
  67033. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67034. /**
  67035. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67036. * This method calls `updateParticle()` for each particle of the SPS.
  67037. * For an animated SPS, it is usually called within the render loop.
  67038. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67039. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67040. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67041. * @returns the PCS.
  67042. */
  67043. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67044. /**
  67045. * Disposes the PCS.
  67046. */
  67047. dispose(): void;
  67048. /**
  67049. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67050. * doc :
  67051. * @returns the PCS.
  67052. */
  67053. refreshVisibleSize(): PointsCloudSystem;
  67054. /**
  67055. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67056. * @param size the size (float) of the visibility box
  67057. * note : this doesn't lock the PCS mesh bounding box.
  67058. * doc :
  67059. */
  67060. setVisibilityBox(size: number): void;
  67061. /**
  67062. * Gets whether the PCS is always visible or not
  67063. * doc :
  67064. */
  67065. get isAlwaysVisible(): boolean;
  67066. /**
  67067. * Sets the PCS as always visible or not
  67068. * doc :
  67069. */
  67070. set isAlwaysVisible(val: boolean);
  67071. /**
  67072. * Tells to `setParticles()` to compute the particle rotations or not
  67073. * Default value : false. The PCS is faster when it's set to false
  67074. * Note : particle rotations are only applied to parent particles
  67075. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67076. */
  67077. set computeParticleRotation(val: boolean);
  67078. /**
  67079. * Tells to `setParticles()` to compute the particle colors or not.
  67080. * Default value : true. The PCS is faster when it's set to false.
  67081. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67082. */
  67083. set computeParticleColor(val: boolean);
  67084. set computeParticleTexture(val: boolean);
  67085. /**
  67086. * Gets if `setParticles()` computes the particle colors or not.
  67087. * Default value : false. The PCS is faster when it's set to false.
  67088. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67089. */
  67090. get computeParticleColor(): boolean;
  67091. /**
  67092. * Gets if `setParticles()` computes the particle textures or not.
  67093. * Default value : false. The PCS is faster when it's set to false.
  67094. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67095. */
  67096. get computeParticleTexture(): boolean;
  67097. /**
  67098. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67099. */
  67100. set computeBoundingBox(val: boolean);
  67101. /**
  67102. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67103. */
  67104. get computeBoundingBox(): boolean;
  67105. /**
  67106. * This function does nothing. It may be overwritten to set all the particle first values.
  67107. * The PCS doesn't call this function, you may have to call it by your own.
  67108. * doc :
  67109. */
  67110. initParticles(): void;
  67111. /**
  67112. * This function does nothing. It may be overwritten to recycle a particle
  67113. * The PCS doesn't call this function, you can to call it
  67114. * doc :
  67115. * @param particle The particle to recycle
  67116. * @returns the recycled particle
  67117. */
  67118. recycleParticle(particle: CloudPoint): CloudPoint;
  67119. /**
  67120. * Updates a particle : this function should be overwritten by the user.
  67121. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67122. * doc :
  67123. * @example : just set a particle position or velocity and recycle conditions
  67124. * @param particle The particle to update
  67125. * @returns the updated particle
  67126. */
  67127. updateParticle(particle: CloudPoint): CloudPoint;
  67128. /**
  67129. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67130. * This does nothing and may be overwritten by the user.
  67131. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67132. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67133. * @param update the boolean update value actually passed to setParticles()
  67134. */
  67135. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67136. /**
  67137. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67138. * This will be passed three parameters.
  67139. * This does nothing and may be overwritten by the user.
  67140. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67141. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67142. * @param update the boolean update value actually passed to setParticles()
  67143. */
  67144. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67145. }
  67146. }
  67147. declare module "babylonjs/Particles/cloudPoint" {
  67148. import { Nullable } from "babylonjs/types";
  67149. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67150. import { Mesh } from "babylonjs/Meshes/mesh";
  67151. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67152. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67153. /**
  67154. * Represents one particle of a points cloud system.
  67155. */
  67156. export class CloudPoint {
  67157. /**
  67158. * particle global index
  67159. */
  67160. idx: number;
  67161. /**
  67162. * The color of the particle
  67163. */
  67164. color: Nullable<Color4>;
  67165. /**
  67166. * The world space position of the particle.
  67167. */
  67168. position: Vector3;
  67169. /**
  67170. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67171. */
  67172. rotation: Vector3;
  67173. /**
  67174. * The world space rotation quaternion of the particle.
  67175. */
  67176. rotationQuaternion: Nullable<Quaternion>;
  67177. /**
  67178. * The uv of the particle.
  67179. */
  67180. uv: Nullable<Vector2>;
  67181. /**
  67182. * The current speed of the particle.
  67183. */
  67184. velocity: Vector3;
  67185. /**
  67186. * The pivot point in the particle local space.
  67187. */
  67188. pivot: Vector3;
  67189. /**
  67190. * Must the particle be translated from its pivot point in its local space ?
  67191. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67192. * Default : false
  67193. */
  67194. translateFromPivot: boolean;
  67195. /**
  67196. * Index of this particle in the global "positions" array (Internal use)
  67197. * @hidden
  67198. */
  67199. _pos: number;
  67200. /**
  67201. * @hidden Index of this particle in the global "indices" array (Internal use)
  67202. */
  67203. _ind: number;
  67204. /**
  67205. * Group this particle belongs to
  67206. */
  67207. _group: PointsGroup;
  67208. /**
  67209. * Group id of this particle
  67210. */
  67211. groupId: number;
  67212. /**
  67213. * Index of the particle in its group id (Internal use)
  67214. */
  67215. idxInGroup: number;
  67216. /**
  67217. * @hidden Particle BoundingInfo object (Internal use)
  67218. */
  67219. _boundingInfo: BoundingInfo;
  67220. /**
  67221. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67222. */
  67223. _pcs: PointsCloudSystem;
  67224. /**
  67225. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67226. */
  67227. _stillInvisible: boolean;
  67228. /**
  67229. * @hidden Last computed particle rotation matrix
  67230. */
  67231. _rotationMatrix: number[];
  67232. /**
  67233. * Parent particle Id, if any.
  67234. * Default null.
  67235. */
  67236. parentId: Nullable<number>;
  67237. /**
  67238. * @hidden Internal global position in the PCS.
  67239. */
  67240. _globalPosition: Vector3;
  67241. /**
  67242. * Creates a Point Cloud object.
  67243. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67244. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67245. * @param group (PointsGroup) is the group the particle belongs to
  67246. * @param groupId (integer) is the group identifier in the PCS.
  67247. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67248. * @param pcs defines the PCS it is associated to
  67249. */
  67250. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67251. /**
  67252. * get point size
  67253. */
  67254. get size(): Vector3;
  67255. /**
  67256. * Set point size
  67257. */
  67258. set size(scale: Vector3);
  67259. /**
  67260. * Legacy support, changed quaternion to rotationQuaternion
  67261. */
  67262. get quaternion(): Nullable<Quaternion>;
  67263. /**
  67264. * Legacy support, changed quaternion to rotationQuaternion
  67265. */
  67266. set quaternion(q: Nullable<Quaternion>);
  67267. /**
  67268. * Returns a boolean. True if the particle intersects a mesh, else false
  67269. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67270. * @param target is the object (point or mesh) what the intersection is computed against
  67271. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67272. * @returns true if it intersects
  67273. */
  67274. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67275. /**
  67276. * get the rotation matrix of the particle
  67277. * @hidden
  67278. */
  67279. getRotationMatrix(m: Matrix): void;
  67280. }
  67281. /**
  67282. * Represents a group of points in a points cloud system
  67283. * * PCS internal tool, don't use it manually.
  67284. */
  67285. export class PointsGroup {
  67286. /**
  67287. * The group id
  67288. * @hidden
  67289. */
  67290. groupID: number;
  67291. /**
  67292. * image data for group (internal use)
  67293. * @hidden
  67294. */
  67295. _groupImageData: Nullable<ArrayBufferView>;
  67296. /**
  67297. * Image Width (internal use)
  67298. * @hidden
  67299. */
  67300. _groupImgWidth: number;
  67301. /**
  67302. * Image Height (internal use)
  67303. * @hidden
  67304. */
  67305. _groupImgHeight: number;
  67306. /**
  67307. * Custom position function (internal use)
  67308. * @hidden
  67309. */
  67310. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67311. /**
  67312. * density per facet for surface points
  67313. * @hidden
  67314. */
  67315. _groupDensity: number[];
  67316. /**
  67317. * Only when points are colored by texture carries pointer to texture list array
  67318. * @hidden
  67319. */
  67320. _textureNb: number;
  67321. /**
  67322. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67323. * PCS internal tool, don't use it manually.
  67324. * @hidden
  67325. */
  67326. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67327. }
  67328. }
  67329. declare module "babylonjs/Particles/particleSystemDebugger" {
  67330. import { IDisposable } from "babylonjs/scene";
  67331. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67332. /**
  67333. * Represents a set of particle systems working together to create a specific effect
  67334. */
  67335. export class ParticleSystemDebugger implements IDisposable {
  67336. /**
  67337. * Defines the particle system to debug
  67338. */
  67339. system: IParticleSystem;
  67340. /**
  67341. * Creates a new particle system debugger
  67342. * @param system defines the particle system to debug
  67343. */
  67344. constructor(
  67345. /**
  67346. * Defines the particle system to debug
  67347. */
  67348. system: IParticleSystem);
  67349. /** Clear all the resources */
  67350. dispose(): void;
  67351. }
  67352. }
  67353. declare module "babylonjs/Particles/index" {
  67354. export * from "babylonjs/Particles/baseParticleSystem";
  67355. export * from "babylonjs/Particles/EmitterTypes/index";
  67356. export * from "babylonjs/Particles/gpuParticleSystem";
  67357. export * from "babylonjs/Particles/IParticleSystem";
  67358. export * from "babylonjs/Particles/particle";
  67359. export * from "babylonjs/Particles/particleHelper";
  67360. export * from "babylonjs/Particles/particleSystem";
  67361. export * from "babylonjs/Particles/particleSystemComponent";
  67362. export * from "babylonjs/Particles/particleSystemSet";
  67363. export * from "babylonjs/Particles/solidParticle";
  67364. export * from "babylonjs/Particles/solidParticleSystem";
  67365. export * from "babylonjs/Particles/cloudPoint";
  67366. export * from "babylonjs/Particles/pointsCloudSystem";
  67367. export * from "babylonjs/Particles/subEmitter";
  67368. export * from "babylonjs/Particles/particleSystemDebugger";
  67369. }
  67370. declare module "babylonjs/Physics/physicsEngineComponent" {
  67371. import { Nullable } from "babylonjs/types";
  67372. import { Observable, Observer } from "babylonjs/Misc/observable";
  67373. import { Vector3 } from "babylonjs/Maths/math.vector";
  67374. import { Mesh } from "babylonjs/Meshes/mesh";
  67375. import { ISceneComponent } from "babylonjs/sceneComponent";
  67376. import { Scene } from "babylonjs/scene";
  67377. import { Node } from "babylonjs/node";
  67378. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67379. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67380. module "babylonjs/scene" {
  67381. interface Scene {
  67382. /** @hidden (Backing field) */
  67383. _physicsEngine: Nullable<IPhysicsEngine>;
  67384. /** @hidden */
  67385. _physicsTimeAccumulator: number;
  67386. /**
  67387. * Gets the current physics engine
  67388. * @returns a IPhysicsEngine or null if none attached
  67389. */
  67390. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67391. /**
  67392. * Enables physics to the current scene
  67393. * @param gravity defines the scene's gravity for the physics engine
  67394. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67395. * @return a boolean indicating if the physics engine was initialized
  67396. */
  67397. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67398. /**
  67399. * Disables and disposes the physics engine associated with the scene
  67400. */
  67401. disablePhysicsEngine(): void;
  67402. /**
  67403. * Gets a boolean indicating if there is an active physics engine
  67404. * @returns a boolean indicating if there is an active physics engine
  67405. */
  67406. isPhysicsEnabled(): boolean;
  67407. /**
  67408. * Deletes a physics compound impostor
  67409. * @param compound defines the compound to delete
  67410. */
  67411. deleteCompoundImpostor(compound: any): void;
  67412. /**
  67413. * An event triggered when physic simulation is about to be run
  67414. */
  67415. onBeforePhysicsObservable: Observable<Scene>;
  67416. /**
  67417. * An event triggered when physic simulation has been done
  67418. */
  67419. onAfterPhysicsObservable: Observable<Scene>;
  67420. }
  67421. }
  67422. module "babylonjs/Meshes/abstractMesh" {
  67423. interface AbstractMesh {
  67424. /** @hidden */
  67425. _physicsImpostor: Nullable<PhysicsImpostor>;
  67426. /**
  67427. * Gets or sets impostor used for physic simulation
  67428. * @see http://doc.babylonjs.com/features/physics_engine
  67429. */
  67430. physicsImpostor: Nullable<PhysicsImpostor>;
  67431. /**
  67432. * Gets the current physics impostor
  67433. * @see http://doc.babylonjs.com/features/physics_engine
  67434. * @returns a physics impostor or null
  67435. */
  67436. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67437. /** Apply a physic impulse to the mesh
  67438. * @param force defines the force to apply
  67439. * @param contactPoint defines where to apply the force
  67440. * @returns the current mesh
  67441. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67442. */
  67443. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67444. /**
  67445. * Creates a physic joint between two meshes
  67446. * @param otherMesh defines the other mesh to use
  67447. * @param pivot1 defines the pivot to use on this mesh
  67448. * @param pivot2 defines the pivot to use on the other mesh
  67449. * @param options defines additional options (can be plugin dependent)
  67450. * @returns the current mesh
  67451. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67452. */
  67453. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67454. /** @hidden */
  67455. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67456. }
  67457. }
  67458. /**
  67459. * Defines the physics engine scene component responsible to manage a physics engine
  67460. */
  67461. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67462. /**
  67463. * The component name helpful to identify the component in the list of scene components.
  67464. */
  67465. readonly name: string;
  67466. /**
  67467. * The scene the component belongs to.
  67468. */
  67469. scene: Scene;
  67470. /**
  67471. * Creates a new instance of the component for the given scene
  67472. * @param scene Defines the scene to register the component in
  67473. */
  67474. constructor(scene: Scene);
  67475. /**
  67476. * Registers the component in a given scene
  67477. */
  67478. register(): void;
  67479. /**
  67480. * Rebuilds the elements related to this component in case of
  67481. * context lost for instance.
  67482. */
  67483. rebuild(): void;
  67484. /**
  67485. * Disposes the component and the associated ressources
  67486. */
  67487. dispose(): void;
  67488. }
  67489. }
  67490. declare module "babylonjs/Physics/physicsHelper" {
  67491. import { Nullable } from "babylonjs/types";
  67492. import { Vector3 } from "babylonjs/Maths/math.vector";
  67493. import { Mesh } from "babylonjs/Meshes/mesh";
  67494. import { Scene } from "babylonjs/scene";
  67495. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67496. /**
  67497. * A helper for physics simulations
  67498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67499. */
  67500. export class PhysicsHelper {
  67501. private _scene;
  67502. private _physicsEngine;
  67503. /**
  67504. * Initializes the Physics helper
  67505. * @param scene Babylon.js scene
  67506. */
  67507. constructor(scene: Scene);
  67508. /**
  67509. * Applies a radial explosion impulse
  67510. * @param origin the origin of the explosion
  67511. * @param radiusOrEventOptions the radius or the options of radial explosion
  67512. * @param strength the explosion strength
  67513. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67514. * @returns A physics radial explosion event, or null
  67515. */
  67516. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67517. /**
  67518. * Applies a radial explosion force
  67519. * @param origin the origin of the explosion
  67520. * @param radiusOrEventOptions the radius or the options of radial explosion
  67521. * @param strength the explosion strength
  67522. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67523. * @returns A physics radial explosion event, or null
  67524. */
  67525. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67526. /**
  67527. * Creates a gravitational field
  67528. * @param origin the origin of the explosion
  67529. * @param radiusOrEventOptions the radius or the options of radial explosion
  67530. * @param strength the explosion strength
  67531. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67532. * @returns A physics gravitational field event, or null
  67533. */
  67534. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67535. /**
  67536. * Creates a physics updraft event
  67537. * @param origin the origin of the updraft
  67538. * @param radiusOrEventOptions the radius or the options of the updraft
  67539. * @param strength the strength of the updraft
  67540. * @param height the height of the updraft
  67541. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67542. * @returns A physics updraft event, or null
  67543. */
  67544. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67545. /**
  67546. * Creates a physics vortex event
  67547. * @param origin the of the vortex
  67548. * @param radiusOrEventOptions the radius or the options of the vortex
  67549. * @param strength the strength of the vortex
  67550. * @param height the height of the vortex
  67551. * @returns a Physics vortex event, or null
  67552. * A physics vortex event or null
  67553. */
  67554. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67555. }
  67556. /**
  67557. * Represents a physics radial explosion event
  67558. */
  67559. class PhysicsRadialExplosionEvent {
  67560. private _scene;
  67561. private _options;
  67562. private _sphere;
  67563. private _dataFetched;
  67564. /**
  67565. * Initializes a radial explosioin event
  67566. * @param _scene BabylonJS scene
  67567. * @param _options The options for the vortex event
  67568. */
  67569. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67570. /**
  67571. * Returns the data related to the radial explosion event (sphere).
  67572. * @returns The radial explosion event data
  67573. */
  67574. getData(): PhysicsRadialExplosionEventData;
  67575. /**
  67576. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67577. * @param impostor A physics imposter
  67578. * @param origin the origin of the explosion
  67579. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67580. */
  67581. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67582. /**
  67583. * Triggers affecterd impostors callbacks
  67584. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67585. */
  67586. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67587. /**
  67588. * Disposes the sphere.
  67589. * @param force Specifies if the sphere should be disposed by force
  67590. */
  67591. dispose(force?: boolean): void;
  67592. /*** Helpers ***/
  67593. private _prepareSphere;
  67594. private _intersectsWithSphere;
  67595. }
  67596. /**
  67597. * Represents a gravitational field event
  67598. */
  67599. class PhysicsGravitationalFieldEvent {
  67600. private _physicsHelper;
  67601. private _scene;
  67602. private _origin;
  67603. private _options;
  67604. private _tickCallback;
  67605. private _sphere;
  67606. private _dataFetched;
  67607. /**
  67608. * Initializes the physics gravitational field event
  67609. * @param _physicsHelper A physics helper
  67610. * @param _scene BabylonJS scene
  67611. * @param _origin The origin position of the gravitational field event
  67612. * @param _options The options for the vortex event
  67613. */
  67614. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67615. /**
  67616. * Returns the data related to the gravitational field event (sphere).
  67617. * @returns A gravitational field event
  67618. */
  67619. getData(): PhysicsGravitationalFieldEventData;
  67620. /**
  67621. * Enables the gravitational field.
  67622. */
  67623. enable(): void;
  67624. /**
  67625. * Disables the gravitational field.
  67626. */
  67627. disable(): void;
  67628. /**
  67629. * Disposes the sphere.
  67630. * @param force The force to dispose from the gravitational field event
  67631. */
  67632. dispose(force?: boolean): void;
  67633. private _tick;
  67634. }
  67635. /**
  67636. * Represents a physics updraft event
  67637. */
  67638. class PhysicsUpdraftEvent {
  67639. private _scene;
  67640. private _origin;
  67641. private _options;
  67642. private _physicsEngine;
  67643. private _originTop;
  67644. private _originDirection;
  67645. private _tickCallback;
  67646. private _cylinder;
  67647. private _cylinderPosition;
  67648. private _dataFetched;
  67649. /**
  67650. * Initializes the physics updraft event
  67651. * @param _scene BabylonJS scene
  67652. * @param _origin The origin position of the updraft
  67653. * @param _options The options for the updraft event
  67654. */
  67655. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67656. /**
  67657. * Returns the data related to the updraft event (cylinder).
  67658. * @returns A physics updraft event
  67659. */
  67660. getData(): PhysicsUpdraftEventData;
  67661. /**
  67662. * Enables the updraft.
  67663. */
  67664. enable(): void;
  67665. /**
  67666. * Disables the updraft.
  67667. */
  67668. disable(): void;
  67669. /**
  67670. * Disposes the cylinder.
  67671. * @param force Specifies if the updraft should be disposed by force
  67672. */
  67673. dispose(force?: boolean): void;
  67674. private getImpostorHitData;
  67675. private _tick;
  67676. /*** Helpers ***/
  67677. private _prepareCylinder;
  67678. private _intersectsWithCylinder;
  67679. }
  67680. /**
  67681. * Represents a physics vortex event
  67682. */
  67683. class PhysicsVortexEvent {
  67684. private _scene;
  67685. private _origin;
  67686. private _options;
  67687. private _physicsEngine;
  67688. private _originTop;
  67689. private _tickCallback;
  67690. private _cylinder;
  67691. private _cylinderPosition;
  67692. private _dataFetched;
  67693. /**
  67694. * Initializes the physics vortex event
  67695. * @param _scene The BabylonJS scene
  67696. * @param _origin The origin position of the vortex
  67697. * @param _options The options for the vortex event
  67698. */
  67699. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67700. /**
  67701. * Returns the data related to the vortex event (cylinder).
  67702. * @returns The physics vortex event data
  67703. */
  67704. getData(): PhysicsVortexEventData;
  67705. /**
  67706. * Enables the vortex.
  67707. */
  67708. enable(): void;
  67709. /**
  67710. * Disables the cortex.
  67711. */
  67712. disable(): void;
  67713. /**
  67714. * Disposes the sphere.
  67715. * @param force
  67716. */
  67717. dispose(force?: boolean): void;
  67718. private getImpostorHitData;
  67719. private _tick;
  67720. /*** Helpers ***/
  67721. private _prepareCylinder;
  67722. private _intersectsWithCylinder;
  67723. }
  67724. /**
  67725. * Options fot the radial explosion event
  67726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67727. */
  67728. export class PhysicsRadialExplosionEventOptions {
  67729. /**
  67730. * The radius of the sphere for the radial explosion.
  67731. */
  67732. radius: number;
  67733. /**
  67734. * The strenth of the explosion.
  67735. */
  67736. strength: number;
  67737. /**
  67738. * The strenght of the force in correspondence to the distance of the affected object
  67739. */
  67740. falloff: PhysicsRadialImpulseFalloff;
  67741. /**
  67742. * Sphere options for the radial explosion.
  67743. */
  67744. sphere: {
  67745. segments: number;
  67746. diameter: number;
  67747. };
  67748. /**
  67749. * Sphere options for the radial explosion.
  67750. */
  67751. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67752. }
  67753. /**
  67754. * Options fot the updraft event
  67755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67756. */
  67757. export class PhysicsUpdraftEventOptions {
  67758. /**
  67759. * The radius of the cylinder for the vortex
  67760. */
  67761. radius: number;
  67762. /**
  67763. * The strenth of the updraft.
  67764. */
  67765. strength: number;
  67766. /**
  67767. * The height of the cylinder for the updraft.
  67768. */
  67769. height: number;
  67770. /**
  67771. * The mode for the the updraft.
  67772. */
  67773. updraftMode: PhysicsUpdraftMode;
  67774. }
  67775. /**
  67776. * Options fot the vortex event
  67777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67778. */
  67779. export class PhysicsVortexEventOptions {
  67780. /**
  67781. * The radius of the cylinder for the vortex
  67782. */
  67783. radius: number;
  67784. /**
  67785. * The strenth of the vortex.
  67786. */
  67787. strength: number;
  67788. /**
  67789. * The height of the cylinder for the vortex.
  67790. */
  67791. height: number;
  67792. /**
  67793. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67794. */
  67795. centripetalForceThreshold: number;
  67796. /**
  67797. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67798. */
  67799. centripetalForceMultiplier: number;
  67800. /**
  67801. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67802. */
  67803. centrifugalForceMultiplier: number;
  67804. /**
  67805. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67806. */
  67807. updraftForceMultiplier: number;
  67808. }
  67809. /**
  67810. * The strenght of the force in correspondence to the distance of the affected object
  67811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67812. */
  67813. export enum PhysicsRadialImpulseFalloff {
  67814. /** Defines that impulse is constant in strength across it's whole radius */
  67815. Constant = 0,
  67816. /** Defines that impulse gets weaker if it's further from the origin */
  67817. Linear = 1
  67818. }
  67819. /**
  67820. * The strength of the force in correspondence to the distance of the affected object
  67821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67822. */
  67823. export enum PhysicsUpdraftMode {
  67824. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67825. Center = 0,
  67826. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67827. Perpendicular = 1
  67828. }
  67829. /**
  67830. * Interface for a physics hit data
  67831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67832. */
  67833. export interface PhysicsHitData {
  67834. /**
  67835. * The force applied at the contact point
  67836. */
  67837. force: Vector3;
  67838. /**
  67839. * The contact point
  67840. */
  67841. contactPoint: Vector3;
  67842. /**
  67843. * The distance from the origin to the contact point
  67844. */
  67845. distanceFromOrigin: number;
  67846. }
  67847. /**
  67848. * Interface for radial explosion event data
  67849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67850. */
  67851. export interface PhysicsRadialExplosionEventData {
  67852. /**
  67853. * A sphere used for the radial explosion event
  67854. */
  67855. sphere: Mesh;
  67856. }
  67857. /**
  67858. * Interface for gravitational field event data
  67859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67860. */
  67861. export interface PhysicsGravitationalFieldEventData {
  67862. /**
  67863. * A sphere mesh used for the gravitational field event
  67864. */
  67865. sphere: Mesh;
  67866. }
  67867. /**
  67868. * Interface for updraft event data
  67869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67870. */
  67871. export interface PhysicsUpdraftEventData {
  67872. /**
  67873. * A cylinder used for the updraft event
  67874. */
  67875. cylinder: Mesh;
  67876. }
  67877. /**
  67878. * Interface for vortex event data
  67879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67880. */
  67881. export interface PhysicsVortexEventData {
  67882. /**
  67883. * A cylinder used for the vortex event
  67884. */
  67885. cylinder: Mesh;
  67886. }
  67887. /**
  67888. * Interface for an affected physics impostor
  67889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67890. */
  67891. export interface PhysicsAffectedImpostorWithData {
  67892. /**
  67893. * The impostor affected by the effect
  67894. */
  67895. impostor: PhysicsImpostor;
  67896. /**
  67897. * The data about the hit/horce from the explosion
  67898. */
  67899. hitData: PhysicsHitData;
  67900. }
  67901. }
  67902. declare module "babylonjs/Physics/Plugins/index" {
  67903. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67904. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67905. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67906. }
  67907. declare module "babylonjs/Physics/index" {
  67908. export * from "babylonjs/Physics/IPhysicsEngine";
  67909. export * from "babylonjs/Physics/physicsEngine";
  67910. export * from "babylonjs/Physics/physicsEngineComponent";
  67911. export * from "babylonjs/Physics/physicsHelper";
  67912. export * from "babylonjs/Physics/physicsImpostor";
  67913. export * from "babylonjs/Physics/physicsJoint";
  67914. export * from "babylonjs/Physics/Plugins/index";
  67915. }
  67916. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67917. /** @hidden */
  67918. export var blackAndWhitePixelShader: {
  67919. name: string;
  67920. shader: string;
  67921. };
  67922. }
  67923. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67924. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67925. import { Camera } from "babylonjs/Cameras/camera";
  67926. import { Engine } from "babylonjs/Engines/engine";
  67927. import "babylonjs/Shaders/blackAndWhite.fragment";
  67928. /**
  67929. * Post process used to render in black and white
  67930. */
  67931. export class BlackAndWhitePostProcess extends PostProcess {
  67932. /**
  67933. * Linear about to convert he result to black and white (default: 1)
  67934. */
  67935. degree: number;
  67936. /**
  67937. * Creates a black and white post process
  67938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67939. * @param name The name of the effect.
  67940. * @param options The required width/height ratio to downsize to before computing the render pass.
  67941. * @param camera The camera to apply the render pass to.
  67942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67943. * @param engine The engine which the post process will be applied. (default: current engine)
  67944. * @param reusable If the post process can be reused on the same frame. (default: false)
  67945. */
  67946. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67947. }
  67948. }
  67949. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67950. import { Nullable } from "babylonjs/types";
  67951. import { Camera } from "babylonjs/Cameras/camera";
  67952. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67953. import { Engine } from "babylonjs/Engines/engine";
  67954. /**
  67955. * This represents a set of one or more post processes in Babylon.
  67956. * A post process can be used to apply a shader to a texture after it is rendered.
  67957. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67958. */
  67959. export class PostProcessRenderEffect {
  67960. private _postProcesses;
  67961. private _getPostProcesses;
  67962. private _singleInstance;
  67963. private _cameras;
  67964. private _indicesForCamera;
  67965. /**
  67966. * Name of the effect
  67967. * @hidden
  67968. */
  67969. _name: string;
  67970. /**
  67971. * Instantiates a post process render effect.
  67972. * A post process can be used to apply a shader to a texture after it is rendered.
  67973. * @param engine The engine the effect is tied to
  67974. * @param name The name of the effect
  67975. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67976. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67977. */
  67978. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67979. /**
  67980. * Checks if all the post processes in the effect are supported.
  67981. */
  67982. get isSupported(): boolean;
  67983. /**
  67984. * Updates the current state of the effect
  67985. * @hidden
  67986. */
  67987. _update(): void;
  67988. /**
  67989. * Attaches the effect on cameras
  67990. * @param cameras The camera to attach to.
  67991. * @hidden
  67992. */
  67993. _attachCameras(cameras: Camera): void;
  67994. /**
  67995. * Attaches the effect on cameras
  67996. * @param cameras The camera to attach to.
  67997. * @hidden
  67998. */
  67999. _attachCameras(cameras: Camera[]): void;
  68000. /**
  68001. * Detaches the effect on cameras
  68002. * @param cameras The camera to detatch from.
  68003. * @hidden
  68004. */
  68005. _detachCameras(cameras: Camera): void;
  68006. /**
  68007. * Detatches the effect on cameras
  68008. * @param cameras The camera to detatch from.
  68009. * @hidden
  68010. */
  68011. _detachCameras(cameras: Camera[]): void;
  68012. /**
  68013. * Enables the effect on given cameras
  68014. * @param cameras The camera to enable.
  68015. * @hidden
  68016. */
  68017. _enable(cameras: Camera): void;
  68018. /**
  68019. * Enables the effect on given cameras
  68020. * @param cameras The camera to enable.
  68021. * @hidden
  68022. */
  68023. _enable(cameras: Nullable<Camera[]>): void;
  68024. /**
  68025. * Disables the effect on the given cameras
  68026. * @param cameras The camera to disable.
  68027. * @hidden
  68028. */
  68029. _disable(cameras: Camera): void;
  68030. /**
  68031. * Disables the effect on the given cameras
  68032. * @param cameras The camera to disable.
  68033. * @hidden
  68034. */
  68035. _disable(cameras: Nullable<Camera[]>): void;
  68036. /**
  68037. * Gets a list of the post processes contained in the effect.
  68038. * @param camera The camera to get the post processes on.
  68039. * @returns The list of the post processes in the effect.
  68040. */
  68041. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68042. }
  68043. }
  68044. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68045. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68046. /** @hidden */
  68047. export var extractHighlightsPixelShader: {
  68048. name: string;
  68049. shader: string;
  68050. };
  68051. }
  68052. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68053. import { Nullable } from "babylonjs/types";
  68054. import { Camera } from "babylonjs/Cameras/camera";
  68055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68056. import { Engine } from "babylonjs/Engines/engine";
  68057. import "babylonjs/Shaders/extractHighlights.fragment";
  68058. /**
  68059. * 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.
  68060. */
  68061. export class ExtractHighlightsPostProcess extends PostProcess {
  68062. /**
  68063. * The luminance threshold, pixels below this value will be set to black.
  68064. */
  68065. threshold: number;
  68066. /** @hidden */
  68067. _exposure: number;
  68068. /**
  68069. * Post process which has the input texture to be used when performing highlight extraction
  68070. * @hidden
  68071. */
  68072. _inputPostProcess: Nullable<PostProcess>;
  68073. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68074. }
  68075. }
  68076. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68077. /** @hidden */
  68078. export var bloomMergePixelShader: {
  68079. name: string;
  68080. shader: string;
  68081. };
  68082. }
  68083. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68084. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68085. import { Nullable } from "babylonjs/types";
  68086. import { Engine } from "babylonjs/Engines/engine";
  68087. import { Camera } from "babylonjs/Cameras/camera";
  68088. import "babylonjs/Shaders/bloomMerge.fragment";
  68089. /**
  68090. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68091. */
  68092. export class BloomMergePostProcess extends PostProcess {
  68093. /** Weight of the bloom to be added to the original input. */
  68094. weight: number;
  68095. /**
  68096. * Creates a new instance of @see BloomMergePostProcess
  68097. * @param name The name of the effect.
  68098. * @param originalFromInput Post process which's input will be used for the merge.
  68099. * @param blurred Blurred highlights post process which's output will be used.
  68100. * @param weight Weight of the bloom to be added to the original input.
  68101. * @param options The required width/height ratio to downsize to before computing the render pass.
  68102. * @param camera The camera to apply the render pass to.
  68103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68104. * @param engine The engine which the post process will be applied. (default: current engine)
  68105. * @param reusable If the post process can be reused on the same frame. (default: false)
  68106. * @param textureType Type of textures used when performing the post process. (default: 0)
  68107. * @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)
  68108. */
  68109. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68110. /** Weight of the bloom to be added to the original input. */
  68111. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68112. }
  68113. }
  68114. declare module "babylonjs/PostProcesses/bloomEffect" {
  68115. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68116. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68117. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68118. import { Camera } from "babylonjs/Cameras/camera";
  68119. import { Scene } from "babylonjs/scene";
  68120. /**
  68121. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68122. */
  68123. export class BloomEffect extends PostProcessRenderEffect {
  68124. private bloomScale;
  68125. /**
  68126. * @hidden Internal
  68127. */
  68128. _effects: Array<PostProcess>;
  68129. /**
  68130. * @hidden Internal
  68131. */
  68132. _downscale: ExtractHighlightsPostProcess;
  68133. private _blurX;
  68134. private _blurY;
  68135. private _merge;
  68136. /**
  68137. * The luminance threshold to find bright areas of the image to bloom.
  68138. */
  68139. get threshold(): number;
  68140. set threshold(value: number);
  68141. /**
  68142. * The strength of the bloom.
  68143. */
  68144. get weight(): number;
  68145. set weight(value: number);
  68146. /**
  68147. * Specifies the size of the bloom blur kernel, relative to the final output size
  68148. */
  68149. get kernel(): number;
  68150. set kernel(value: number);
  68151. /**
  68152. * Creates a new instance of @see BloomEffect
  68153. * @param scene The scene the effect belongs to.
  68154. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68155. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68156. * @param bloomWeight The the strength of bloom.
  68157. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68158. * @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)
  68159. */
  68160. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68161. /**
  68162. * Disposes each of the internal effects for a given camera.
  68163. * @param camera The camera to dispose the effect on.
  68164. */
  68165. disposeEffects(camera: Camera): void;
  68166. /**
  68167. * @hidden Internal
  68168. */
  68169. _updateEffects(): void;
  68170. /**
  68171. * Internal
  68172. * @returns if all the contained post processes are ready.
  68173. * @hidden
  68174. */
  68175. _isReady(): boolean;
  68176. }
  68177. }
  68178. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68179. /** @hidden */
  68180. export var chromaticAberrationPixelShader: {
  68181. name: string;
  68182. shader: string;
  68183. };
  68184. }
  68185. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68186. import { Vector2 } from "babylonjs/Maths/math.vector";
  68187. import { Nullable } from "babylonjs/types";
  68188. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68189. import { Camera } from "babylonjs/Cameras/camera";
  68190. import { Engine } from "babylonjs/Engines/engine";
  68191. import "babylonjs/Shaders/chromaticAberration.fragment";
  68192. /**
  68193. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68194. */
  68195. export class ChromaticAberrationPostProcess extends PostProcess {
  68196. /**
  68197. * The amount of seperation of rgb channels (default: 30)
  68198. */
  68199. aberrationAmount: number;
  68200. /**
  68201. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68202. */
  68203. radialIntensity: number;
  68204. /**
  68205. * 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))
  68206. */
  68207. direction: Vector2;
  68208. /**
  68209. * 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))
  68210. */
  68211. centerPosition: Vector2;
  68212. /**
  68213. * Creates a new instance ChromaticAberrationPostProcess
  68214. * @param name The name of the effect.
  68215. * @param screenWidth The width of the screen to apply the effect on.
  68216. * @param screenHeight The height of the screen to apply the effect on.
  68217. * @param options The required width/height ratio to downsize to before computing the render pass.
  68218. * @param camera The camera to apply the render pass to.
  68219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68220. * @param engine The engine which the post process will be applied. (default: current engine)
  68221. * @param reusable If the post process can be reused on the same frame. (default: false)
  68222. * @param textureType Type of textures used when performing the post process. (default: 0)
  68223. * @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)
  68224. */
  68225. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68226. }
  68227. }
  68228. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68229. /** @hidden */
  68230. export var circleOfConfusionPixelShader: {
  68231. name: string;
  68232. shader: string;
  68233. };
  68234. }
  68235. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68236. import { Nullable } from "babylonjs/types";
  68237. import { Engine } from "babylonjs/Engines/engine";
  68238. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68240. import { Camera } from "babylonjs/Cameras/camera";
  68241. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68242. /**
  68243. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68244. */
  68245. export class CircleOfConfusionPostProcess extends PostProcess {
  68246. /**
  68247. * 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.
  68248. */
  68249. lensSize: number;
  68250. /**
  68251. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68252. */
  68253. fStop: number;
  68254. /**
  68255. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68256. */
  68257. focusDistance: number;
  68258. /**
  68259. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68260. */
  68261. focalLength: number;
  68262. private _depthTexture;
  68263. /**
  68264. * Creates a new instance CircleOfConfusionPostProcess
  68265. * @param name The name of the effect.
  68266. * @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.
  68267. * @param options The required width/height ratio to downsize to before computing the render pass.
  68268. * @param camera The camera to apply the render pass to.
  68269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68270. * @param engine The engine which the post process will be applied. (default: current engine)
  68271. * @param reusable If the post process can be reused on the same frame. (default: false)
  68272. * @param textureType Type of textures used when performing the post process. (default: 0)
  68273. * @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)
  68274. */
  68275. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68276. /**
  68277. * 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.
  68278. */
  68279. set depthTexture(value: RenderTargetTexture);
  68280. }
  68281. }
  68282. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68283. /** @hidden */
  68284. export var colorCorrectionPixelShader: {
  68285. name: string;
  68286. shader: string;
  68287. };
  68288. }
  68289. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68290. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68291. import { Engine } from "babylonjs/Engines/engine";
  68292. import { Camera } from "babylonjs/Cameras/camera";
  68293. import "babylonjs/Shaders/colorCorrection.fragment";
  68294. /**
  68295. *
  68296. * This post-process allows the modification of rendered colors by using
  68297. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68298. *
  68299. * The object needs to be provided an url to a texture containing the color
  68300. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68301. * Use an image editing software to tweak the LUT to match your needs.
  68302. *
  68303. * For an example of a color LUT, see here:
  68304. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68305. * For explanations on color grading, see here:
  68306. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68307. *
  68308. */
  68309. export class ColorCorrectionPostProcess extends PostProcess {
  68310. private _colorTableTexture;
  68311. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68312. }
  68313. }
  68314. declare module "babylonjs/Shaders/convolution.fragment" {
  68315. /** @hidden */
  68316. export var convolutionPixelShader: {
  68317. name: string;
  68318. shader: string;
  68319. };
  68320. }
  68321. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68322. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68323. import { Nullable } from "babylonjs/types";
  68324. import { Camera } from "babylonjs/Cameras/camera";
  68325. import { Engine } from "babylonjs/Engines/engine";
  68326. import "babylonjs/Shaders/convolution.fragment";
  68327. /**
  68328. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68329. * input texture to perform effects such as edge detection or sharpening
  68330. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68331. */
  68332. export class ConvolutionPostProcess extends PostProcess {
  68333. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68334. kernel: number[];
  68335. /**
  68336. * Creates a new instance ConvolutionPostProcess
  68337. * @param name The name of the effect.
  68338. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68339. * @param options The required width/height ratio to downsize to before computing the render pass.
  68340. * @param camera The camera to apply the render pass to.
  68341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68342. * @param engine The engine which the post process will be applied. (default: current engine)
  68343. * @param reusable If the post process can be reused on the same frame. (default: false)
  68344. * @param textureType Type of textures used when performing the post process. (default: 0)
  68345. */
  68346. constructor(name: string,
  68347. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68348. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68349. /**
  68350. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68351. */
  68352. static EdgeDetect0Kernel: number[];
  68353. /**
  68354. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68355. */
  68356. static EdgeDetect1Kernel: number[];
  68357. /**
  68358. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68359. */
  68360. static EdgeDetect2Kernel: number[];
  68361. /**
  68362. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68363. */
  68364. static SharpenKernel: number[];
  68365. /**
  68366. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68367. */
  68368. static EmbossKernel: number[];
  68369. /**
  68370. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68371. */
  68372. static GaussianKernel: number[];
  68373. }
  68374. }
  68375. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68376. import { Nullable } from "babylonjs/types";
  68377. import { Vector2 } from "babylonjs/Maths/math.vector";
  68378. import { Camera } from "babylonjs/Cameras/camera";
  68379. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68380. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68381. import { Engine } from "babylonjs/Engines/engine";
  68382. import { Scene } from "babylonjs/scene";
  68383. /**
  68384. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68385. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68386. * based on samples that have a large difference in distance than the center pixel.
  68387. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68388. */
  68389. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68390. direction: Vector2;
  68391. /**
  68392. * Creates a new instance CircleOfConfusionPostProcess
  68393. * @param name The name of the effect.
  68394. * @param scene The scene the effect belongs to.
  68395. * @param direction The direction the blur should be applied.
  68396. * @param kernel The size of the kernel used to blur.
  68397. * @param options The required width/height ratio to downsize to before computing the render pass.
  68398. * @param camera The camera to apply the render pass to.
  68399. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68400. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68402. * @param engine The engine which the post process will be applied. (default: current engine)
  68403. * @param reusable If the post process can be reused on the same frame. (default: false)
  68404. * @param textureType Type of textures used when performing the post process. (default: 0)
  68405. * @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)
  68406. */
  68407. 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);
  68408. }
  68409. }
  68410. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68411. /** @hidden */
  68412. export var depthOfFieldMergePixelShader: {
  68413. name: string;
  68414. shader: string;
  68415. };
  68416. }
  68417. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68418. import { Nullable } from "babylonjs/types";
  68419. import { Camera } from "babylonjs/Cameras/camera";
  68420. import { Effect } from "babylonjs/Materials/effect";
  68421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68422. import { Engine } from "babylonjs/Engines/engine";
  68423. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68424. /**
  68425. * Options to be set when merging outputs from the default pipeline.
  68426. */
  68427. export class DepthOfFieldMergePostProcessOptions {
  68428. /**
  68429. * The original image to merge on top of
  68430. */
  68431. originalFromInput: PostProcess;
  68432. /**
  68433. * Parameters to perform the merge of the depth of field effect
  68434. */
  68435. depthOfField?: {
  68436. circleOfConfusion: PostProcess;
  68437. blurSteps: Array<PostProcess>;
  68438. };
  68439. /**
  68440. * Parameters to perform the merge of bloom effect
  68441. */
  68442. bloom?: {
  68443. blurred: PostProcess;
  68444. weight: number;
  68445. };
  68446. }
  68447. /**
  68448. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68449. */
  68450. export class DepthOfFieldMergePostProcess extends PostProcess {
  68451. private blurSteps;
  68452. /**
  68453. * Creates a new instance of DepthOfFieldMergePostProcess
  68454. * @param name The name of the effect.
  68455. * @param originalFromInput Post process which's input will be used for the merge.
  68456. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68457. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68458. * @param options The required width/height ratio to downsize to before computing the render pass.
  68459. * @param camera The camera to apply the render pass to.
  68460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68461. * @param engine The engine which the post process will be applied. (default: current engine)
  68462. * @param reusable If the post process can be reused on the same frame. (default: false)
  68463. * @param textureType Type of textures used when performing the post process. (default: 0)
  68464. * @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)
  68465. */
  68466. 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);
  68467. /**
  68468. * Updates the effect with the current post process compile time values and recompiles the shader.
  68469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68472. * @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
  68473. * @param onCompiled Called when the shader has been compiled.
  68474. * @param onError Called if there is an error when compiling a shader.
  68475. */
  68476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68477. }
  68478. }
  68479. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68480. import { Nullable } from "babylonjs/types";
  68481. import { Camera } from "babylonjs/Cameras/camera";
  68482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68484. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68485. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68486. import { Scene } from "babylonjs/scene";
  68487. /**
  68488. * Specifies the level of max blur that should be applied when using the depth of field effect
  68489. */
  68490. export enum DepthOfFieldEffectBlurLevel {
  68491. /**
  68492. * Subtle blur
  68493. */
  68494. Low = 0,
  68495. /**
  68496. * Medium blur
  68497. */
  68498. Medium = 1,
  68499. /**
  68500. * Large blur
  68501. */
  68502. High = 2
  68503. }
  68504. /**
  68505. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68506. */
  68507. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68508. private _circleOfConfusion;
  68509. /**
  68510. * @hidden Internal, blurs from high to low
  68511. */
  68512. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68513. private _depthOfFieldBlurY;
  68514. private _dofMerge;
  68515. /**
  68516. * @hidden Internal post processes in depth of field effect
  68517. */
  68518. _effects: Array<PostProcess>;
  68519. /**
  68520. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68521. */
  68522. set focalLength(value: number);
  68523. get focalLength(): number;
  68524. /**
  68525. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68526. */
  68527. set fStop(value: number);
  68528. get fStop(): number;
  68529. /**
  68530. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68531. */
  68532. set focusDistance(value: number);
  68533. get focusDistance(): number;
  68534. /**
  68535. * 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.
  68536. */
  68537. set lensSize(value: number);
  68538. get lensSize(): number;
  68539. /**
  68540. * Creates a new instance DepthOfFieldEffect
  68541. * @param scene The scene the effect belongs to.
  68542. * @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.
  68543. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68544. * @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)
  68545. */
  68546. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68547. /**
  68548. * Get the current class name of the current effet
  68549. * @returns "DepthOfFieldEffect"
  68550. */
  68551. getClassName(): string;
  68552. /**
  68553. * 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.
  68554. */
  68555. set depthTexture(value: RenderTargetTexture);
  68556. /**
  68557. * Disposes each of the internal effects for a given camera.
  68558. * @param camera The camera to dispose the effect on.
  68559. */
  68560. disposeEffects(camera: Camera): void;
  68561. /**
  68562. * @hidden Internal
  68563. */
  68564. _updateEffects(): void;
  68565. /**
  68566. * Internal
  68567. * @returns if all the contained post processes are ready.
  68568. * @hidden
  68569. */
  68570. _isReady(): boolean;
  68571. }
  68572. }
  68573. declare module "babylonjs/Shaders/displayPass.fragment" {
  68574. /** @hidden */
  68575. export var displayPassPixelShader: {
  68576. name: string;
  68577. shader: string;
  68578. };
  68579. }
  68580. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68581. import { Nullable } from "babylonjs/types";
  68582. import { Camera } from "babylonjs/Cameras/camera";
  68583. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68584. import { Engine } from "babylonjs/Engines/engine";
  68585. import "babylonjs/Shaders/displayPass.fragment";
  68586. /**
  68587. * DisplayPassPostProcess which produces an output the same as it's input
  68588. */
  68589. export class DisplayPassPostProcess extends PostProcess {
  68590. /**
  68591. * Creates the DisplayPassPostProcess
  68592. * @param name The name of the effect.
  68593. * @param options The required width/height ratio to downsize to before computing the render pass.
  68594. * @param camera The camera to apply the render pass to.
  68595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68596. * @param engine The engine which the post process will be applied. (default: current engine)
  68597. * @param reusable If the post process can be reused on the same frame. (default: false)
  68598. */
  68599. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68600. }
  68601. }
  68602. declare module "babylonjs/Shaders/filter.fragment" {
  68603. /** @hidden */
  68604. export var filterPixelShader: {
  68605. name: string;
  68606. shader: string;
  68607. };
  68608. }
  68609. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68610. import { Nullable } from "babylonjs/types";
  68611. import { Matrix } from "babylonjs/Maths/math.vector";
  68612. import { Camera } from "babylonjs/Cameras/camera";
  68613. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68614. import { Engine } from "babylonjs/Engines/engine";
  68615. import "babylonjs/Shaders/filter.fragment";
  68616. /**
  68617. * Applies a kernel filter to the image
  68618. */
  68619. export class FilterPostProcess extends PostProcess {
  68620. /** The matrix to be applied to the image */
  68621. kernelMatrix: Matrix;
  68622. /**
  68623. *
  68624. * @param name The name of the effect.
  68625. * @param kernelMatrix The matrix to be applied to the image
  68626. * @param options The required width/height ratio to downsize to before computing the render pass.
  68627. * @param camera The camera to apply the render pass to.
  68628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68629. * @param engine The engine which the post process will be applied. (default: current engine)
  68630. * @param reusable If the post process can be reused on the same frame. (default: false)
  68631. */
  68632. constructor(name: string,
  68633. /** The matrix to be applied to the image */
  68634. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68635. }
  68636. }
  68637. declare module "babylonjs/Shaders/fxaa.fragment" {
  68638. /** @hidden */
  68639. export var fxaaPixelShader: {
  68640. name: string;
  68641. shader: string;
  68642. };
  68643. }
  68644. declare module "babylonjs/Shaders/fxaa.vertex" {
  68645. /** @hidden */
  68646. export var fxaaVertexShader: {
  68647. name: string;
  68648. shader: string;
  68649. };
  68650. }
  68651. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68652. import { Nullable } from "babylonjs/types";
  68653. import { Camera } from "babylonjs/Cameras/camera";
  68654. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68655. import { Engine } from "babylonjs/Engines/engine";
  68656. import "babylonjs/Shaders/fxaa.fragment";
  68657. import "babylonjs/Shaders/fxaa.vertex";
  68658. /**
  68659. * Fxaa post process
  68660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68661. */
  68662. export class FxaaPostProcess extends PostProcess {
  68663. /** @hidden */
  68664. texelWidth: number;
  68665. /** @hidden */
  68666. texelHeight: number;
  68667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68668. private _getDefines;
  68669. }
  68670. }
  68671. declare module "babylonjs/Shaders/grain.fragment" {
  68672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68673. /** @hidden */
  68674. export var grainPixelShader: {
  68675. name: string;
  68676. shader: string;
  68677. };
  68678. }
  68679. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68680. import { Nullable } from "babylonjs/types";
  68681. import { Camera } from "babylonjs/Cameras/camera";
  68682. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68683. import { Engine } from "babylonjs/Engines/engine";
  68684. import "babylonjs/Shaders/grain.fragment";
  68685. /**
  68686. * The GrainPostProcess adds noise to the image at mid luminance levels
  68687. */
  68688. export class GrainPostProcess extends PostProcess {
  68689. /**
  68690. * The intensity of the grain added (default: 30)
  68691. */
  68692. intensity: number;
  68693. /**
  68694. * If the grain should be randomized on every frame
  68695. */
  68696. animated: boolean;
  68697. /**
  68698. * Creates a new instance of @see GrainPostProcess
  68699. * @param name The name of the effect.
  68700. * @param options The required width/height ratio to downsize to before computing the render pass.
  68701. * @param camera The camera to apply the render pass to.
  68702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68703. * @param engine The engine which the post process will be applied. (default: current engine)
  68704. * @param reusable If the post process can be reused on the same frame. (default: false)
  68705. * @param textureType Type of textures used when performing the post process. (default: 0)
  68706. * @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)
  68707. */
  68708. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68709. }
  68710. }
  68711. declare module "babylonjs/Shaders/highlights.fragment" {
  68712. /** @hidden */
  68713. export var highlightsPixelShader: {
  68714. name: string;
  68715. shader: string;
  68716. };
  68717. }
  68718. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68719. import { Nullable } from "babylonjs/types";
  68720. import { Camera } from "babylonjs/Cameras/camera";
  68721. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68722. import { Engine } from "babylonjs/Engines/engine";
  68723. import "babylonjs/Shaders/highlights.fragment";
  68724. /**
  68725. * Extracts highlights from the image
  68726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68727. */
  68728. export class HighlightsPostProcess extends PostProcess {
  68729. /**
  68730. * Extracts highlights from the image
  68731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68732. * @param name The name of the effect.
  68733. * @param options The required width/height ratio to downsize to before computing the render pass.
  68734. * @param camera The camera to apply the render pass to.
  68735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68736. * @param engine The engine which the post process will be applied. (default: current engine)
  68737. * @param reusable If the post process can be reused on the same frame. (default: false)
  68738. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68739. */
  68740. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68741. }
  68742. }
  68743. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68744. /** @hidden */
  68745. export var mrtFragmentDeclaration: {
  68746. name: string;
  68747. shader: string;
  68748. };
  68749. }
  68750. declare module "babylonjs/Shaders/geometry.fragment" {
  68751. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68752. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68753. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68754. /** @hidden */
  68755. export var geometryPixelShader: {
  68756. name: string;
  68757. shader: string;
  68758. };
  68759. }
  68760. declare module "babylonjs/Shaders/geometry.vertex" {
  68761. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68764. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68766. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68767. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68768. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68769. /** @hidden */
  68770. export var geometryVertexShader: {
  68771. name: string;
  68772. shader: string;
  68773. };
  68774. }
  68775. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68776. import { Matrix } from "babylonjs/Maths/math.vector";
  68777. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68778. import { Mesh } from "babylonjs/Meshes/mesh";
  68779. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68780. import { Effect } from "babylonjs/Materials/effect";
  68781. import { Scene } from "babylonjs/scene";
  68782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68783. import "babylonjs/Shaders/geometry.fragment";
  68784. import "babylonjs/Shaders/geometry.vertex";
  68785. /** @hidden */
  68786. interface ISavedTransformationMatrix {
  68787. world: Matrix;
  68788. viewProjection: Matrix;
  68789. }
  68790. /**
  68791. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68792. */
  68793. export class GeometryBufferRenderer {
  68794. /**
  68795. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68796. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68797. */
  68798. static readonly POSITION_TEXTURE_TYPE: number;
  68799. /**
  68800. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68801. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68802. */
  68803. static readonly VELOCITY_TEXTURE_TYPE: number;
  68804. /**
  68805. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68806. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68807. */
  68808. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68809. /**
  68810. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68811. * in order to compute objects velocities when enableVelocity is set to "true"
  68812. * @hidden
  68813. */
  68814. _previousTransformationMatrices: {
  68815. [index: number]: ISavedTransformationMatrix;
  68816. };
  68817. /**
  68818. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68819. * in order to compute objects velocities when enableVelocity is set to "true"
  68820. * @hidden
  68821. */
  68822. _previousBonesTransformationMatrices: {
  68823. [index: number]: Float32Array;
  68824. };
  68825. /**
  68826. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68827. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68828. */
  68829. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68830. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68831. renderTransparentMeshes: boolean;
  68832. private _scene;
  68833. private _multiRenderTarget;
  68834. private _ratio;
  68835. private _enablePosition;
  68836. private _enableVelocity;
  68837. private _enableReflectivity;
  68838. private _positionIndex;
  68839. private _velocityIndex;
  68840. private _reflectivityIndex;
  68841. protected _effect: Effect;
  68842. protected _cachedDefines: string;
  68843. /**
  68844. * Set the render list (meshes to be rendered) used in the G buffer.
  68845. */
  68846. set renderList(meshes: Mesh[]);
  68847. /**
  68848. * Gets wether or not G buffer are supported by the running hardware.
  68849. * This requires draw buffer supports
  68850. */
  68851. get isSupported(): boolean;
  68852. /**
  68853. * Returns the index of the given texture type in the G-Buffer textures array
  68854. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68855. * @returns the index of the given texture type in the G-Buffer textures array
  68856. */
  68857. getTextureIndex(textureType: number): number;
  68858. /**
  68859. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68860. */
  68861. get enablePosition(): boolean;
  68862. /**
  68863. * Sets whether or not objects positions are enabled for the G buffer.
  68864. */
  68865. set enablePosition(enable: boolean);
  68866. /**
  68867. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68868. */
  68869. get enableVelocity(): boolean;
  68870. /**
  68871. * Sets wether or not objects velocities are enabled for the G buffer.
  68872. */
  68873. set enableVelocity(enable: boolean);
  68874. /**
  68875. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68876. */
  68877. get enableReflectivity(): boolean;
  68878. /**
  68879. * Sets wether or not objects roughness are enabled for the G buffer.
  68880. */
  68881. set enableReflectivity(enable: boolean);
  68882. /**
  68883. * Gets the scene associated with the buffer.
  68884. */
  68885. get scene(): Scene;
  68886. /**
  68887. * Gets the ratio used by the buffer during its creation.
  68888. * How big is the buffer related to the main canvas.
  68889. */
  68890. get ratio(): number;
  68891. /** @hidden */
  68892. static _SceneComponentInitialization: (scene: Scene) => void;
  68893. /**
  68894. * Creates a new G Buffer for the scene
  68895. * @param scene The scene the buffer belongs to
  68896. * @param ratio How big is the buffer related to the main canvas.
  68897. */
  68898. constructor(scene: Scene, ratio?: number);
  68899. /**
  68900. * Checks wether everything is ready to render a submesh to the G buffer.
  68901. * @param subMesh the submesh to check readiness for
  68902. * @param useInstances is the mesh drawn using instance or not
  68903. * @returns true if ready otherwise false
  68904. */
  68905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68906. /**
  68907. * Gets the current underlying G Buffer.
  68908. * @returns the buffer
  68909. */
  68910. getGBuffer(): MultiRenderTarget;
  68911. /**
  68912. * Gets the number of samples used to render the buffer (anti aliasing).
  68913. */
  68914. get samples(): number;
  68915. /**
  68916. * Sets the number of samples used to render the buffer (anti aliasing).
  68917. */
  68918. set samples(value: number);
  68919. /**
  68920. * Disposes the renderer and frees up associated resources.
  68921. */
  68922. dispose(): void;
  68923. protected _createRenderTargets(): void;
  68924. private _copyBonesTransformationMatrices;
  68925. }
  68926. }
  68927. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68928. import { Nullable } from "babylonjs/types";
  68929. import { Scene } from "babylonjs/scene";
  68930. import { ISceneComponent } from "babylonjs/sceneComponent";
  68931. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68932. module "babylonjs/scene" {
  68933. interface Scene {
  68934. /** @hidden (Backing field) */
  68935. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68936. /**
  68937. * Gets or Sets the current geometry buffer associated to the scene.
  68938. */
  68939. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68940. /**
  68941. * Enables a GeometryBufferRender and associates it with the scene
  68942. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68943. * @returns the GeometryBufferRenderer
  68944. */
  68945. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68946. /**
  68947. * Disables the GeometryBufferRender associated with the scene
  68948. */
  68949. disableGeometryBufferRenderer(): void;
  68950. }
  68951. }
  68952. /**
  68953. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68954. * in several rendering techniques.
  68955. */
  68956. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68957. /**
  68958. * The component name helpful to identify the component in the list of scene components.
  68959. */
  68960. readonly name: string;
  68961. /**
  68962. * The scene the component belongs to.
  68963. */
  68964. scene: Scene;
  68965. /**
  68966. * Creates a new instance of the component for the given scene
  68967. * @param scene Defines the scene to register the component in
  68968. */
  68969. constructor(scene: Scene);
  68970. /**
  68971. * Registers the component in a given scene
  68972. */
  68973. register(): void;
  68974. /**
  68975. * Rebuilds the elements related to this component in case of
  68976. * context lost for instance.
  68977. */
  68978. rebuild(): void;
  68979. /**
  68980. * Disposes the component and the associated ressources
  68981. */
  68982. dispose(): void;
  68983. private _gatherRenderTargets;
  68984. }
  68985. }
  68986. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68987. /** @hidden */
  68988. export var motionBlurPixelShader: {
  68989. name: string;
  68990. shader: string;
  68991. };
  68992. }
  68993. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68994. import { Nullable } from "babylonjs/types";
  68995. import { Camera } from "babylonjs/Cameras/camera";
  68996. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68997. import { Scene } from "babylonjs/scene";
  68998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68999. import "babylonjs/Animations/animatable";
  69000. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69001. import "babylonjs/Shaders/motionBlur.fragment";
  69002. import { Engine } from "babylonjs/Engines/engine";
  69003. /**
  69004. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69005. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69006. * As an example, all you have to do is to create the post-process:
  69007. * var mb = new BABYLON.MotionBlurPostProcess(
  69008. * 'mb', // The name of the effect.
  69009. * scene, // The scene containing the objects to blur according to their velocity.
  69010. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69011. * camera // The camera to apply the render pass to.
  69012. * );
  69013. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69014. */
  69015. export class MotionBlurPostProcess extends PostProcess {
  69016. /**
  69017. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69018. */
  69019. motionStrength: number;
  69020. /**
  69021. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69022. */
  69023. get motionBlurSamples(): number;
  69024. /**
  69025. * Sets the number of iterations to be used for motion blur quality
  69026. */
  69027. set motionBlurSamples(samples: number);
  69028. private _motionBlurSamples;
  69029. private _geometryBufferRenderer;
  69030. /**
  69031. * Creates a new instance MotionBlurPostProcess
  69032. * @param name The name of the effect.
  69033. * @param scene The scene containing the objects to blur according to their velocity.
  69034. * @param options The required width/height ratio to downsize to before computing the render pass.
  69035. * @param camera The camera to apply the render pass to.
  69036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69037. * @param engine The engine which the post process will be applied. (default: current engine)
  69038. * @param reusable If the post process can be reused on the same frame. (default: false)
  69039. * @param textureType Type of textures used when performing the post process. (default: 0)
  69040. * @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)
  69041. */
  69042. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69043. /**
  69044. * Excludes the given skinned mesh from computing bones velocities.
  69045. * 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.
  69046. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69047. */
  69048. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69049. /**
  69050. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69051. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69052. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69053. */
  69054. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69055. /**
  69056. * Disposes the post process.
  69057. * @param camera The camera to dispose the post process on.
  69058. */
  69059. dispose(camera?: Camera): void;
  69060. }
  69061. }
  69062. declare module "babylonjs/Shaders/refraction.fragment" {
  69063. /** @hidden */
  69064. export var refractionPixelShader: {
  69065. name: string;
  69066. shader: string;
  69067. };
  69068. }
  69069. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69070. import { Color3 } from "babylonjs/Maths/math.color";
  69071. import { Camera } from "babylonjs/Cameras/camera";
  69072. import { Texture } from "babylonjs/Materials/Textures/texture";
  69073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69074. import { Engine } from "babylonjs/Engines/engine";
  69075. import "babylonjs/Shaders/refraction.fragment";
  69076. /**
  69077. * Post process which applies a refractin texture
  69078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69079. */
  69080. export class RefractionPostProcess extends PostProcess {
  69081. /** the base color of the refraction (used to taint the rendering) */
  69082. color: Color3;
  69083. /** simulated refraction depth */
  69084. depth: number;
  69085. /** the coefficient of the base color (0 to remove base color tainting) */
  69086. colorLevel: number;
  69087. private _refTexture;
  69088. private _ownRefractionTexture;
  69089. /**
  69090. * Gets or sets the refraction texture
  69091. * Please note that you are responsible for disposing the texture if you set it manually
  69092. */
  69093. get refractionTexture(): Texture;
  69094. set refractionTexture(value: Texture);
  69095. /**
  69096. * Initializes the RefractionPostProcess
  69097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69098. * @param name The name of the effect.
  69099. * @param refractionTextureUrl Url of the refraction texture to use
  69100. * @param color the base color of the refraction (used to taint the rendering)
  69101. * @param depth simulated refraction depth
  69102. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69103. * @param camera The camera to apply the render pass to.
  69104. * @param options The required width/height ratio to downsize to before computing the render pass.
  69105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69106. * @param engine The engine which the post process will be applied. (default: current engine)
  69107. * @param reusable If the post process can be reused on the same frame. (default: false)
  69108. */
  69109. constructor(name: string, refractionTextureUrl: string,
  69110. /** the base color of the refraction (used to taint the rendering) */
  69111. color: Color3,
  69112. /** simulated refraction depth */
  69113. depth: number,
  69114. /** the coefficient of the base color (0 to remove base color tainting) */
  69115. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69116. /**
  69117. * Disposes of the post process
  69118. * @param camera Camera to dispose post process on
  69119. */
  69120. dispose(camera: Camera): void;
  69121. }
  69122. }
  69123. declare module "babylonjs/Shaders/sharpen.fragment" {
  69124. /** @hidden */
  69125. export var sharpenPixelShader: {
  69126. name: string;
  69127. shader: string;
  69128. };
  69129. }
  69130. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69131. import { Nullable } from "babylonjs/types";
  69132. import { Camera } from "babylonjs/Cameras/camera";
  69133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69134. import "babylonjs/Shaders/sharpen.fragment";
  69135. import { Engine } from "babylonjs/Engines/engine";
  69136. /**
  69137. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69138. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69139. */
  69140. export class SharpenPostProcess extends PostProcess {
  69141. /**
  69142. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69143. */
  69144. colorAmount: number;
  69145. /**
  69146. * How much sharpness should be applied (default: 0.3)
  69147. */
  69148. edgeAmount: number;
  69149. /**
  69150. * Creates a new instance ConvolutionPostProcess
  69151. * @param name The name of the effect.
  69152. * @param options The required width/height ratio to downsize to before computing the render pass.
  69153. * @param camera The camera to apply the render pass to.
  69154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69155. * @param engine The engine which the post process will be applied. (default: current engine)
  69156. * @param reusable If the post process can be reused on the same frame. (default: false)
  69157. * @param textureType Type of textures used when performing the post process. (default: 0)
  69158. * @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)
  69159. */
  69160. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69161. }
  69162. }
  69163. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69164. import { Nullable } from "babylonjs/types";
  69165. import { Camera } from "babylonjs/Cameras/camera";
  69166. import { Engine } from "babylonjs/Engines/engine";
  69167. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69168. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69169. /**
  69170. * PostProcessRenderPipeline
  69171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69172. */
  69173. export class PostProcessRenderPipeline {
  69174. private engine;
  69175. private _renderEffects;
  69176. private _renderEffectsForIsolatedPass;
  69177. /**
  69178. * List of inspectable custom properties (used by the Inspector)
  69179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69180. */
  69181. inspectableCustomProperties: IInspectable[];
  69182. /**
  69183. * @hidden
  69184. */
  69185. protected _cameras: Camera[];
  69186. /** @hidden */
  69187. _name: string;
  69188. /**
  69189. * Gets pipeline name
  69190. */
  69191. get name(): string;
  69192. /** Gets the list of attached cameras */
  69193. get cameras(): Camera[];
  69194. /**
  69195. * Initializes a PostProcessRenderPipeline
  69196. * @param engine engine to add the pipeline to
  69197. * @param name name of the pipeline
  69198. */
  69199. constructor(engine: Engine, name: string);
  69200. /**
  69201. * Gets the class name
  69202. * @returns "PostProcessRenderPipeline"
  69203. */
  69204. getClassName(): string;
  69205. /**
  69206. * If all the render effects in the pipeline are supported
  69207. */
  69208. get isSupported(): boolean;
  69209. /**
  69210. * Adds an effect to the pipeline
  69211. * @param renderEffect the effect to add
  69212. */
  69213. addEffect(renderEffect: PostProcessRenderEffect): void;
  69214. /** @hidden */
  69215. _rebuild(): void;
  69216. /** @hidden */
  69217. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69218. /** @hidden */
  69219. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69220. /** @hidden */
  69221. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69222. /** @hidden */
  69223. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69224. /** @hidden */
  69225. _attachCameras(cameras: Camera, unique: boolean): void;
  69226. /** @hidden */
  69227. _attachCameras(cameras: Camera[], unique: boolean): void;
  69228. /** @hidden */
  69229. _detachCameras(cameras: Camera): void;
  69230. /** @hidden */
  69231. _detachCameras(cameras: Nullable<Camera[]>): void;
  69232. /** @hidden */
  69233. _update(): void;
  69234. /** @hidden */
  69235. _reset(): void;
  69236. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69237. /**
  69238. * Disposes of the pipeline
  69239. */
  69240. dispose(): void;
  69241. }
  69242. }
  69243. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69244. import { Camera } from "babylonjs/Cameras/camera";
  69245. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69246. /**
  69247. * PostProcessRenderPipelineManager class
  69248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69249. */
  69250. export class PostProcessRenderPipelineManager {
  69251. private _renderPipelines;
  69252. /**
  69253. * Initializes a PostProcessRenderPipelineManager
  69254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69255. */
  69256. constructor();
  69257. /**
  69258. * Gets the list of supported render pipelines
  69259. */
  69260. get supportedPipelines(): PostProcessRenderPipeline[];
  69261. /**
  69262. * Adds a pipeline to the manager
  69263. * @param renderPipeline The pipeline to add
  69264. */
  69265. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69266. /**
  69267. * Attaches a camera to the pipeline
  69268. * @param renderPipelineName The name of the pipeline to attach to
  69269. * @param cameras the camera to attach
  69270. * @param unique if the camera can be attached multiple times to the pipeline
  69271. */
  69272. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69273. /**
  69274. * Detaches a camera from the pipeline
  69275. * @param renderPipelineName The name of the pipeline to detach from
  69276. * @param cameras the camera to detach
  69277. */
  69278. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69279. /**
  69280. * Enables an effect by name on a pipeline
  69281. * @param renderPipelineName the name of the pipeline to enable the effect in
  69282. * @param renderEffectName the name of the effect to enable
  69283. * @param cameras the cameras that the effect should be enabled on
  69284. */
  69285. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69286. /**
  69287. * Disables an effect by name on a pipeline
  69288. * @param renderPipelineName the name of the pipeline to disable the effect in
  69289. * @param renderEffectName the name of the effect to disable
  69290. * @param cameras the cameras that the effect should be disabled on
  69291. */
  69292. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69293. /**
  69294. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69295. */
  69296. update(): void;
  69297. /** @hidden */
  69298. _rebuild(): void;
  69299. /**
  69300. * Disposes of the manager and pipelines
  69301. */
  69302. dispose(): void;
  69303. }
  69304. }
  69305. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69306. import { ISceneComponent } from "babylonjs/sceneComponent";
  69307. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69308. import { Scene } from "babylonjs/scene";
  69309. module "babylonjs/scene" {
  69310. interface Scene {
  69311. /** @hidden (Backing field) */
  69312. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69313. /**
  69314. * Gets the postprocess render pipeline manager
  69315. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69316. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69317. */
  69318. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69319. }
  69320. }
  69321. /**
  69322. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69323. */
  69324. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69325. /**
  69326. * The component name helpfull to identify the component in the list of scene components.
  69327. */
  69328. readonly name: string;
  69329. /**
  69330. * The scene the component belongs to.
  69331. */
  69332. scene: Scene;
  69333. /**
  69334. * Creates a new instance of the component for the given scene
  69335. * @param scene Defines the scene to register the component in
  69336. */
  69337. constructor(scene: Scene);
  69338. /**
  69339. * Registers the component in a given scene
  69340. */
  69341. register(): void;
  69342. /**
  69343. * Rebuilds the elements related to this component in case of
  69344. * context lost for instance.
  69345. */
  69346. rebuild(): void;
  69347. /**
  69348. * Disposes the component and the associated ressources
  69349. */
  69350. dispose(): void;
  69351. private _gatherRenderTargets;
  69352. }
  69353. }
  69354. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69355. import { Nullable } from "babylonjs/types";
  69356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69357. import { Camera } from "babylonjs/Cameras/camera";
  69358. import { IDisposable } from "babylonjs/scene";
  69359. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69360. import { Scene } from "babylonjs/scene";
  69361. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69362. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69363. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69364. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69365. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69366. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69367. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69368. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69369. import { Animation } from "babylonjs/Animations/animation";
  69370. /**
  69371. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69372. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69373. */
  69374. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69375. private _scene;
  69376. private _camerasToBeAttached;
  69377. /**
  69378. * ID of the sharpen post process,
  69379. */
  69380. private readonly SharpenPostProcessId;
  69381. /**
  69382. * @ignore
  69383. * ID of the image processing post process;
  69384. */
  69385. readonly ImageProcessingPostProcessId: string;
  69386. /**
  69387. * @ignore
  69388. * ID of the Fast Approximate Anti-Aliasing post process;
  69389. */
  69390. readonly FxaaPostProcessId: string;
  69391. /**
  69392. * ID of the chromatic aberration post process,
  69393. */
  69394. private readonly ChromaticAberrationPostProcessId;
  69395. /**
  69396. * ID of the grain post process
  69397. */
  69398. private readonly GrainPostProcessId;
  69399. /**
  69400. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69401. */
  69402. sharpen: SharpenPostProcess;
  69403. private _sharpenEffect;
  69404. private bloom;
  69405. /**
  69406. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69407. */
  69408. depthOfField: DepthOfFieldEffect;
  69409. /**
  69410. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69411. */
  69412. fxaa: FxaaPostProcess;
  69413. /**
  69414. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69415. */
  69416. imageProcessing: ImageProcessingPostProcess;
  69417. /**
  69418. * Chromatic aberration post process which will shift rgb colors in the image
  69419. */
  69420. chromaticAberration: ChromaticAberrationPostProcess;
  69421. private _chromaticAberrationEffect;
  69422. /**
  69423. * Grain post process which add noise to the image
  69424. */
  69425. grain: GrainPostProcess;
  69426. private _grainEffect;
  69427. /**
  69428. * Glow post process which adds a glow to emissive areas of the image
  69429. */
  69430. private _glowLayer;
  69431. /**
  69432. * Animations which can be used to tweak settings over a period of time
  69433. */
  69434. animations: Animation[];
  69435. private _imageProcessingConfigurationObserver;
  69436. private _sharpenEnabled;
  69437. private _bloomEnabled;
  69438. private _depthOfFieldEnabled;
  69439. private _depthOfFieldBlurLevel;
  69440. private _fxaaEnabled;
  69441. private _imageProcessingEnabled;
  69442. private _defaultPipelineTextureType;
  69443. private _bloomScale;
  69444. private _chromaticAberrationEnabled;
  69445. private _grainEnabled;
  69446. private _buildAllowed;
  69447. /**
  69448. * Gets active scene
  69449. */
  69450. get scene(): Scene;
  69451. /**
  69452. * Enable or disable the sharpen process from the pipeline
  69453. */
  69454. set sharpenEnabled(enabled: boolean);
  69455. get sharpenEnabled(): boolean;
  69456. private _resizeObserver;
  69457. private _hardwareScaleLevel;
  69458. private _bloomKernel;
  69459. /**
  69460. * Specifies the size of the bloom blur kernel, relative to the final output size
  69461. */
  69462. get bloomKernel(): number;
  69463. set bloomKernel(value: number);
  69464. /**
  69465. * Specifies the weight of the bloom in the final rendering
  69466. */
  69467. private _bloomWeight;
  69468. /**
  69469. * Specifies the luma threshold for the area that will be blurred by the bloom
  69470. */
  69471. private _bloomThreshold;
  69472. private _hdr;
  69473. /**
  69474. * The strength of the bloom.
  69475. */
  69476. set bloomWeight(value: number);
  69477. get bloomWeight(): number;
  69478. /**
  69479. * The strength of the bloom.
  69480. */
  69481. set bloomThreshold(value: number);
  69482. get bloomThreshold(): number;
  69483. /**
  69484. * The scale of the bloom, lower value will provide better performance.
  69485. */
  69486. set bloomScale(value: number);
  69487. get bloomScale(): number;
  69488. /**
  69489. * Enable or disable the bloom from the pipeline
  69490. */
  69491. set bloomEnabled(enabled: boolean);
  69492. get bloomEnabled(): boolean;
  69493. private _rebuildBloom;
  69494. /**
  69495. * If the depth of field is enabled.
  69496. */
  69497. get depthOfFieldEnabled(): boolean;
  69498. set depthOfFieldEnabled(enabled: boolean);
  69499. /**
  69500. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69501. */
  69502. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69503. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69504. /**
  69505. * If the anti aliasing is enabled.
  69506. */
  69507. set fxaaEnabled(enabled: boolean);
  69508. get fxaaEnabled(): boolean;
  69509. private _samples;
  69510. /**
  69511. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69512. */
  69513. set samples(sampleCount: number);
  69514. get samples(): number;
  69515. /**
  69516. * If image processing is enabled.
  69517. */
  69518. set imageProcessingEnabled(enabled: boolean);
  69519. get imageProcessingEnabled(): boolean;
  69520. /**
  69521. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69522. */
  69523. set glowLayerEnabled(enabled: boolean);
  69524. get glowLayerEnabled(): boolean;
  69525. /**
  69526. * Gets the glow layer (or null if not defined)
  69527. */
  69528. get glowLayer(): Nullable<GlowLayer>;
  69529. /**
  69530. * Enable or disable the chromaticAberration process from the pipeline
  69531. */
  69532. set chromaticAberrationEnabled(enabled: boolean);
  69533. get chromaticAberrationEnabled(): boolean;
  69534. /**
  69535. * Enable or disable the grain process from the pipeline
  69536. */
  69537. set grainEnabled(enabled: boolean);
  69538. get grainEnabled(): boolean;
  69539. /**
  69540. * @constructor
  69541. * @param name - The rendering pipeline name (default: "")
  69542. * @param hdr - If high dynamic range textures should be used (default: true)
  69543. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69544. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69545. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69546. */
  69547. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69548. /**
  69549. * Get the class name
  69550. * @returns "DefaultRenderingPipeline"
  69551. */
  69552. getClassName(): string;
  69553. /**
  69554. * Force the compilation of the entire pipeline.
  69555. */
  69556. prepare(): void;
  69557. private _hasCleared;
  69558. private _prevPostProcess;
  69559. private _prevPrevPostProcess;
  69560. private _setAutoClearAndTextureSharing;
  69561. private _depthOfFieldSceneObserver;
  69562. private _buildPipeline;
  69563. private _disposePostProcesses;
  69564. /**
  69565. * Adds a camera to the pipeline
  69566. * @param camera the camera to be added
  69567. */
  69568. addCamera(camera: Camera): void;
  69569. /**
  69570. * Removes a camera from the pipeline
  69571. * @param camera the camera to remove
  69572. */
  69573. removeCamera(camera: Camera): void;
  69574. /**
  69575. * Dispose of the pipeline and stop all post processes
  69576. */
  69577. dispose(): void;
  69578. /**
  69579. * Serialize the rendering pipeline (Used when exporting)
  69580. * @returns the serialized object
  69581. */
  69582. serialize(): any;
  69583. /**
  69584. * Parse the serialized pipeline
  69585. * @param source Source pipeline.
  69586. * @param scene The scene to load the pipeline to.
  69587. * @param rootUrl The URL of the serialized pipeline.
  69588. * @returns An instantiated pipeline from the serialized object.
  69589. */
  69590. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69591. }
  69592. }
  69593. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69594. /** @hidden */
  69595. export var lensHighlightsPixelShader: {
  69596. name: string;
  69597. shader: string;
  69598. };
  69599. }
  69600. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69601. /** @hidden */
  69602. export var depthOfFieldPixelShader: {
  69603. name: string;
  69604. shader: string;
  69605. };
  69606. }
  69607. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69608. import { Camera } from "babylonjs/Cameras/camera";
  69609. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69610. import { Scene } from "babylonjs/scene";
  69611. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69612. import "babylonjs/Shaders/chromaticAberration.fragment";
  69613. import "babylonjs/Shaders/lensHighlights.fragment";
  69614. import "babylonjs/Shaders/depthOfField.fragment";
  69615. /**
  69616. * BABYLON.JS Chromatic Aberration GLSL Shader
  69617. * Author: Olivier Guyot
  69618. * Separates very slightly R, G and B colors on the edges of the screen
  69619. * Inspired by Francois Tarlier & Martins Upitis
  69620. */
  69621. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69622. /**
  69623. * @ignore
  69624. * The chromatic aberration PostProcess id in the pipeline
  69625. */
  69626. LensChromaticAberrationEffect: string;
  69627. /**
  69628. * @ignore
  69629. * The highlights enhancing PostProcess id in the pipeline
  69630. */
  69631. HighlightsEnhancingEffect: string;
  69632. /**
  69633. * @ignore
  69634. * The depth-of-field PostProcess id in the pipeline
  69635. */
  69636. LensDepthOfFieldEffect: string;
  69637. private _scene;
  69638. private _depthTexture;
  69639. private _grainTexture;
  69640. private _chromaticAberrationPostProcess;
  69641. private _highlightsPostProcess;
  69642. private _depthOfFieldPostProcess;
  69643. private _edgeBlur;
  69644. private _grainAmount;
  69645. private _chromaticAberration;
  69646. private _distortion;
  69647. private _highlightsGain;
  69648. private _highlightsThreshold;
  69649. private _dofDistance;
  69650. private _dofAperture;
  69651. private _dofDarken;
  69652. private _dofPentagon;
  69653. private _blurNoise;
  69654. /**
  69655. * @constructor
  69656. *
  69657. * Effect parameters are as follow:
  69658. * {
  69659. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69660. * edge_blur: number; // from 0 to x (1 for realism)
  69661. * distortion: number; // from 0 to x (1 for realism)
  69662. * grain_amount: number; // from 0 to 1
  69663. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69664. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69665. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69666. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69667. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69668. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69669. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69670. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69671. * }
  69672. * Note: if an effect parameter is unset, effect is disabled
  69673. *
  69674. * @param name The rendering pipeline name
  69675. * @param parameters - An object containing all parameters (see above)
  69676. * @param scene The scene linked to this pipeline
  69677. * @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)
  69678. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69679. */
  69680. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69681. /**
  69682. * Get the class name
  69683. * @returns "LensRenderingPipeline"
  69684. */
  69685. getClassName(): string;
  69686. /**
  69687. * Gets associated scene
  69688. */
  69689. get scene(): Scene;
  69690. /**
  69691. * Gets or sets the edge blur
  69692. */
  69693. get edgeBlur(): number;
  69694. set edgeBlur(value: number);
  69695. /**
  69696. * Gets or sets the grain amount
  69697. */
  69698. get grainAmount(): number;
  69699. set grainAmount(value: number);
  69700. /**
  69701. * Gets or sets the chromatic aberration amount
  69702. */
  69703. get chromaticAberration(): number;
  69704. set chromaticAberration(value: number);
  69705. /**
  69706. * Gets or sets the depth of field aperture
  69707. */
  69708. get dofAperture(): number;
  69709. set dofAperture(value: number);
  69710. /**
  69711. * Gets or sets the edge distortion
  69712. */
  69713. get edgeDistortion(): number;
  69714. set edgeDistortion(value: number);
  69715. /**
  69716. * Gets or sets the depth of field distortion
  69717. */
  69718. get dofDistortion(): number;
  69719. set dofDistortion(value: number);
  69720. /**
  69721. * Gets or sets the darken out of focus amount
  69722. */
  69723. get darkenOutOfFocus(): number;
  69724. set darkenOutOfFocus(value: number);
  69725. /**
  69726. * Gets or sets a boolean indicating if blur noise is enabled
  69727. */
  69728. get blurNoise(): boolean;
  69729. set blurNoise(value: boolean);
  69730. /**
  69731. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69732. */
  69733. get pentagonBokeh(): boolean;
  69734. set pentagonBokeh(value: boolean);
  69735. /**
  69736. * Gets or sets the highlight grain amount
  69737. */
  69738. get highlightsGain(): number;
  69739. set highlightsGain(value: number);
  69740. /**
  69741. * Gets or sets the highlight threshold
  69742. */
  69743. get highlightsThreshold(): number;
  69744. set highlightsThreshold(value: number);
  69745. /**
  69746. * Sets the amount of blur at the edges
  69747. * @param amount blur amount
  69748. */
  69749. setEdgeBlur(amount: number): void;
  69750. /**
  69751. * Sets edge blur to 0
  69752. */
  69753. disableEdgeBlur(): void;
  69754. /**
  69755. * Sets the amout of grain
  69756. * @param amount Amount of grain
  69757. */
  69758. setGrainAmount(amount: number): void;
  69759. /**
  69760. * Set grain amount to 0
  69761. */
  69762. disableGrain(): void;
  69763. /**
  69764. * Sets the chromatic aberration amount
  69765. * @param amount amount of chromatic aberration
  69766. */
  69767. setChromaticAberration(amount: number): void;
  69768. /**
  69769. * Sets chromatic aberration amount to 0
  69770. */
  69771. disableChromaticAberration(): void;
  69772. /**
  69773. * Sets the EdgeDistortion amount
  69774. * @param amount amount of EdgeDistortion
  69775. */
  69776. setEdgeDistortion(amount: number): void;
  69777. /**
  69778. * Sets edge distortion to 0
  69779. */
  69780. disableEdgeDistortion(): void;
  69781. /**
  69782. * Sets the FocusDistance amount
  69783. * @param amount amount of FocusDistance
  69784. */
  69785. setFocusDistance(amount: number): void;
  69786. /**
  69787. * Disables depth of field
  69788. */
  69789. disableDepthOfField(): void;
  69790. /**
  69791. * Sets the Aperture amount
  69792. * @param amount amount of Aperture
  69793. */
  69794. setAperture(amount: number): void;
  69795. /**
  69796. * Sets the DarkenOutOfFocus amount
  69797. * @param amount amount of DarkenOutOfFocus
  69798. */
  69799. setDarkenOutOfFocus(amount: number): void;
  69800. private _pentagonBokehIsEnabled;
  69801. /**
  69802. * Creates a pentagon bokeh effect
  69803. */
  69804. enablePentagonBokeh(): void;
  69805. /**
  69806. * Disables the pentagon bokeh effect
  69807. */
  69808. disablePentagonBokeh(): void;
  69809. /**
  69810. * Enables noise blur
  69811. */
  69812. enableNoiseBlur(): void;
  69813. /**
  69814. * Disables noise blur
  69815. */
  69816. disableNoiseBlur(): void;
  69817. /**
  69818. * Sets the HighlightsGain amount
  69819. * @param amount amount of HighlightsGain
  69820. */
  69821. setHighlightsGain(amount: number): void;
  69822. /**
  69823. * Sets the HighlightsThreshold amount
  69824. * @param amount amount of HighlightsThreshold
  69825. */
  69826. setHighlightsThreshold(amount: number): void;
  69827. /**
  69828. * Disables highlights
  69829. */
  69830. disableHighlights(): void;
  69831. /**
  69832. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69833. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69834. */
  69835. dispose(disableDepthRender?: boolean): void;
  69836. private _createChromaticAberrationPostProcess;
  69837. private _createHighlightsPostProcess;
  69838. private _createDepthOfFieldPostProcess;
  69839. private _createGrainTexture;
  69840. }
  69841. }
  69842. declare module "babylonjs/Shaders/ssao2.fragment" {
  69843. /** @hidden */
  69844. export var ssao2PixelShader: {
  69845. name: string;
  69846. shader: string;
  69847. };
  69848. }
  69849. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69850. /** @hidden */
  69851. export var ssaoCombinePixelShader: {
  69852. name: string;
  69853. shader: string;
  69854. };
  69855. }
  69856. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69857. import { Camera } from "babylonjs/Cameras/camera";
  69858. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69859. import { Scene } from "babylonjs/scene";
  69860. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69861. import "babylonjs/Shaders/ssao2.fragment";
  69862. import "babylonjs/Shaders/ssaoCombine.fragment";
  69863. /**
  69864. * Render pipeline to produce ssao effect
  69865. */
  69866. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69867. /**
  69868. * @ignore
  69869. * The PassPostProcess id in the pipeline that contains the original scene color
  69870. */
  69871. SSAOOriginalSceneColorEffect: string;
  69872. /**
  69873. * @ignore
  69874. * The SSAO PostProcess id in the pipeline
  69875. */
  69876. SSAORenderEffect: string;
  69877. /**
  69878. * @ignore
  69879. * The horizontal blur PostProcess id in the pipeline
  69880. */
  69881. SSAOBlurHRenderEffect: string;
  69882. /**
  69883. * @ignore
  69884. * The vertical blur PostProcess id in the pipeline
  69885. */
  69886. SSAOBlurVRenderEffect: string;
  69887. /**
  69888. * @ignore
  69889. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69890. */
  69891. SSAOCombineRenderEffect: string;
  69892. /**
  69893. * The output strength of the SSAO post-process. Default value is 1.0.
  69894. */
  69895. totalStrength: number;
  69896. /**
  69897. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69898. */
  69899. maxZ: number;
  69900. /**
  69901. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69902. */
  69903. minZAspect: number;
  69904. private _samples;
  69905. /**
  69906. * Number of samples used for the SSAO calculations. Default value is 8
  69907. */
  69908. set samples(n: number);
  69909. get samples(): number;
  69910. private _textureSamples;
  69911. /**
  69912. * Number of samples to use for antialiasing
  69913. */
  69914. set textureSamples(n: number);
  69915. get textureSamples(): number;
  69916. /**
  69917. * Ratio object used for SSAO ratio and blur ratio
  69918. */
  69919. private _ratio;
  69920. /**
  69921. * Dynamically generated sphere sampler.
  69922. */
  69923. private _sampleSphere;
  69924. /**
  69925. * Blur filter offsets
  69926. */
  69927. private _samplerOffsets;
  69928. private _expensiveBlur;
  69929. /**
  69930. * If bilateral blur should be used
  69931. */
  69932. set expensiveBlur(b: boolean);
  69933. get expensiveBlur(): boolean;
  69934. /**
  69935. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69936. */
  69937. radius: number;
  69938. /**
  69939. * The base color of the SSAO post-process
  69940. * The final result is "base + ssao" between [0, 1]
  69941. */
  69942. base: number;
  69943. /**
  69944. * Support test.
  69945. */
  69946. static get IsSupported(): boolean;
  69947. private _scene;
  69948. private _depthTexture;
  69949. private _normalTexture;
  69950. private _randomTexture;
  69951. private _originalColorPostProcess;
  69952. private _ssaoPostProcess;
  69953. private _blurHPostProcess;
  69954. private _blurVPostProcess;
  69955. private _ssaoCombinePostProcess;
  69956. /**
  69957. * Gets active scene
  69958. */
  69959. get scene(): Scene;
  69960. /**
  69961. * @constructor
  69962. * @param name The rendering pipeline name
  69963. * @param scene The scene linked to this pipeline
  69964. * @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 }
  69965. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69966. */
  69967. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69968. /**
  69969. * Get the class name
  69970. * @returns "SSAO2RenderingPipeline"
  69971. */
  69972. getClassName(): string;
  69973. /**
  69974. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69975. */
  69976. dispose(disableGeometryBufferRenderer?: boolean): void;
  69977. private _createBlurPostProcess;
  69978. /** @hidden */
  69979. _rebuild(): void;
  69980. private _bits;
  69981. private _radicalInverse_VdC;
  69982. private _hammersley;
  69983. private _hemisphereSample_uniform;
  69984. private _generateHemisphere;
  69985. private _createSSAOPostProcess;
  69986. private _createSSAOCombinePostProcess;
  69987. private _createRandomTexture;
  69988. /**
  69989. * Serialize the rendering pipeline (Used when exporting)
  69990. * @returns the serialized object
  69991. */
  69992. serialize(): any;
  69993. /**
  69994. * Parse the serialized pipeline
  69995. * @param source Source pipeline.
  69996. * @param scene The scene to load the pipeline to.
  69997. * @param rootUrl The URL of the serialized pipeline.
  69998. * @returns An instantiated pipeline from the serialized object.
  69999. */
  70000. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70001. }
  70002. }
  70003. declare module "babylonjs/Shaders/ssao.fragment" {
  70004. /** @hidden */
  70005. export var ssaoPixelShader: {
  70006. name: string;
  70007. shader: string;
  70008. };
  70009. }
  70010. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  70011. import { Camera } from "babylonjs/Cameras/camera";
  70012. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70013. import { Scene } from "babylonjs/scene";
  70014. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70015. import "babylonjs/Shaders/ssao.fragment";
  70016. import "babylonjs/Shaders/ssaoCombine.fragment";
  70017. /**
  70018. * Render pipeline to produce ssao effect
  70019. */
  70020. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70021. /**
  70022. * @ignore
  70023. * The PassPostProcess id in the pipeline that contains the original scene color
  70024. */
  70025. SSAOOriginalSceneColorEffect: string;
  70026. /**
  70027. * @ignore
  70028. * The SSAO PostProcess id in the pipeline
  70029. */
  70030. SSAORenderEffect: string;
  70031. /**
  70032. * @ignore
  70033. * The horizontal blur PostProcess id in the pipeline
  70034. */
  70035. SSAOBlurHRenderEffect: string;
  70036. /**
  70037. * @ignore
  70038. * The vertical blur PostProcess id in the pipeline
  70039. */
  70040. SSAOBlurVRenderEffect: string;
  70041. /**
  70042. * @ignore
  70043. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70044. */
  70045. SSAOCombineRenderEffect: string;
  70046. /**
  70047. * The output strength of the SSAO post-process. Default value is 1.0.
  70048. */
  70049. totalStrength: number;
  70050. /**
  70051. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70052. */
  70053. radius: number;
  70054. /**
  70055. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70056. * Must not be equal to fallOff and superior to fallOff.
  70057. * Default value is 0.0075
  70058. */
  70059. area: number;
  70060. /**
  70061. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70062. * Must not be equal to area and inferior to area.
  70063. * Default value is 0.000001
  70064. */
  70065. fallOff: number;
  70066. /**
  70067. * The base color of the SSAO post-process
  70068. * The final result is "base + ssao" between [0, 1]
  70069. */
  70070. base: number;
  70071. private _scene;
  70072. private _depthTexture;
  70073. private _randomTexture;
  70074. private _originalColorPostProcess;
  70075. private _ssaoPostProcess;
  70076. private _blurHPostProcess;
  70077. private _blurVPostProcess;
  70078. private _ssaoCombinePostProcess;
  70079. private _firstUpdate;
  70080. /**
  70081. * Gets active scene
  70082. */
  70083. get scene(): Scene;
  70084. /**
  70085. * @constructor
  70086. * @param name - The rendering pipeline name
  70087. * @param scene - The scene linked to this pipeline
  70088. * @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 }
  70089. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70090. */
  70091. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70092. /**
  70093. * Get the class name
  70094. * @returns "SSAORenderingPipeline"
  70095. */
  70096. getClassName(): string;
  70097. /**
  70098. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70099. */
  70100. dispose(disableDepthRender?: boolean): void;
  70101. private _createBlurPostProcess;
  70102. /** @hidden */
  70103. _rebuild(): void;
  70104. private _createSSAOPostProcess;
  70105. private _createSSAOCombinePostProcess;
  70106. private _createRandomTexture;
  70107. }
  70108. }
  70109. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70110. /** @hidden */
  70111. export var screenSpaceReflectionPixelShader: {
  70112. name: string;
  70113. shader: string;
  70114. };
  70115. }
  70116. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70117. import { Nullable } from "babylonjs/types";
  70118. import { Camera } from "babylonjs/Cameras/camera";
  70119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70120. import { Scene } from "babylonjs/scene";
  70121. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70122. import { Engine } from "babylonjs/Engines/engine";
  70123. /**
  70124. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70125. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70126. */
  70127. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70128. /**
  70129. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70130. */
  70131. threshold: number;
  70132. /**
  70133. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70134. */
  70135. strength: number;
  70136. /**
  70137. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70138. */
  70139. reflectionSpecularFalloffExponent: number;
  70140. /**
  70141. * 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]
  70142. */
  70143. step: number;
  70144. /**
  70145. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70146. */
  70147. roughnessFactor: number;
  70148. private _geometryBufferRenderer;
  70149. private _enableSmoothReflections;
  70150. private _reflectionSamples;
  70151. private _smoothSteps;
  70152. /**
  70153. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70154. * @param name The name of the effect.
  70155. * @param scene The scene containing the objects to calculate reflections.
  70156. * @param options The required width/height ratio to downsize to before computing the render pass.
  70157. * @param camera The camera to apply the render pass to.
  70158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70159. * @param engine The engine which the post process will be applied. (default: current engine)
  70160. * @param reusable If the post process can be reused on the same frame. (default: false)
  70161. * @param textureType Type of textures used when performing the post process. (default: 0)
  70162. * @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)
  70163. */
  70164. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70165. /**
  70166. * Gets wether or not smoothing reflections is enabled.
  70167. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70168. */
  70169. get enableSmoothReflections(): boolean;
  70170. /**
  70171. * Sets wether or not smoothing reflections is enabled.
  70172. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70173. */
  70174. set enableSmoothReflections(enabled: boolean);
  70175. /**
  70176. * Gets the number of samples taken while computing reflections. More samples count is high,
  70177. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70178. */
  70179. get reflectionSamples(): number;
  70180. /**
  70181. * Sets the number of samples taken while computing reflections. More samples count is high,
  70182. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70183. */
  70184. set reflectionSamples(samples: number);
  70185. /**
  70186. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70187. * more the post-process will require GPU power and can generate a drop in FPS.
  70188. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70189. */
  70190. get smoothSteps(): number;
  70191. set smoothSteps(steps: number);
  70192. private _updateEffectDefines;
  70193. }
  70194. }
  70195. declare module "babylonjs/Shaders/standard.fragment" {
  70196. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70197. /** @hidden */
  70198. export var standardPixelShader: {
  70199. name: string;
  70200. shader: string;
  70201. };
  70202. }
  70203. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70204. import { Nullable } from "babylonjs/types";
  70205. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70206. import { Camera } from "babylonjs/Cameras/camera";
  70207. import { Texture } from "babylonjs/Materials/Textures/texture";
  70208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70209. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70210. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70211. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70212. import { IDisposable } from "babylonjs/scene";
  70213. import { SpotLight } from "babylonjs/Lights/spotLight";
  70214. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70215. import { Scene } from "babylonjs/scene";
  70216. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70217. import { Animation } from "babylonjs/Animations/animation";
  70218. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70219. import "babylonjs/Shaders/standard.fragment";
  70220. /**
  70221. * Standard rendering pipeline
  70222. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70223. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70224. */
  70225. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70226. /**
  70227. * Public members
  70228. */
  70229. /**
  70230. * Post-process which contains the original scene color before the pipeline applies all the effects
  70231. */
  70232. originalPostProcess: Nullable<PostProcess>;
  70233. /**
  70234. * Post-process used to down scale an image x4
  70235. */
  70236. downSampleX4PostProcess: Nullable<PostProcess>;
  70237. /**
  70238. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70239. */
  70240. brightPassPostProcess: Nullable<PostProcess>;
  70241. /**
  70242. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70243. */
  70244. blurHPostProcesses: PostProcess[];
  70245. /**
  70246. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70247. */
  70248. blurVPostProcesses: PostProcess[];
  70249. /**
  70250. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70251. */
  70252. textureAdderPostProcess: Nullable<PostProcess>;
  70253. /**
  70254. * Post-process used to create volumetric lighting effect
  70255. */
  70256. volumetricLightPostProcess: Nullable<PostProcess>;
  70257. /**
  70258. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70259. */
  70260. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70261. /**
  70262. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70263. */
  70264. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70265. /**
  70266. * Post-process used to merge the volumetric light effect and the real scene color
  70267. */
  70268. volumetricLightMergePostProces: Nullable<PostProcess>;
  70269. /**
  70270. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70271. */
  70272. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70273. /**
  70274. * Base post-process used to calculate the average luminance of the final image for HDR
  70275. */
  70276. luminancePostProcess: Nullable<PostProcess>;
  70277. /**
  70278. * Post-processes used to create down sample post-processes in order to get
  70279. * the average luminance of the final image for HDR
  70280. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70281. */
  70282. luminanceDownSamplePostProcesses: PostProcess[];
  70283. /**
  70284. * Post-process used to create a HDR effect (light adaptation)
  70285. */
  70286. hdrPostProcess: Nullable<PostProcess>;
  70287. /**
  70288. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70289. */
  70290. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70291. /**
  70292. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70293. */
  70294. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70295. /**
  70296. * Post-process used to merge the final HDR post-process and the real scene color
  70297. */
  70298. hdrFinalPostProcess: Nullable<PostProcess>;
  70299. /**
  70300. * Post-process used to create a lens flare effect
  70301. */
  70302. lensFlarePostProcess: Nullable<PostProcess>;
  70303. /**
  70304. * Post-process that merges the result of the lens flare post-process and the real scene color
  70305. */
  70306. lensFlareComposePostProcess: Nullable<PostProcess>;
  70307. /**
  70308. * Post-process used to create a motion blur effect
  70309. */
  70310. motionBlurPostProcess: Nullable<PostProcess>;
  70311. /**
  70312. * Post-process used to create a depth of field effect
  70313. */
  70314. depthOfFieldPostProcess: Nullable<PostProcess>;
  70315. /**
  70316. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70317. */
  70318. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70319. /**
  70320. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70321. */
  70322. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70323. /**
  70324. * Represents the brightness threshold in order to configure the illuminated surfaces
  70325. */
  70326. brightThreshold: number;
  70327. /**
  70328. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70329. */
  70330. blurWidth: number;
  70331. /**
  70332. * Sets if the blur for highlighted surfaces must be only horizontal
  70333. */
  70334. horizontalBlur: boolean;
  70335. /**
  70336. * Gets the overall exposure used by the pipeline
  70337. */
  70338. get exposure(): number;
  70339. /**
  70340. * Sets the overall exposure used by the pipeline
  70341. */
  70342. set exposure(value: number);
  70343. /**
  70344. * Texture used typically to simulate "dirty" on camera lens
  70345. */
  70346. lensTexture: Nullable<Texture>;
  70347. /**
  70348. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70349. */
  70350. volumetricLightCoefficient: number;
  70351. /**
  70352. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70353. */
  70354. volumetricLightPower: number;
  70355. /**
  70356. * Used the set the blur intensity to smooth the volumetric lights
  70357. */
  70358. volumetricLightBlurScale: number;
  70359. /**
  70360. * Light (spot or directional) used to generate the volumetric lights rays
  70361. * The source light must have a shadow generate so the pipeline can get its
  70362. * depth map
  70363. */
  70364. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70365. /**
  70366. * For eye adaptation, represents the minimum luminance the eye can see
  70367. */
  70368. hdrMinimumLuminance: number;
  70369. /**
  70370. * For eye adaptation, represents the decrease luminance speed
  70371. */
  70372. hdrDecreaseRate: number;
  70373. /**
  70374. * For eye adaptation, represents the increase luminance speed
  70375. */
  70376. hdrIncreaseRate: number;
  70377. /**
  70378. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70379. */
  70380. get hdrAutoExposure(): boolean;
  70381. /**
  70382. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70383. */
  70384. set hdrAutoExposure(value: boolean);
  70385. /**
  70386. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70387. */
  70388. lensColorTexture: Nullable<Texture>;
  70389. /**
  70390. * The overall strengh for the lens flare effect
  70391. */
  70392. lensFlareStrength: number;
  70393. /**
  70394. * Dispersion coefficient for lens flare ghosts
  70395. */
  70396. lensFlareGhostDispersal: number;
  70397. /**
  70398. * Main lens flare halo width
  70399. */
  70400. lensFlareHaloWidth: number;
  70401. /**
  70402. * Based on the lens distortion effect, defines how much the lens flare result
  70403. * is distorted
  70404. */
  70405. lensFlareDistortionStrength: number;
  70406. /**
  70407. * Configures the blur intensity used for for lens flare (halo)
  70408. */
  70409. lensFlareBlurWidth: number;
  70410. /**
  70411. * Lens star texture must be used to simulate rays on the flares and is available
  70412. * in the documentation
  70413. */
  70414. lensStarTexture: Nullable<Texture>;
  70415. /**
  70416. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70417. * flare effect by taking account of the dirt texture
  70418. */
  70419. lensFlareDirtTexture: Nullable<Texture>;
  70420. /**
  70421. * Represents the focal length for the depth of field effect
  70422. */
  70423. depthOfFieldDistance: number;
  70424. /**
  70425. * Represents the blur intensity for the blurred part of the depth of field effect
  70426. */
  70427. depthOfFieldBlurWidth: number;
  70428. /**
  70429. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70430. */
  70431. get motionStrength(): number;
  70432. /**
  70433. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70434. */
  70435. set motionStrength(strength: number);
  70436. /**
  70437. * Gets wether or not the motion blur post-process is object based or screen based.
  70438. */
  70439. get objectBasedMotionBlur(): boolean;
  70440. /**
  70441. * Sets wether or not the motion blur post-process should be object based or screen based
  70442. */
  70443. set objectBasedMotionBlur(value: boolean);
  70444. /**
  70445. * List of animations for the pipeline (IAnimatable implementation)
  70446. */
  70447. animations: Animation[];
  70448. /**
  70449. * Private members
  70450. */
  70451. private _scene;
  70452. private _currentDepthOfFieldSource;
  70453. private _basePostProcess;
  70454. private _fixedExposure;
  70455. private _currentExposure;
  70456. private _hdrAutoExposure;
  70457. private _hdrCurrentLuminance;
  70458. private _motionStrength;
  70459. private _isObjectBasedMotionBlur;
  70460. private _floatTextureType;
  70461. private _camerasToBeAttached;
  70462. private _ratio;
  70463. private _bloomEnabled;
  70464. private _depthOfFieldEnabled;
  70465. private _vlsEnabled;
  70466. private _lensFlareEnabled;
  70467. private _hdrEnabled;
  70468. private _motionBlurEnabled;
  70469. private _fxaaEnabled;
  70470. private _screenSpaceReflectionsEnabled;
  70471. private _motionBlurSamples;
  70472. private _volumetricLightStepsCount;
  70473. private _samples;
  70474. /**
  70475. * @ignore
  70476. * Specifies if the bloom pipeline is enabled
  70477. */
  70478. get BloomEnabled(): boolean;
  70479. set BloomEnabled(enabled: boolean);
  70480. /**
  70481. * @ignore
  70482. * Specifies if the depth of field pipeline is enabed
  70483. */
  70484. get DepthOfFieldEnabled(): boolean;
  70485. set DepthOfFieldEnabled(enabled: boolean);
  70486. /**
  70487. * @ignore
  70488. * Specifies if the lens flare pipeline is enabed
  70489. */
  70490. get LensFlareEnabled(): boolean;
  70491. set LensFlareEnabled(enabled: boolean);
  70492. /**
  70493. * @ignore
  70494. * Specifies if the HDR pipeline is enabled
  70495. */
  70496. get HDREnabled(): boolean;
  70497. set HDREnabled(enabled: boolean);
  70498. /**
  70499. * @ignore
  70500. * Specifies if the volumetric lights scattering effect is enabled
  70501. */
  70502. get VLSEnabled(): boolean;
  70503. set VLSEnabled(enabled: boolean);
  70504. /**
  70505. * @ignore
  70506. * Specifies if the motion blur effect is enabled
  70507. */
  70508. get MotionBlurEnabled(): boolean;
  70509. set MotionBlurEnabled(enabled: boolean);
  70510. /**
  70511. * Specifies if anti-aliasing is enabled
  70512. */
  70513. get fxaaEnabled(): boolean;
  70514. set fxaaEnabled(enabled: boolean);
  70515. /**
  70516. * Specifies if screen space reflections are enabled.
  70517. */
  70518. get screenSpaceReflectionsEnabled(): boolean;
  70519. set screenSpaceReflectionsEnabled(enabled: boolean);
  70520. /**
  70521. * Specifies the number of steps used to calculate the volumetric lights
  70522. * Typically in interval [50, 200]
  70523. */
  70524. get volumetricLightStepsCount(): number;
  70525. set volumetricLightStepsCount(count: number);
  70526. /**
  70527. * Specifies the number of samples used for the motion blur effect
  70528. * Typically in interval [16, 64]
  70529. */
  70530. get motionBlurSamples(): number;
  70531. set motionBlurSamples(samples: number);
  70532. /**
  70533. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70534. */
  70535. get samples(): number;
  70536. set samples(sampleCount: number);
  70537. /**
  70538. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70539. * @constructor
  70540. * @param name The rendering pipeline name
  70541. * @param scene The scene linked to this pipeline
  70542. * @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)
  70543. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70544. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70545. */
  70546. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70547. private _buildPipeline;
  70548. private _createDownSampleX4PostProcess;
  70549. private _createBrightPassPostProcess;
  70550. private _createBlurPostProcesses;
  70551. private _createTextureAdderPostProcess;
  70552. private _createVolumetricLightPostProcess;
  70553. private _createLuminancePostProcesses;
  70554. private _createHdrPostProcess;
  70555. private _createLensFlarePostProcess;
  70556. private _createDepthOfFieldPostProcess;
  70557. private _createMotionBlurPostProcess;
  70558. private _getDepthTexture;
  70559. private _disposePostProcesses;
  70560. /**
  70561. * Dispose of the pipeline and stop all post processes
  70562. */
  70563. dispose(): void;
  70564. /**
  70565. * Serialize the rendering pipeline (Used when exporting)
  70566. * @returns the serialized object
  70567. */
  70568. serialize(): any;
  70569. /**
  70570. * Parse the serialized pipeline
  70571. * @param source Source pipeline.
  70572. * @param scene The scene to load the pipeline to.
  70573. * @param rootUrl The URL of the serialized pipeline.
  70574. * @returns An instantiated pipeline from the serialized object.
  70575. */
  70576. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70577. /**
  70578. * Luminance steps
  70579. */
  70580. static LuminanceSteps: number;
  70581. }
  70582. }
  70583. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70584. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70585. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70586. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70587. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70588. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70589. }
  70590. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70591. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70592. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70593. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70594. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70595. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70596. }
  70597. declare module "babylonjs/Shaders/tonemap.fragment" {
  70598. /** @hidden */
  70599. export var tonemapPixelShader: {
  70600. name: string;
  70601. shader: string;
  70602. };
  70603. }
  70604. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70605. import { Camera } from "babylonjs/Cameras/camera";
  70606. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70607. import "babylonjs/Shaders/tonemap.fragment";
  70608. import { Engine } from "babylonjs/Engines/engine";
  70609. /** Defines operator used for tonemapping */
  70610. export enum TonemappingOperator {
  70611. /** Hable */
  70612. Hable = 0,
  70613. /** Reinhard */
  70614. Reinhard = 1,
  70615. /** HejiDawson */
  70616. HejiDawson = 2,
  70617. /** Photographic */
  70618. Photographic = 3
  70619. }
  70620. /**
  70621. * Defines a post process to apply tone mapping
  70622. */
  70623. export class TonemapPostProcess extends PostProcess {
  70624. private _operator;
  70625. /** Defines the required exposure adjustement */
  70626. exposureAdjustment: number;
  70627. /**
  70628. * Creates a new TonemapPostProcess
  70629. * @param name defines the name of the postprocess
  70630. * @param _operator defines the operator to use
  70631. * @param exposureAdjustment defines the required exposure adjustement
  70632. * @param camera defines the camera to use (can be null)
  70633. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70634. * @param engine defines the hosting engine (can be ignore if camera is set)
  70635. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70636. */
  70637. constructor(name: string, _operator: TonemappingOperator,
  70638. /** Defines the required exposure adjustement */
  70639. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70640. }
  70641. }
  70642. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70643. /** @hidden */
  70644. export var volumetricLightScatteringPixelShader: {
  70645. name: string;
  70646. shader: string;
  70647. };
  70648. }
  70649. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70650. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70651. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70652. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70653. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70654. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70655. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70656. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70657. /** @hidden */
  70658. export var volumetricLightScatteringPassVertexShader: {
  70659. name: string;
  70660. shader: string;
  70661. };
  70662. }
  70663. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70664. /** @hidden */
  70665. export var volumetricLightScatteringPassPixelShader: {
  70666. name: string;
  70667. shader: string;
  70668. };
  70669. }
  70670. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70671. import { Vector3 } from "babylonjs/Maths/math.vector";
  70672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70673. import { Mesh } from "babylonjs/Meshes/mesh";
  70674. import { Camera } from "babylonjs/Cameras/camera";
  70675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70676. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70677. import { Scene } from "babylonjs/scene";
  70678. import "babylonjs/Meshes/Builders/planeBuilder";
  70679. import "babylonjs/Shaders/depth.vertex";
  70680. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70681. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70682. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70683. import { Engine } from "babylonjs/Engines/engine";
  70684. /**
  70685. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70686. */
  70687. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70688. private _volumetricLightScatteringPass;
  70689. private _volumetricLightScatteringRTT;
  70690. private _viewPort;
  70691. private _screenCoordinates;
  70692. private _cachedDefines;
  70693. /**
  70694. * If not undefined, the mesh position is computed from the attached node position
  70695. */
  70696. attachedNode: {
  70697. position: Vector3;
  70698. };
  70699. /**
  70700. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70701. */
  70702. customMeshPosition: Vector3;
  70703. /**
  70704. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70705. */
  70706. useCustomMeshPosition: boolean;
  70707. /**
  70708. * If the post-process should inverse the light scattering direction
  70709. */
  70710. invert: boolean;
  70711. /**
  70712. * The internal mesh used by the post-process
  70713. */
  70714. mesh: Mesh;
  70715. /**
  70716. * @hidden
  70717. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70718. */
  70719. get useDiffuseColor(): boolean;
  70720. set useDiffuseColor(useDiffuseColor: boolean);
  70721. /**
  70722. * Array containing the excluded meshes not rendered in the internal pass
  70723. */
  70724. excludedMeshes: AbstractMesh[];
  70725. /**
  70726. * Controls the overall intensity of the post-process
  70727. */
  70728. exposure: number;
  70729. /**
  70730. * Dissipates each sample's contribution in range [0, 1]
  70731. */
  70732. decay: number;
  70733. /**
  70734. * Controls the overall intensity of each sample
  70735. */
  70736. weight: number;
  70737. /**
  70738. * Controls the density of each sample
  70739. */
  70740. density: number;
  70741. /**
  70742. * @constructor
  70743. * @param name The post-process name
  70744. * @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)
  70745. * @param camera The camera that the post-process will be attached to
  70746. * @param mesh The mesh used to create the light scattering
  70747. * @param samples The post-process quality, default 100
  70748. * @param samplingModeThe post-process filtering mode
  70749. * @param engine The babylon engine
  70750. * @param reusable If the post-process is reusable
  70751. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70752. */
  70753. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70754. /**
  70755. * Returns the string "VolumetricLightScatteringPostProcess"
  70756. * @returns "VolumetricLightScatteringPostProcess"
  70757. */
  70758. getClassName(): string;
  70759. private _isReady;
  70760. /**
  70761. * Sets the new light position for light scattering effect
  70762. * @param position The new custom light position
  70763. */
  70764. setCustomMeshPosition(position: Vector3): void;
  70765. /**
  70766. * Returns the light position for light scattering effect
  70767. * @return Vector3 The custom light position
  70768. */
  70769. getCustomMeshPosition(): Vector3;
  70770. /**
  70771. * Disposes the internal assets and detaches the post-process from the camera
  70772. */
  70773. dispose(camera: Camera): void;
  70774. /**
  70775. * Returns the render target texture used by the post-process
  70776. * @return the render target texture used by the post-process
  70777. */
  70778. getPass(): RenderTargetTexture;
  70779. private _meshExcluded;
  70780. private _createPass;
  70781. private _updateMeshScreenCoordinates;
  70782. /**
  70783. * Creates a default mesh for the Volumeric Light Scattering post-process
  70784. * @param name The mesh name
  70785. * @param scene The scene where to create the mesh
  70786. * @return the default mesh
  70787. */
  70788. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70789. }
  70790. }
  70791. declare module "babylonjs/PostProcesses/index" {
  70792. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70793. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70794. export * from "babylonjs/PostProcesses/bloomEffect";
  70795. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70796. export * from "babylonjs/PostProcesses/blurPostProcess";
  70797. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70798. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70799. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70800. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70801. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70802. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70803. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70804. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70805. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70806. export * from "babylonjs/PostProcesses/filterPostProcess";
  70807. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70808. export * from "babylonjs/PostProcesses/grainPostProcess";
  70809. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70810. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70811. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70812. export * from "babylonjs/PostProcesses/passPostProcess";
  70813. export * from "babylonjs/PostProcesses/postProcess";
  70814. export * from "babylonjs/PostProcesses/postProcessManager";
  70815. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70816. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70817. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70818. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70819. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70820. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70821. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70822. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70823. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70824. }
  70825. declare module "babylonjs/Probes/index" {
  70826. export * from "babylonjs/Probes/reflectionProbe";
  70827. }
  70828. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70829. import { Scene } from "babylonjs/scene";
  70830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70831. import { SmartArray } from "babylonjs/Misc/smartArray";
  70832. import { ISceneComponent } from "babylonjs/sceneComponent";
  70833. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70834. import "babylonjs/Meshes/Builders/boxBuilder";
  70835. import "babylonjs/Shaders/color.fragment";
  70836. import "babylonjs/Shaders/color.vertex";
  70837. import { Color3 } from "babylonjs/Maths/math.color";
  70838. module "babylonjs/scene" {
  70839. interface Scene {
  70840. /** @hidden (Backing field) */
  70841. _boundingBoxRenderer: BoundingBoxRenderer;
  70842. /** @hidden (Backing field) */
  70843. _forceShowBoundingBoxes: boolean;
  70844. /**
  70845. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70846. */
  70847. forceShowBoundingBoxes: boolean;
  70848. /**
  70849. * Gets the bounding box renderer associated with the scene
  70850. * @returns a BoundingBoxRenderer
  70851. */
  70852. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70853. }
  70854. }
  70855. module "babylonjs/Meshes/abstractMesh" {
  70856. interface AbstractMesh {
  70857. /** @hidden (Backing field) */
  70858. _showBoundingBox: boolean;
  70859. /**
  70860. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70861. */
  70862. showBoundingBox: boolean;
  70863. }
  70864. }
  70865. /**
  70866. * Component responsible of rendering the bounding box of the meshes in a scene.
  70867. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70868. */
  70869. export class BoundingBoxRenderer implements ISceneComponent {
  70870. /**
  70871. * The component name helpfull to identify the component in the list of scene components.
  70872. */
  70873. readonly name: string;
  70874. /**
  70875. * The scene the component belongs to.
  70876. */
  70877. scene: Scene;
  70878. /**
  70879. * Color of the bounding box lines placed in front of an object
  70880. */
  70881. frontColor: Color3;
  70882. /**
  70883. * Color of the bounding box lines placed behind an object
  70884. */
  70885. backColor: Color3;
  70886. /**
  70887. * Defines if the renderer should show the back lines or not
  70888. */
  70889. showBackLines: boolean;
  70890. /**
  70891. * @hidden
  70892. */
  70893. renderList: SmartArray<BoundingBox>;
  70894. private _colorShader;
  70895. private _vertexBuffers;
  70896. private _indexBuffer;
  70897. private _fillIndexBuffer;
  70898. private _fillIndexData;
  70899. /**
  70900. * Instantiates a new bounding box renderer in a scene.
  70901. * @param scene the scene the renderer renders in
  70902. */
  70903. constructor(scene: Scene);
  70904. /**
  70905. * Registers the component in a given scene
  70906. */
  70907. register(): void;
  70908. private _evaluateSubMesh;
  70909. private _activeMesh;
  70910. private _prepareRessources;
  70911. private _createIndexBuffer;
  70912. /**
  70913. * Rebuilds the elements related to this component in case of
  70914. * context lost for instance.
  70915. */
  70916. rebuild(): void;
  70917. /**
  70918. * @hidden
  70919. */
  70920. reset(): void;
  70921. /**
  70922. * Render the bounding boxes of a specific rendering group
  70923. * @param renderingGroupId defines the rendering group to render
  70924. */
  70925. render(renderingGroupId: number): void;
  70926. /**
  70927. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70928. * @param mesh Define the mesh to render the occlusion bounding box for
  70929. */
  70930. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70931. /**
  70932. * Dispose and release the resources attached to this renderer.
  70933. */
  70934. dispose(): void;
  70935. }
  70936. }
  70937. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70938. import { Nullable } from "babylonjs/types";
  70939. import { Scene } from "babylonjs/scene";
  70940. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70941. import { Camera } from "babylonjs/Cameras/camera";
  70942. import { ISceneComponent } from "babylonjs/sceneComponent";
  70943. module "babylonjs/scene" {
  70944. interface Scene {
  70945. /** @hidden (Backing field) */
  70946. _depthRenderer: {
  70947. [id: string]: DepthRenderer;
  70948. };
  70949. /**
  70950. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70951. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70952. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70953. * @returns the created depth renderer
  70954. */
  70955. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70956. /**
  70957. * Disables a depth renderer for a given camera
  70958. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70959. */
  70960. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70961. }
  70962. }
  70963. /**
  70964. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70965. * in several rendering techniques.
  70966. */
  70967. export class DepthRendererSceneComponent implements ISceneComponent {
  70968. /**
  70969. * The component name helpfull to identify the component in the list of scene components.
  70970. */
  70971. readonly name: string;
  70972. /**
  70973. * The scene the component belongs to.
  70974. */
  70975. scene: Scene;
  70976. /**
  70977. * Creates a new instance of the component for the given scene
  70978. * @param scene Defines the scene to register the component in
  70979. */
  70980. constructor(scene: Scene);
  70981. /**
  70982. * Registers the component in a given scene
  70983. */
  70984. register(): void;
  70985. /**
  70986. * Rebuilds the elements related to this component in case of
  70987. * context lost for instance.
  70988. */
  70989. rebuild(): void;
  70990. /**
  70991. * Disposes the component and the associated ressources
  70992. */
  70993. dispose(): void;
  70994. private _gatherRenderTargets;
  70995. private _gatherActiveCameraRenderTargets;
  70996. }
  70997. }
  70998. declare module "babylonjs/Shaders/outline.fragment" {
  70999. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  71000. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  71001. /** @hidden */
  71002. export var outlinePixelShader: {
  71003. name: string;
  71004. shader: string;
  71005. };
  71006. }
  71007. declare module "babylonjs/Shaders/outline.vertex" {
  71008. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71009. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71011. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71012. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  71013. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71014. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71015. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71016. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  71017. /** @hidden */
  71018. export var outlineVertexShader: {
  71019. name: string;
  71020. shader: string;
  71021. };
  71022. }
  71023. declare module "babylonjs/Rendering/outlineRenderer" {
  71024. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71025. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71026. import { Scene } from "babylonjs/scene";
  71027. import { ISceneComponent } from "babylonjs/sceneComponent";
  71028. import "babylonjs/Shaders/outline.fragment";
  71029. import "babylonjs/Shaders/outline.vertex";
  71030. module "babylonjs/scene" {
  71031. interface Scene {
  71032. /** @hidden */
  71033. _outlineRenderer: OutlineRenderer;
  71034. /**
  71035. * Gets the outline renderer associated with the scene
  71036. * @returns a OutlineRenderer
  71037. */
  71038. getOutlineRenderer(): OutlineRenderer;
  71039. }
  71040. }
  71041. module "babylonjs/Meshes/abstractMesh" {
  71042. interface AbstractMesh {
  71043. /** @hidden (Backing field) */
  71044. _renderOutline: boolean;
  71045. /**
  71046. * Gets or sets a boolean indicating if the outline must be rendered as well
  71047. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71048. */
  71049. renderOutline: boolean;
  71050. /** @hidden (Backing field) */
  71051. _renderOverlay: boolean;
  71052. /**
  71053. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71054. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71055. */
  71056. renderOverlay: boolean;
  71057. }
  71058. }
  71059. /**
  71060. * This class is responsible to draw bothe outline/overlay of meshes.
  71061. * It should not be used directly but through the available method on mesh.
  71062. */
  71063. export class OutlineRenderer implements ISceneComponent {
  71064. /**
  71065. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71066. */
  71067. private static _StencilReference;
  71068. /**
  71069. * The name of the component. Each component must have a unique name.
  71070. */
  71071. name: string;
  71072. /**
  71073. * The scene the component belongs to.
  71074. */
  71075. scene: Scene;
  71076. /**
  71077. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71078. */
  71079. zOffset: number;
  71080. private _engine;
  71081. private _effect;
  71082. private _cachedDefines;
  71083. private _savedDepthWrite;
  71084. /**
  71085. * Instantiates a new outline renderer. (There could be only one per scene).
  71086. * @param scene Defines the scene it belongs to
  71087. */
  71088. constructor(scene: Scene);
  71089. /**
  71090. * Register the component to one instance of a scene.
  71091. */
  71092. register(): void;
  71093. /**
  71094. * Rebuilds the elements related to this component in case of
  71095. * context lost for instance.
  71096. */
  71097. rebuild(): void;
  71098. /**
  71099. * Disposes the component and the associated ressources.
  71100. */
  71101. dispose(): void;
  71102. /**
  71103. * Renders the outline in the canvas.
  71104. * @param subMesh Defines the sumesh to render
  71105. * @param batch Defines the batch of meshes in case of instances
  71106. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71107. */
  71108. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71109. /**
  71110. * Returns whether or not the outline renderer is ready for a given submesh.
  71111. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71112. * @param subMesh Defines the submesh to check readyness for
  71113. * @param useInstances Defines wheter wee are trying to render instances or not
  71114. * @returns true if ready otherwise false
  71115. */
  71116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71117. private _beforeRenderingMesh;
  71118. private _afterRenderingMesh;
  71119. }
  71120. }
  71121. declare module "babylonjs/Rendering/index" {
  71122. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71123. export * from "babylonjs/Rendering/depthRenderer";
  71124. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71125. export * from "babylonjs/Rendering/edgesRenderer";
  71126. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71127. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71128. export * from "babylonjs/Rendering/outlineRenderer";
  71129. export * from "babylonjs/Rendering/renderingGroup";
  71130. export * from "babylonjs/Rendering/renderingManager";
  71131. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71132. }
  71133. declare module "babylonjs/Sprites/ISprites" {
  71134. /**
  71135. * Defines the basic options interface of a Sprite Frame Source Size.
  71136. */
  71137. export interface ISpriteJSONSpriteSourceSize {
  71138. /**
  71139. * number of the original width of the Frame
  71140. */
  71141. w: number;
  71142. /**
  71143. * number of the original height of the Frame
  71144. */
  71145. h: number;
  71146. }
  71147. /**
  71148. * Defines the basic options interface of a Sprite Frame Data.
  71149. */
  71150. export interface ISpriteJSONSpriteFrameData {
  71151. /**
  71152. * number of the x offset of the Frame
  71153. */
  71154. x: number;
  71155. /**
  71156. * number of the y offset of the Frame
  71157. */
  71158. y: number;
  71159. /**
  71160. * number of the width of the Frame
  71161. */
  71162. w: number;
  71163. /**
  71164. * number of the height of the Frame
  71165. */
  71166. h: number;
  71167. }
  71168. /**
  71169. * Defines the basic options interface of a JSON Sprite.
  71170. */
  71171. export interface ISpriteJSONSprite {
  71172. /**
  71173. * string name of the Frame
  71174. */
  71175. filename: string;
  71176. /**
  71177. * ISpriteJSONSpriteFrame basic object of the frame data
  71178. */
  71179. frame: ISpriteJSONSpriteFrameData;
  71180. /**
  71181. * boolean to flag is the frame was rotated.
  71182. */
  71183. rotated: boolean;
  71184. /**
  71185. * boolean to flag is the frame was trimmed.
  71186. */
  71187. trimmed: boolean;
  71188. /**
  71189. * ISpriteJSONSpriteFrame basic object of the source data
  71190. */
  71191. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71192. /**
  71193. * ISpriteJSONSpriteFrame basic object of the source data
  71194. */
  71195. sourceSize: ISpriteJSONSpriteSourceSize;
  71196. }
  71197. /**
  71198. * Defines the basic options interface of a JSON atlas.
  71199. */
  71200. export interface ISpriteJSONAtlas {
  71201. /**
  71202. * Array of objects that contain the frame data.
  71203. */
  71204. frames: Array<ISpriteJSONSprite>;
  71205. /**
  71206. * object basic object containing the sprite meta data.
  71207. */
  71208. meta?: object;
  71209. }
  71210. }
  71211. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71212. /** @hidden */
  71213. export var spriteMapPixelShader: {
  71214. name: string;
  71215. shader: string;
  71216. };
  71217. }
  71218. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71219. /** @hidden */
  71220. export var spriteMapVertexShader: {
  71221. name: string;
  71222. shader: string;
  71223. };
  71224. }
  71225. declare module "babylonjs/Sprites/spriteMap" {
  71226. import { IDisposable, Scene } from "babylonjs/scene";
  71227. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71228. import { Texture } from "babylonjs/Materials/Textures/texture";
  71229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71230. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71231. import "babylonjs/Meshes/Builders/planeBuilder";
  71232. import "babylonjs/Shaders/spriteMap.fragment";
  71233. import "babylonjs/Shaders/spriteMap.vertex";
  71234. /**
  71235. * Defines the basic options interface of a SpriteMap
  71236. */
  71237. export interface ISpriteMapOptions {
  71238. /**
  71239. * Vector2 of the number of cells in the grid.
  71240. */
  71241. stageSize?: Vector2;
  71242. /**
  71243. * Vector2 of the size of the output plane in World Units.
  71244. */
  71245. outputSize?: Vector2;
  71246. /**
  71247. * Vector3 of the position of the output plane in World Units.
  71248. */
  71249. outputPosition?: Vector3;
  71250. /**
  71251. * Vector3 of the rotation of the output plane.
  71252. */
  71253. outputRotation?: Vector3;
  71254. /**
  71255. * number of layers that the system will reserve in resources.
  71256. */
  71257. layerCount?: number;
  71258. /**
  71259. * number of max animation frames a single cell will reserve in resources.
  71260. */
  71261. maxAnimationFrames?: number;
  71262. /**
  71263. * number cell index of the base tile when the system compiles.
  71264. */
  71265. baseTile?: number;
  71266. /**
  71267. * boolean flip the sprite after its been repositioned by the framing data.
  71268. */
  71269. flipU?: boolean;
  71270. /**
  71271. * Vector3 scalar of the global RGB values of the SpriteMap.
  71272. */
  71273. colorMultiply?: Vector3;
  71274. }
  71275. /**
  71276. * Defines the IDisposable interface in order to be cleanable from resources.
  71277. */
  71278. export interface ISpriteMap extends IDisposable {
  71279. /**
  71280. * String name of the SpriteMap.
  71281. */
  71282. name: string;
  71283. /**
  71284. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71285. */
  71286. atlasJSON: ISpriteJSONAtlas;
  71287. /**
  71288. * Texture of the SpriteMap.
  71289. */
  71290. spriteSheet: Texture;
  71291. /**
  71292. * The parameters to initialize the SpriteMap with.
  71293. */
  71294. options: ISpriteMapOptions;
  71295. }
  71296. /**
  71297. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71298. */
  71299. export class SpriteMap implements ISpriteMap {
  71300. /** The Name of the spriteMap */
  71301. name: string;
  71302. /** The JSON file with the frame and meta data */
  71303. atlasJSON: ISpriteJSONAtlas;
  71304. /** The systems Sprite Sheet Texture */
  71305. spriteSheet: Texture;
  71306. /** Arguments passed with the Constructor */
  71307. options: ISpriteMapOptions;
  71308. /** Public Sprite Storage array, parsed from atlasJSON */
  71309. sprites: Array<ISpriteJSONSprite>;
  71310. /** Returns the Number of Sprites in the System */
  71311. get spriteCount(): number;
  71312. /** Returns the Position of Output Plane*/
  71313. get position(): Vector3;
  71314. /** Returns the Position of Output Plane*/
  71315. set position(v: Vector3);
  71316. /** Returns the Rotation of Output Plane*/
  71317. get rotation(): Vector3;
  71318. /** Returns the Rotation of Output Plane*/
  71319. set rotation(v: Vector3);
  71320. /** Sets the AnimationMap*/
  71321. get animationMap(): RawTexture;
  71322. /** Sets the AnimationMap*/
  71323. set animationMap(v: RawTexture);
  71324. /** Scene that the SpriteMap was created in */
  71325. private _scene;
  71326. /** Texture Buffer of Float32 that holds tile frame data*/
  71327. private _frameMap;
  71328. /** Texture Buffers of Float32 that holds tileMap data*/
  71329. private _tileMaps;
  71330. /** Texture Buffer of Float32 that holds Animation Data*/
  71331. private _animationMap;
  71332. /** Custom ShaderMaterial Central to the System*/
  71333. private _material;
  71334. /** Custom ShaderMaterial Central to the System*/
  71335. private _output;
  71336. /** Systems Time Ticker*/
  71337. private _time;
  71338. /**
  71339. * Creates a new SpriteMap
  71340. * @param name defines the SpriteMaps Name
  71341. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71342. * @param spriteSheet is the Texture that the Sprites are on.
  71343. * @param options a basic deployment configuration
  71344. * @param scene The Scene that the map is deployed on
  71345. */
  71346. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71347. /**
  71348. * Returns tileID location
  71349. * @returns Vector2 the cell position ID
  71350. */
  71351. getTileID(): Vector2;
  71352. /**
  71353. * Gets the UV location of the mouse over the SpriteMap.
  71354. * @returns Vector2 the UV position of the mouse interaction
  71355. */
  71356. getMousePosition(): Vector2;
  71357. /**
  71358. * Creates the "frame" texture Buffer
  71359. * -------------------------------------
  71360. * Structure of frames
  71361. * "filename": "Falling-Water-2.png",
  71362. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71363. * "rotated": true,
  71364. * "trimmed": true,
  71365. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71366. * "sourceSize": {"w":32,"h":32}
  71367. * @returns RawTexture of the frameMap
  71368. */
  71369. private _createFrameBuffer;
  71370. /**
  71371. * Creates the tileMap texture Buffer
  71372. * @param buffer normally and array of numbers, or a false to generate from scratch
  71373. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71374. * @returns RawTexture of the tileMap
  71375. */
  71376. private _createTileBuffer;
  71377. /**
  71378. * Modifies the data of the tileMaps
  71379. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71380. * @param pos is the iVector2 Coordinates of the Tile
  71381. * @param tile The SpriteIndex of the new Tile
  71382. */
  71383. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71384. /**
  71385. * Creates the animationMap texture Buffer
  71386. * @param buffer normally and array of numbers, or a false to generate from scratch
  71387. * @returns RawTexture of the animationMap
  71388. */
  71389. private _createTileAnimationBuffer;
  71390. /**
  71391. * Modifies the data of the animationMap
  71392. * @param cellID is the Index of the Sprite
  71393. * @param _frame is the target Animation frame
  71394. * @param toCell is the Target Index of the next frame of the animation
  71395. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71396. * @param speed is a global scalar of the time variable on the map.
  71397. */
  71398. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71399. /**
  71400. * Exports the .tilemaps file
  71401. */
  71402. saveTileMaps(): void;
  71403. /**
  71404. * Imports the .tilemaps file
  71405. * @param url of the .tilemaps file
  71406. */
  71407. loadTileMaps(url: string): void;
  71408. /**
  71409. * Release associated resources
  71410. */
  71411. dispose(): void;
  71412. }
  71413. }
  71414. declare module "babylonjs/Sprites/spritePackedManager" {
  71415. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71416. import { Scene } from "babylonjs/scene";
  71417. /**
  71418. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71419. * @see http://doc.babylonjs.com/babylon101/sprites
  71420. */
  71421. export class SpritePackedManager extends SpriteManager {
  71422. /** defines the packed manager's name */
  71423. name: string;
  71424. /**
  71425. * Creates a new sprite manager from a packed sprite sheet
  71426. * @param name defines the manager's name
  71427. * @param imgUrl defines the sprite sheet url
  71428. * @param capacity defines the maximum allowed number of sprites
  71429. * @param scene defines the hosting scene
  71430. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71431. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71432. * @param samplingMode defines the smapling mode to use with spritesheet
  71433. * @param fromPacked set to true; do not alter
  71434. */
  71435. constructor(
  71436. /** defines the packed manager's name */
  71437. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71438. }
  71439. }
  71440. declare module "babylonjs/Sprites/index" {
  71441. export * from "babylonjs/Sprites/sprite";
  71442. export * from "babylonjs/Sprites/ISprites";
  71443. export * from "babylonjs/Sprites/spriteManager";
  71444. export * from "babylonjs/Sprites/spriteMap";
  71445. export * from "babylonjs/Sprites/spritePackedManager";
  71446. export * from "babylonjs/Sprites/spriteSceneComponent";
  71447. }
  71448. declare module "babylonjs/States/index" {
  71449. export * from "babylonjs/States/alphaCullingState";
  71450. export * from "babylonjs/States/depthCullingState";
  71451. export * from "babylonjs/States/stencilState";
  71452. }
  71453. declare module "babylonjs/Misc/assetsManager" {
  71454. import { Scene } from "babylonjs/scene";
  71455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71456. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71457. import { Skeleton } from "babylonjs/Bones/skeleton";
  71458. import { Observable } from "babylonjs/Misc/observable";
  71459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71460. import { Texture } from "babylonjs/Materials/Textures/texture";
  71461. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71462. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71463. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71464. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71465. /**
  71466. * Defines the list of states available for a task inside a AssetsManager
  71467. */
  71468. export enum AssetTaskState {
  71469. /**
  71470. * Initialization
  71471. */
  71472. INIT = 0,
  71473. /**
  71474. * Running
  71475. */
  71476. RUNNING = 1,
  71477. /**
  71478. * Done
  71479. */
  71480. DONE = 2,
  71481. /**
  71482. * Error
  71483. */
  71484. ERROR = 3
  71485. }
  71486. /**
  71487. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71488. */
  71489. export abstract class AbstractAssetTask {
  71490. /**
  71491. * Task name
  71492. */ name: string;
  71493. /**
  71494. * Callback called when the task is successful
  71495. */
  71496. onSuccess: (task: any) => void;
  71497. /**
  71498. * Callback called when the task is not successful
  71499. */
  71500. onError: (task: any, message?: string, exception?: any) => void;
  71501. /**
  71502. * Creates a new AssetsManager
  71503. * @param name defines the name of the task
  71504. */
  71505. constructor(
  71506. /**
  71507. * Task name
  71508. */ name: string);
  71509. private _isCompleted;
  71510. private _taskState;
  71511. private _errorObject;
  71512. /**
  71513. * Get if the task is completed
  71514. */
  71515. get isCompleted(): boolean;
  71516. /**
  71517. * Gets the current state of the task
  71518. */
  71519. get taskState(): AssetTaskState;
  71520. /**
  71521. * Gets the current error object (if task is in error)
  71522. */
  71523. get errorObject(): {
  71524. message?: string;
  71525. exception?: any;
  71526. };
  71527. /**
  71528. * Internal only
  71529. * @hidden
  71530. */
  71531. _setErrorObject(message?: string, exception?: any): void;
  71532. /**
  71533. * Execute the current task
  71534. * @param scene defines the scene where you want your assets to be loaded
  71535. * @param onSuccess is a callback called when the task is successfully executed
  71536. * @param onError is a callback called if an error occurs
  71537. */
  71538. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71539. /**
  71540. * Execute the current task
  71541. * @param scene defines the scene where you want your assets to be loaded
  71542. * @param onSuccess is a callback called when the task is successfully executed
  71543. * @param onError is a callback called if an error occurs
  71544. */
  71545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71546. /**
  71547. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71548. * This can be used with failed tasks that have the reason for failure fixed.
  71549. */
  71550. reset(): void;
  71551. private onErrorCallback;
  71552. private onDoneCallback;
  71553. }
  71554. /**
  71555. * Define the interface used by progress events raised during assets loading
  71556. */
  71557. export interface IAssetsProgressEvent {
  71558. /**
  71559. * Defines the number of remaining tasks to process
  71560. */
  71561. remainingCount: number;
  71562. /**
  71563. * Defines the total number of tasks
  71564. */
  71565. totalCount: number;
  71566. /**
  71567. * Defines the task that was just processed
  71568. */
  71569. task: AbstractAssetTask;
  71570. }
  71571. /**
  71572. * Class used to share progress information about assets loading
  71573. */
  71574. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71575. /**
  71576. * Defines the number of remaining tasks to process
  71577. */
  71578. remainingCount: number;
  71579. /**
  71580. * Defines the total number of tasks
  71581. */
  71582. totalCount: number;
  71583. /**
  71584. * Defines the task that was just processed
  71585. */
  71586. task: AbstractAssetTask;
  71587. /**
  71588. * Creates a AssetsProgressEvent
  71589. * @param remainingCount defines the number of remaining tasks to process
  71590. * @param totalCount defines the total number of tasks
  71591. * @param task defines the task that was just processed
  71592. */
  71593. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71594. }
  71595. /**
  71596. * Define a task used by AssetsManager to load meshes
  71597. */
  71598. export class MeshAssetTask extends AbstractAssetTask {
  71599. /**
  71600. * Defines the name of the task
  71601. */
  71602. name: string;
  71603. /**
  71604. * Defines the list of mesh's names you want to load
  71605. */
  71606. meshesNames: any;
  71607. /**
  71608. * Defines the root url to use as a base to load your meshes and associated resources
  71609. */
  71610. rootUrl: string;
  71611. /**
  71612. * Defines the filename of the scene to load from
  71613. */
  71614. sceneFilename: string;
  71615. /**
  71616. * Gets the list of loaded meshes
  71617. */
  71618. loadedMeshes: Array<AbstractMesh>;
  71619. /**
  71620. * Gets the list of loaded particle systems
  71621. */
  71622. loadedParticleSystems: Array<IParticleSystem>;
  71623. /**
  71624. * Gets the list of loaded skeletons
  71625. */
  71626. loadedSkeletons: Array<Skeleton>;
  71627. /**
  71628. * Gets the list of loaded animation groups
  71629. */
  71630. loadedAnimationGroups: Array<AnimationGroup>;
  71631. /**
  71632. * Callback called when the task is successful
  71633. */
  71634. onSuccess: (task: MeshAssetTask) => void;
  71635. /**
  71636. * Callback called when the task is successful
  71637. */
  71638. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71639. /**
  71640. * Creates a new MeshAssetTask
  71641. * @param name defines the name of the task
  71642. * @param meshesNames defines the list of mesh's names you want to load
  71643. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71644. * @param sceneFilename defines the filename of the scene to load from
  71645. */
  71646. constructor(
  71647. /**
  71648. * Defines the name of the task
  71649. */
  71650. name: string,
  71651. /**
  71652. * Defines the list of mesh's names you want to load
  71653. */
  71654. meshesNames: any,
  71655. /**
  71656. * Defines the root url to use as a base to load your meshes and associated resources
  71657. */
  71658. rootUrl: string,
  71659. /**
  71660. * Defines the filename of the scene to load from
  71661. */
  71662. sceneFilename: string);
  71663. /**
  71664. * Execute the current task
  71665. * @param scene defines the scene where you want your assets to be loaded
  71666. * @param onSuccess is a callback called when the task is successfully executed
  71667. * @param onError is a callback called if an error occurs
  71668. */
  71669. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71670. }
  71671. /**
  71672. * Define a task used by AssetsManager to load text content
  71673. */
  71674. export class TextFileAssetTask extends AbstractAssetTask {
  71675. /**
  71676. * Defines the name of the task
  71677. */
  71678. name: string;
  71679. /**
  71680. * Defines the location of the file to load
  71681. */
  71682. url: string;
  71683. /**
  71684. * Gets the loaded text string
  71685. */
  71686. text: string;
  71687. /**
  71688. * Callback called when the task is successful
  71689. */
  71690. onSuccess: (task: TextFileAssetTask) => void;
  71691. /**
  71692. * Callback called when the task is successful
  71693. */
  71694. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71695. /**
  71696. * Creates a new TextFileAssetTask object
  71697. * @param name defines the name of the task
  71698. * @param url defines the location of the file to load
  71699. */
  71700. constructor(
  71701. /**
  71702. * Defines the name of the task
  71703. */
  71704. name: string,
  71705. /**
  71706. * Defines the location of the file to load
  71707. */
  71708. url: string);
  71709. /**
  71710. * Execute the current task
  71711. * @param scene defines the scene where you want your assets to be loaded
  71712. * @param onSuccess is a callback called when the task is successfully executed
  71713. * @param onError is a callback called if an error occurs
  71714. */
  71715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71716. }
  71717. /**
  71718. * Define a task used by AssetsManager to load binary data
  71719. */
  71720. export class BinaryFileAssetTask extends AbstractAssetTask {
  71721. /**
  71722. * Defines the name of the task
  71723. */
  71724. name: string;
  71725. /**
  71726. * Defines the location of the file to load
  71727. */
  71728. url: string;
  71729. /**
  71730. * Gets the lodaded data (as an array buffer)
  71731. */
  71732. data: ArrayBuffer;
  71733. /**
  71734. * Callback called when the task is successful
  71735. */
  71736. onSuccess: (task: BinaryFileAssetTask) => void;
  71737. /**
  71738. * Callback called when the task is successful
  71739. */
  71740. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71741. /**
  71742. * Creates a new BinaryFileAssetTask object
  71743. * @param name defines the name of the new task
  71744. * @param url defines the location of the file to load
  71745. */
  71746. constructor(
  71747. /**
  71748. * Defines the name of the task
  71749. */
  71750. name: string,
  71751. /**
  71752. * Defines the location of the file to load
  71753. */
  71754. url: string);
  71755. /**
  71756. * Execute the current task
  71757. * @param scene defines the scene where you want your assets to be loaded
  71758. * @param onSuccess is a callback called when the task is successfully executed
  71759. * @param onError is a callback called if an error occurs
  71760. */
  71761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71762. }
  71763. /**
  71764. * Define a task used by AssetsManager to load images
  71765. */
  71766. export class ImageAssetTask extends AbstractAssetTask {
  71767. /**
  71768. * Defines the name of the task
  71769. */
  71770. name: string;
  71771. /**
  71772. * Defines the location of the image to load
  71773. */
  71774. url: string;
  71775. /**
  71776. * Gets the loaded images
  71777. */
  71778. image: HTMLImageElement;
  71779. /**
  71780. * Callback called when the task is successful
  71781. */
  71782. onSuccess: (task: ImageAssetTask) => void;
  71783. /**
  71784. * Callback called when the task is successful
  71785. */
  71786. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71787. /**
  71788. * Creates a new ImageAssetTask
  71789. * @param name defines the name of the task
  71790. * @param url defines the location of the image to load
  71791. */
  71792. constructor(
  71793. /**
  71794. * Defines the name of the task
  71795. */
  71796. name: string,
  71797. /**
  71798. * Defines the location of the image to load
  71799. */
  71800. url: string);
  71801. /**
  71802. * Execute the current task
  71803. * @param scene defines the scene where you want your assets to be loaded
  71804. * @param onSuccess is a callback called when the task is successfully executed
  71805. * @param onError is a callback called if an error occurs
  71806. */
  71807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71808. }
  71809. /**
  71810. * Defines the interface used by texture loading tasks
  71811. */
  71812. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71813. /**
  71814. * Gets the loaded texture
  71815. */
  71816. texture: TEX;
  71817. }
  71818. /**
  71819. * Define a task used by AssetsManager to load 2D textures
  71820. */
  71821. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71822. /**
  71823. * Defines the name of the task
  71824. */
  71825. name: string;
  71826. /**
  71827. * Defines the location of the file to load
  71828. */
  71829. url: string;
  71830. /**
  71831. * Defines if mipmap should not be generated (default is false)
  71832. */
  71833. noMipmap?: boolean | undefined;
  71834. /**
  71835. * Defines if texture must be inverted on Y axis (default is true)
  71836. */
  71837. invertY: boolean;
  71838. /**
  71839. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71840. */
  71841. samplingMode: number;
  71842. /**
  71843. * Gets the loaded texture
  71844. */
  71845. texture: Texture;
  71846. /**
  71847. * Callback called when the task is successful
  71848. */
  71849. onSuccess: (task: TextureAssetTask) => void;
  71850. /**
  71851. * Callback called when the task is successful
  71852. */
  71853. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71854. /**
  71855. * Creates a new TextureAssetTask object
  71856. * @param name defines the name of the task
  71857. * @param url defines the location of the file to load
  71858. * @param noMipmap defines if mipmap should not be generated (default is false)
  71859. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71860. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71861. */
  71862. constructor(
  71863. /**
  71864. * Defines the name of the task
  71865. */
  71866. name: string,
  71867. /**
  71868. * Defines the location of the file to load
  71869. */
  71870. url: string,
  71871. /**
  71872. * Defines if mipmap should not be generated (default is false)
  71873. */
  71874. noMipmap?: boolean | undefined,
  71875. /**
  71876. * Defines if texture must be inverted on Y axis (default is true)
  71877. */
  71878. invertY?: boolean,
  71879. /**
  71880. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71881. */
  71882. samplingMode?: number);
  71883. /**
  71884. * Execute the current task
  71885. * @param scene defines the scene where you want your assets to be loaded
  71886. * @param onSuccess is a callback called when the task is successfully executed
  71887. * @param onError is a callback called if an error occurs
  71888. */
  71889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71890. }
  71891. /**
  71892. * Define a task used by AssetsManager to load cube textures
  71893. */
  71894. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71895. /**
  71896. * Defines the name of the task
  71897. */
  71898. name: string;
  71899. /**
  71900. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71901. */
  71902. url: string;
  71903. /**
  71904. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71905. */
  71906. extensions?: string[] | undefined;
  71907. /**
  71908. * Defines if mipmaps should not be generated (default is false)
  71909. */
  71910. noMipmap?: boolean | undefined;
  71911. /**
  71912. * Defines the explicit list of files (undefined by default)
  71913. */
  71914. files?: string[] | undefined;
  71915. /**
  71916. * Gets the loaded texture
  71917. */
  71918. texture: CubeTexture;
  71919. /**
  71920. * Callback called when the task is successful
  71921. */
  71922. onSuccess: (task: CubeTextureAssetTask) => void;
  71923. /**
  71924. * Callback called when the task is successful
  71925. */
  71926. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71927. /**
  71928. * Creates a new CubeTextureAssetTask
  71929. * @param name defines the name of the task
  71930. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71931. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71932. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71933. * @param files defines the explicit list of files (undefined by default)
  71934. */
  71935. constructor(
  71936. /**
  71937. * Defines the name of the task
  71938. */
  71939. name: string,
  71940. /**
  71941. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71942. */
  71943. url: string,
  71944. /**
  71945. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71946. */
  71947. extensions?: string[] | undefined,
  71948. /**
  71949. * Defines if mipmaps should not be generated (default is false)
  71950. */
  71951. noMipmap?: boolean | undefined,
  71952. /**
  71953. * Defines the explicit list of files (undefined by default)
  71954. */
  71955. files?: string[] | undefined);
  71956. /**
  71957. * Execute the current task
  71958. * @param scene defines the scene where you want your assets to be loaded
  71959. * @param onSuccess is a callback called when the task is successfully executed
  71960. * @param onError is a callback called if an error occurs
  71961. */
  71962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71963. }
  71964. /**
  71965. * Define a task used by AssetsManager to load HDR cube textures
  71966. */
  71967. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71968. /**
  71969. * Defines the name of the task
  71970. */
  71971. name: string;
  71972. /**
  71973. * Defines the location of the file to load
  71974. */
  71975. url: string;
  71976. /**
  71977. * Defines the desired size (the more it increases the longer the generation will be)
  71978. */
  71979. size: number;
  71980. /**
  71981. * Defines if mipmaps should not be generated (default is false)
  71982. */
  71983. noMipmap: boolean;
  71984. /**
  71985. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71986. */
  71987. generateHarmonics: boolean;
  71988. /**
  71989. * 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)
  71990. */
  71991. gammaSpace: boolean;
  71992. /**
  71993. * Internal Use Only
  71994. */
  71995. reserved: boolean;
  71996. /**
  71997. * Gets the loaded texture
  71998. */
  71999. texture: HDRCubeTexture;
  72000. /**
  72001. * Callback called when the task is successful
  72002. */
  72003. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72004. /**
  72005. * Callback called when the task is successful
  72006. */
  72007. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72008. /**
  72009. * Creates a new HDRCubeTextureAssetTask object
  72010. * @param name defines the name of the task
  72011. * @param url defines the location of the file to load
  72012. * @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.
  72013. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72014. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72015. * @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)
  72016. * @param reserved Internal use only
  72017. */
  72018. constructor(
  72019. /**
  72020. * Defines the name of the task
  72021. */
  72022. name: string,
  72023. /**
  72024. * Defines the location of the file to load
  72025. */
  72026. url: string,
  72027. /**
  72028. * Defines the desired size (the more it increases the longer the generation will be)
  72029. */
  72030. size: number,
  72031. /**
  72032. * Defines if mipmaps should not be generated (default is false)
  72033. */
  72034. noMipmap?: boolean,
  72035. /**
  72036. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72037. */
  72038. generateHarmonics?: boolean,
  72039. /**
  72040. * 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)
  72041. */
  72042. gammaSpace?: boolean,
  72043. /**
  72044. * Internal Use Only
  72045. */
  72046. reserved?: boolean);
  72047. /**
  72048. * Execute the current task
  72049. * @param scene defines the scene where you want your assets to be loaded
  72050. * @param onSuccess is a callback called when the task is successfully executed
  72051. * @param onError is a callback called if an error occurs
  72052. */
  72053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72054. }
  72055. /**
  72056. * Define a task used by AssetsManager to load Equirectangular cube textures
  72057. */
  72058. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72059. /**
  72060. * Defines the name of the task
  72061. */
  72062. name: string;
  72063. /**
  72064. * Defines the location of the file to load
  72065. */
  72066. url: string;
  72067. /**
  72068. * Defines the desired size (the more it increases the longer the generation will be)
  72069. */
  72070. size: number;
  72071. /**
  72072. * Defines if mipmaps should not be generated (default is false)
  72073. */
  72074. noMipmap: boolean;
  72075. /**
  72076. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72077. * but the standard material would require them in Gamma space) (default is true)
  72078. */
  72079. gammaSpace: boolean;
  72080. /**
  72081. * Gets the loaded texture
  72082. */
  72083. texture: EquiRectangularCubeTexture;
  72084. /**
  72085. * Callback called when the task is successful
  72086. */
  72087. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72088. /**
  72089. * Callback called when the task is successful
  72090. */
  72091. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72092. /**
  72093. * Creates a new EquiRectangularCubeTextureAssetTask object
  72094. * @param name defines the name of the task
  72095. * @param url defines the location of the file to load
  72096. * @param size defines the desired size (the more it increases the longer the generation will be)
  72097. * If the size is omitted this implies you are using a preprocessed cubemap.
  72098. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72099. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72100. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72101. * (default is true)
  72102. */
  72103. constructor(
  72104. /**
  72105. * Defines the name of the task
  72106. */
  72107. name: string,
  72108. /**
  72109. * Defines the location of the file to load
  72110. */
  72111. url: string,
  72112. /**
  72113. * Defines the desired size (the more it increases the longer the generation will be)
  72114. */
  72115. size: number,
  72116. /**
  72117. * Defines if mipmaps should not be generated (default is false)
  72118. */
  72119. noMipmap?: boolean,
  72120. /**
  72121. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72122. * but the standard material would require them in Gamma space) (default is true)
  72123. */
  72124. gammaSpace?: boolean);
  72125. /**
  72126. * Execute the current task
  72127. * @param scene defines the scene where you want your assets to be loaded
  72128. * @param onSuccess is a callback called when the task is successfully executed
  72129. * @param onError is a callback called if an error occurs
  72130. */
  72131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72132. }
  72133. /**
  72134. * This class can be used to easily import assets into a scene
  72135. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72136. */
  72137. export class AssetsManager {
  72138. private _scene;
  72139. private _isLoading;
  72140. protected _tasks: AbstractAssetTask[];
  72141. protected _waitingTasksCount: number;
  72142. protected _totalTasksCount: number;
  72143. /**
  72144. * Callback called when all tasks are processed
  72145. */
  72146. onFinish: (tasks: AbstractAssetTask[]) => void;
  72147. /**
  72148. * Callback called when a task is successful
  72149. */
  72150. onTaskSuccess: (task: AbstractAssetTask) => void;
  72151. /**
  72152. * Callback called when a task had an error
  72153. */
  72154. onTaskError: (task: AbstractAssetTask) => void;
  72155. /**
  72156. * Callback called when a task is done (whatever the result is)
  72157. */
  72158. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72159. /**
  72160. * Observable called when all tasks are processed
  72161. */
  72162. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72163. /**
  72164. * Observable called when a task had an error
  72165. */
  72166. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72167. /**
  72168. * Observable called when all tasks were executed
  72169. */
  72170. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72171. /**
  72172. * Observable called when a task is done (whatever the result is)
  72173. */
  72174. onProgressObservable: Observable<IAssetsProgressEvent>;
  72175. /**
  72176. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72178. */
  72179. useDefaultLoadingScreen: boolean;
  72180. /**
  72181. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72182. * when all assets have been downloaded.
  72183. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72184. */
  72185. autoHideLoadingUI: boolean;
  72186. /**
  72187. * Creates a new AssetsManager
  72188. * @param scene defines the scene to work on
  72189. */
  72190. constructor(scene: Scene);
  72191. /**
  72192. * Add a MeshAssetTask to the list of active tasks
  72193. * @param taskName defines the name of the new task
  72194. * @param meshesNames defines the name of meshes to load
  72195. * @param rootUrl defines the root url to use to locate files
  72196. * @param sceneFilename defines the filename of the scene file
  72197. * @returns a new MeshAssetTask object
  72198. */
  72199. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72200. /**
  72201. * Add a TextFileAssetTask to the list of active tasks
  72202. * @param taskName defines the name of the new task
  72203. * @param url defines the url of the file to load
  72204. * @returns a new TextFileAssetTask object
  72205. */
  72206. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72207. /**
  72208. * Add a BinaryFileAssetTask to the list of active tasks
  72209. * @param taskName defines the name of the new task
  72210. * @param url defines the url of the file to load
  72211. * @returns a new BinaryFileAssetTask object
  72212. */
  72213. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72214. /**
  72215. * Add a ImageAssetTask to the list of active tasks
  72216. * @param taskName defines the name of the new task
  72217. * @param url defines the url of the file to load
  72218. * @returns a new ImageAssetTask object
  72219. */
  72220. addImageTask(taskName: string, url: string): ImageAssetTask;
  72221. /**
  72222. * Add a TextureAssetTask to the list of active tasks
  72223. * @param taskName defines the name of the new task
  72224. * @param url defines the url of the file to load
  72225. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72226. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72227. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72228. * @returns a new TextureAssetTask object
  72229. */
  72230. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72231. /**
  72232. * Add a CubeTextureAssetTask to the list of active tasks
  72233. * @param taskName defines the name of the new task
  72234. * @param url defines the url of the file to load
  72235. * @param extensions defines the extension to use to load the cube map (can be null)
  72236. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72237. * @param files defines the list of files to load (can be null)
  72238. * @returns a new CubeTextureAssetTask object
  72239. */
  72240. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72241. /**
  72242. *
  72243. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72244. * @param taskName defines the name of the new task
  72245. * @param url defines the url of the file to load
  72246. * @param size defines the size you want for the cubemap (can be null)
  72247. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72248. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72249. * @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)
  72250. * @param reserved Internal use only
  72251. * @returns a new HDRCubeTextureAssetTask object
  72252. */
  72253. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72254. /**
  72255. *
  72256. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72257. * @param taskName defines the name of the new task
  72258. * @param url defines the url of the file to load
  72259. * @param size defines the size you want for the cubemap (can be null)
  72260. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72261. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72262. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72263. * @returns a new EquiRectangularCubeTextureAssetTask object
  72264. */
  72265. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72266. /**
  72267. * Remove a task from the assets manager.
  72268. * @param task the task to remove
  72269. */
  72270. removeTask(task: AbstractAssetTask): void;
  72271. private _decreaseWaitingTasksCount;
  72272. private _runTask;
  72273. /**
  72274. * Reset the AssetsManager and remove all tasks
  72275. * @return the current instance of the AssetsManager
  72276. */
  72277. reset(): AssetsManager;
  72278. /**
  72279. * Start the loading process
  72280. * @return the current instance of the AssetsManager
  72281. */
  72282. load(): AssetsManager;
  72283. /**
  72284. * Start the loading process as an async operation
  72285. * @return a promise returning the list of failed tasks
  72286. */
  72287. loadAsync(): Promise<void>;
  72288. }
  72289. }
  72290. declare module "babylonjs/Misc/deferred" {
  72291. /**
  72292. * Wrapper class for promise with external resolve and reject.
  72293. */
  72294. export class Deferred<T> {
  72295. /**
  72296. * The promise associated with this deferred object.
  72297. */
  72298. readonly promise: Promise<T>;
  72299. private _resolve;
  72300. private _reject;
  72301. /**
  72302. * The resolve method of the promise associated with this deferred object.
  72303. */
  72304. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72305. /**
  72306. * The reject method of the promise associated with this deferred object.
  72307. */
  72308. get reject(): (reason?: any) => void;
  72309. /**
  72310. * Constructor for this deferred object.
  72311. */
  72312. constructor();
  72313. }
  72314. }
  72315. declare module "babylonjs/Misc/meshExploder" {
  72316. import { Mesh } from "babylonjs/Meshes/mesh";
  72317. /**
  72318. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72319. */
  72320. export class MeshExploder {
  72321. private _centerMesh;
  72322. private _meshes;
  72323. private _meshesOrigins;
  72324. private _toCenterVectors;
  72325. private _scaledDirection;
  72326. private _newPosition;
  72327. private _centerPosition;
  72328. /**
  72329. * Explodes meshes from a center mesh.
  72330. * @param meshes The meshes to explode.
  72331. * @param centerMesh The mesh to be center of explosion.
  72332. */
  72333. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72334. private _setCenterMesh;
  72335. /**
  72336. * Get class name
  72337. * @returns "MeshExploder"
  72338. */
  72339. getClassName(): string;
  72340. /**
  72341. * "Exploded meshes"
  72342. * @returns Array of meshes with the centerMesh at index 0.
  72343. */
  72344. getMeshes(): Array<Mesh>;
  72345. /**
  72346. * Explodes meshes giving a specific direction
  72347. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72348. */
  72349. explode(direction?: number): void;
  72350. }
  72351. }
  72352. declare module "babylonjs/Misc/filesInput" {
  72353. import { Engine } from "babylonjs/Engines/engine";
  72354. import { Scene } from "babylonjs/scene";
  72355. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72356. /**
  72357. * Class used to help managing file picking and drag'n'drop
  72358. */
  72359. export class FilesInput {
  72360. /**
  72361. * List of files ready to be loaded
  72362. */
  72363. static get FilesToLoad(): {
  72364. [key: string]: File;
  72365. };
  72366. /**
  72367. * Callback called when a file is processed
  72368. */
  72369. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72370. private _engine;
  72371. private _currentScene;
  72372. private _sceneLoadedCallback;
  72373. private _progressCallback;
  72374. private _additionalRenderLoopLogicCallback;
  72375. private _textureLoadingCallback;
  72376. private _startingProcessingFilesCallback;
  72377. private _onReloadCallback;
  72378. private _errorCallback;
  72379. private _elementToMonitor;
  72380. private _sceneFileToLoad;
  72381. private _filesToLoad;
  72382. /**
  72383. * Creates a new FilesInput
  72384. * @param engine defines the rendering engine
  72385. * @param scene defines the hosting scene
  72386. * @param sceneLoadedCallback callback called when scene is loaded
  72387. * @param progressCallback callback called to track progress
  72388. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72389. * @param textureLoadingCallback callback called when a texture is loading
  72390. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72391. * @param onReloadCallback callback called when a reload is requested
  72392. * @param errorCallback callback call if an error occurs
  72393. */
  72394. 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);
  72395. private _dragEnterHandler;
  72396. private _dragOverHandler;
  72397. private _dropHandler;
  72398. /**
  72399. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72400. * @param elementToMonitor defines the DOM element to track
  72401. */
  72402. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72403. /**
  72404. * Release all associated resources
  72405. */
  72406. dispose(): void;
  72407. private renderFunction;
  72408. private drag;
  72409. private drop;
  72410. private _traverseFolder;
  72411. private _processFiles;
  72412. /**
  72413. * Load files from a drop event
  72414. * @param event defines the drop event to use as source
  72415. */
  72416. loadFiles(event: any): void;
  72417. private _processReload;
  72418. /**
  72419. * Reload the current scene from the loaded files
  72420. */
  72421. reload(): void;
  72422. }
  72423. }
  72424. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72425. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72426. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72427. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72428. }
  72429. declare module "babylonjs/Misc/sceneOptimizer" {
  72430. import { Scene, IDisposable } from "babylonjs/scene";
  72431. import { Observable } from "babylonjs/Misc/observable";
  72432. /**
  72433. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72435. */
  72436. export class SceneOptimization {
  72437. /**
  72438. * Defines the priority of this optimization (0 by default which means first in the list)
  72439. */
  72440. priority: number;
  72441. /**
  72442. * Gets a string describing the action executed by the current optimization
  72443. * @returns description string
  72444. */
  72445. getDescription(): string;
  72446. /**
  72447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72448. * @param scene defines the current scene where to apply this optimization
  72449. * @param optimizer defines the current optimizer
  72450. * @returns true if everything that can be done was applied
  72451. */
  72452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72453. /**
  72454. * Creates the SceneOptimization object
  72455. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72456. * @param desc defines the description associated with the optimization
  72457. */
  72458. constructor(
  72459. /**
  72460. * Defines the priority of this optimization (0 by default which means first in the list)
  72461. */
  72462. priority?: number);
  72463. }
  72464. /**
  72465. * Defines an optimization used to reduce the size of render target textures
  72466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72467. */
  72468. export class TextureOptimization extends SceneOptimization {
  72469. /**
  72470. * Defines the priority of this optimization (0 by default which means first in the list)
  72471. */
  72472. priority: number;
  72473. /**
  72474. * 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
  72475. */
  72476. maximumSize: number;
  72477. /**
  72478. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72479. */
  72480. step: number;
  72481. /**
  72482. * Gets a string describing the action executed by the current optimization
  72483. * @returns description string
  72484. */
  72485. getDescription(): string;
  72486. /**
  72487. * Creates the TextureOptimization object
  72488. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72489. * @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
  72490. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72491. */
  72492. constructor(
  72493. /**
  72494. * Defines the priority of this optimization (0 by default which means first in the list)
  72495. */
  72496. priority?: number,
  72497. /**
  72498. * 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
  72499. */
  72500. maximumSize?: number,
  72501. /**
  72502. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72503. */
  72504. step?: number);
  72505. /**
  72506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72507. * @param scene defines the current scene where to apply this optimization
  72508. * @param optimizer defines the current optimizer
  72509. * @returns true if everything that can be done was applied
  72510. */
  72511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72512. }
  72513. /**
  72514. * Defines an optimization used to increase or decrease the rendering resolution
  72515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72516. */
  72517. export class HardwareScalingOptimization extends SceneOptimization {
  72518. /**
  72519. * Defines the priority of this optimization (0 by default which means first in the list)
  72520. */
  72521. priority: number;
  72522. /**
  72523. * Defines the maximum scale to use (2 by default)
  72524. */
  72525. maximumScale: number;
  72526. /**
  72527. * Defines the step to use between two passes (0.5 by default)
  72528. */
  72529. step: number;
  72530. private _currentScale;
  72531. private _directionOffset;
  72532. /**
  72533. * Gets a string describing the action executed by the current optimization
  72534. * @return description string
  72535. */
  72536. getDescription(): string;
  72537. /**
  72538. * Creates the HardwareScalingOptimization object
  72539. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72540. * @param maximumScale defines the maximum scale to use (2 by default)
  72541. * @param step defines the step to use between two passes (0.5 by default)
  72542. */
  72543. constructor(
  72544. /**
  72545. * Defines the priority of this optimization (0 by default which means first in the list)
  72546. */
  72547. priority?: number,
  72548. /**
  72549. * Defines the maximum scale to use (2 by default)
  72550. */
  72551. maximumScale?: number,
  72552. /**
  72553. * Defines the step to use between two passes (0.5 by default)
  72554. */
  72555. step?: number);
  72556. /**
  72557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72558. * @param scene defines the current scene where to apply this optimization
  72559. * @param optimizer defines the current optimizer
  72560. * @returns true if everything that can be done was applied
  72561. */
  72562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72563. }
  72564. /**
  72565. * Defines an optimization used to remove shadows
  72566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72567. */
  72568. export class ShadowsOptimization extends SceneOptimization {
  72569. /**
  72570. * Gets a string describing the action executed by the current optimization
  72571. * @return description string
  72572. */
  72573. getDescription(): string;
  72574. /**
  72575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72576. * @param scene defines the current scene where to apply this optimization
  72577. * @param optimizer defines the current optimizer
  72578. * @returns true if everything that can be done was applied
  72579. */
  72580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72581. }
  72582. /**
  72583. * Defines an optimization used to turn post-processes off
  72584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72585. */
  72586. export class PostProcessesOptimization extends SceneOptimization {
  72587. /**
  72588. * Gets a string describing the action executed by the current optimization
  72589. * @return description string
  72590. */
  72591. getDescription(): string;
  72592. /**
  72593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72594. * @param scene defines the current scene where to apply this optimization
  72595. * @param optimizer defines the current optimizer
  72596. * @returns true if everything that can be done was applied
  72597. */
  72598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72599. }
  72600. /**
  72601. * Defines an optimization used to turn lens flares off
  72602. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72603. */
  72604. export class LensFlaresOptimization extends SceneOptimization {
  72605. /**
  72606. * Gets a string describing the action executed by the current optimization
  72607. * @return description string
  72608. */
  72609. getDescription(): string;
  72610. /**
  72611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72612. * @param scene defines the current scene where to apply this optimization
  72613. * @param optimizer defines the current optimizer
  72614. * @returns true if everything that can be done was applied
  72615. */
  72616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72617. }
  72618. /**
  72619. * Defines an optimization based on user defined callback.
  72620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72621. */
  72622. export class CustomOptimization extends SceneOptimization {
  72623. /**
  72624. * Callback called to apply the custom optimization.
  72625. */
  72626. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72627. /**
  72628. * Callback called to get custom description
  72629. */
  72630. onGetDescription: () => string;
  72631. /**
  72632. * Gets a string describing the action executed by the current optimization
  72633. * @returns description string
  72634. */
  72635. getDescription(): string;
  72636. /**
  72637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72638. * @param scene defines the current scene where to apply this optimization
  72639. * @param optimizer defines the current optimizer
  72640. * @returns true if everything that can be done was applied
  72641. */
  72642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72643. }
  72644. /**
  72645. * Defines an optimization used to turn particles off
  72646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72647. */
  72648. export class ParticlesOptimization extends SceneOptimization {
  72649. /**
  72650. * Gets a string describing the action executed by the current optimization
  72651. * @return description string
  72652. */
  72653. getDescription(): string;
  72654. /**
  72655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72656. * @param scene defines the current scene where to apply this optimization
  72657. * @param optimizer defines the current optimizer
  72658. * @returns true if everything that can be done was applied
  72659. */
  72660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72661. }
  72662. /**
  72663. * Defines an optimization used to turn render targets off
  72664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72665. */
  72666. export class RenderTargetsOptimization extends SceneOptimization {
  72667. /**
  72668. * Gets a string describing the action executed by the current optimization
  72669. * @return description string
  72670. */
  72671. getDescription(): string;
  72672. /**
  72673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72674. * @param scene defines the current scene where to apply this optimization
  72675. * @param optimizer defines the current optimizer
  72676. * @returns true if everything that can be done was applied
  72677. */
  72678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72679. }
  72680. /**
  72681. * Defines an optimization used to merge meshes with compatible materials
  72682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72683. */
  72684. export class MergeMeshesOptimization extends SceneOptimization {
  72685. private static _UpdateSelectionTree;
  72686. /**
  72687. * Gets or sets a boolean which defines if optimization octree has to be updated
  72688. */
  72689. static get UpdateSelectionTree(): boolean;
  72690. /**
  72691. * Gets or sets a boolean which defines if optimization octree has to be updated
  72692. */
  72693. static set UpdateSelectionTree(value: boolean);
  72694. /**
  72695. * Gets a string describing the action executed by the current optimization
  72696. * @return description string
  72697. */
  72698. getDescription(): string;
  72699. private _canBeMerged;
  72700. /**
  72701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72702. * @param scene defines the current scene where to apply this optimization
  72703. * @param optimizer defines the current optimizer
  72704. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72705. * @returns true if everything that can be done was applied
  72706. */
  72707. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72708. }
  72709. /**
  72710. * Defines a list of options used by SceneOptimizer
  72711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72712. */
  72713. export class SceneOptimizerOptions {
  72714. /**
  72715. * Defines the target frame rate to reach (60 by default)
  72716. */
  72717. targetFrameRate: number;
  72718. /**
  72719. * Defines the interval between two checkes (2000ms by default)
  72720. */
  72721. trackerDuration: number;
  72722. /**
  72723. * Gets the list of optimizations to apply
  72724. */
  72725. optimizations: SceneOptimization[];
  72726. /**
  72727. * Creates a new list of options used by SceneOptimizer
  72728. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72729. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72730. */
  72731. constructor(
  72732. /**
  72733. * Defines the target frame rate to reach (60 by default)
  72734. */
  72735. targetFrameRate?: number,
  72736. /**
  72737. * Defines the interval between two checkes (2000ms by default)
  72738. */
  72739. trackerDuration?: number);
  72740. /**
  72741. * Add a new optimization
  72742. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72743. * @returns the current SceneOptimizerOptions
  72744. */
  72745. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72746. /**
  72747. * Add a new custom optimization
  72748. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72749. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72751. * @returns the current SceneOptimizerOptions
  72752. */
  72753. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72754. /**
  72755. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72756. * @param targetFrameRate defines the target frame rate (60 by default)
  72757. * @returns a SceneOptimizerOptions object
  72758. */
  72759. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72760. /**
  72761. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72762. * @param targetFrameRate defines the target frame rate (60 by default)
  72763. * @returns a SceneOptimizerOptions object
  72764. */
  72765. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72766. /**
  72767. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72768. * @param targetFrameRate defines the target frame rate (60 by default)
  72769. * @returns a SceneOptimizerOptions object
  72770. */
  72771. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72772. }
  72773. /**
  72774. * Class used to run optimizations in order to reach a target frame rate
  72775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72776. */
  72777. export class SceneOptimizer implements IDisposable {
  72778. private _isRunning;
  72779. private _options;
  72780. private _scene;
  72781. private _currentPriorityLevel;
  72782. private _targetFrameRate;
  72783. private _trackerDuration;
  72784. private _currentFrameRate;
  72785. private _sceneDisposeObserver;
  72786. private _improvementMode;
  72787. /**
  72788. * Defines an observable called when the optimizer reaches the target frame rate
  72789. */
  72790. onSuccessObservable: Observable<SceneOptimizer>;
  72791. /**
  72792. * Defines an observable called when the optimizer enables an optimization
  72793. */
  72794. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72795. /**
  72796. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72797. */
  72798. onFailureObservable: Observable<SceneOptimizer>;
  72799. /**
  72800. * Gets a boolean indicating if the optimizer is in improvement mode
  72801. */
  72802. get isInImprovementMode(): boolean;
  72803. /**
  72804. * Gets the current priority level (0 at start)
  72805. */
  72806. get currentPriorityLevel(): number;
  72807. /**
  72808. * Gets the current frame rate checked by the SceneOptimizer
  72809. */
  72810. get currentFrameRate(): number;
  72811. /**
  72812. * Gets or sets the current target frame rate (60 by default)
  72813. */
  72814. get targetFrameRate(): number;
  72815. /**
  72816. * Gets or sets the current target frame rate (60 by default)
  72817. */
  72818. set targetFrameRate(value: number);
  72819. /**
  72820. * Gets or sets the current interval between two checks (every 2000ms by default)
  72821. */
  72822. get trackerDuration(): number;
  72823. /**
  72824. * Gets or sets the current interval between two checks (every 2000ms by default)
  72825. */
  72826. set trackerDuration(value: number);
  72827. /**
  72828. * Gets the list of active optimizations
  72829. */
  72830. get optimizations(): SceneOptimization[];
  72831. /**
  72832. * Creates a new SceneOptimizer
  72833. * @param scene defines the scene to work on
  72834. * @param options defines the options to use with the SceneOptimizer
  72835. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72836. * @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)
  72837. */
  72838. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72839. /**
  72840. * Stops the current optimizer
  72841. */
  72842. stop(): void;
  72843. /**
  72844. * Reset the optimizer to initial step (current priority level = 0)
  72845. */
  72846. reset(): void;
  72847. /**
  72848. * Start the optimizer. By default it will try to reach a specific framerate
  72849. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72850. */
  72851. start(): void;
  72852. private _checkCurrentState;
  72853. /**
  72854. * Release all resources
  72855. */
  72856. dispose(): void;
  72857. /**
  72858. * Helper function to create a SceneOptimizer with one single line of code
  72859. * @param scene defines the scene to work on
  72860. * @param options defines the options to use with the SceneOptimizer
  72861. * @param onSuccess defines a callback to call on success
  72862. * @param onFailure defines a callback to call on failure
  72863. * @returns the new SceneOptimizer object
  72864. */
  72865. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72866. }
  72867. }
  72868. declare module "babylonjs/Misc/sceneSerializer" {
  72869. import { Scene } from "babylonjs/scene";
  72870. /**
  72871. * Class used to serialize a scene into a string
  72872. */
  72873. export class SceneSerializer {
  72874. /**
  72875. * Clear cache used by a previous serialization
  72876. */
  72877. static ClearCache(): void;
  72878. /**
  72879. * Serialize a scene into a JSON compatible object
  72880. * @param scene defines the scene to serialize
  72881. * @returns a JSON compatible object
  72882. */
  72883. static Serialize(scene: Scene): any;
  72884. /**
  72885. * Serialize a mesh into a JSON compatible object
  72886. * @param toSerialize defines the mesh to serialize
  72887. * @param withParents defines if parents must be serialized as well
  72888. * @param withChildren defines if children must be serialized as well
  72889. * @returns a JSON compatible object
  72890. */
  72891. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72892. }
  72893. }
  72894. declare module "babylonjs/Misc/textureTools" {
  72895. import { Texture } from "babylonjs/Materials/Textures/texture";
  72896. /**
  72897. * Class used to host texture specific utilities
  72898. */
  72899. export class TextureTools {
  72900. /**
  72901. * Uses the GPU to create a copy texture rescaled at a given size
  72902. * @param texture Texture to copy from
  72903. * @param width defines the desired width
  72904. * @param height defines the desired height
  72905. * @param useBilinearMode defines if bilinear mode has to be used
  72906. * @return the generated texture
  72907. */
  72908. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72909. }
  72910. }
  72911. declare module "babylonjs/Misc/videoRecorder" {
  72912. import { Nullable } from "babylonjs/types";
  72913. import { Engine } from "babylonjs/Engines/engine";
  72914. /**
  72915. * This represents the different options available for the video capture.
  72916. */
  72917. export interface VideoRecorderOptions {
  72918. /** Defines the mime type of the video. */
  72919. mimeType: string;
  72920. /** Defines the FPS the video should be recorded at. */
  72921. fps: number;
  72922. /** Defines the chunk size for the recording data. */
  72923. recordChunckSize: number;
  72924. /** The audio tracks to attach to the recording. */
  72925. audioTracks?: MediaStreamTrack[];
  72926. }
  72927. /**
  72928. * This can help with recording videos from BabylonJS.
  72929. * This is based on the available WebRTC functionalities of the browser.
  72930. *
  72931. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72932. */
  72933. export class VideoRecorder {
  72934. private static readonly _defaultOptions;
  72935. /**
  72936. * Returns whether or not the VideoRecorder is available in your browser.
  72937. * @param engine Defines the Babylon Engine.
  72938. * @returns true if supported otherwise false.
  72939. */
  72940. static IsSupported(engine: Engine): boolean;
  72941. private readonly _options;
  72942. private _canvas;
  72943. private _mediaRecorder;
  72944. private _recordedChunks;
  72945. private _fileName;
  72946. private _resolve;
  72947. private _reject;
  72948. /**
  72949. * True when a recording is already in progress.
  72950. */
  72951. get isRecording(): boolean;
  72952. /**
  72953. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72954. * @param engine Defines the BabylonJS Engine you wish to record.
  72955. * @param options Defines options that can be used to customize the capture.
  72956. */
  72957. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72958. /**
  72959. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72960. */
  72961. stopRecording(): void;
  72962. /**
  72963. * Starts recording the canvas for a max duration specified in parameters.
  72964. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72965. * If null no automatic download will start and you can rely on the promise to get the data back.
  72966. * @param maxDuration Defines the maximum recording time in seconds.
  72967. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72968. * @return A promise callback at the end of the recording with the video data in Blob.
  72969. */
  72970. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72971. /**
  72972. * Releases internal resources used during the recording.
  72973. */
  72974. dispose(): void;
  72975. private _handleDataAvailable;
  72976. private _handleError;
  72977. private _handleStop;
  72978. }
  72979. }
  72980. declare module "babylonjs/Misc/screenshotTools" {
  72981. import { Camera } from "babylonjs/Cameras/camera";
  72982. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72983. import { Engine } from "babylonjs/Engines/engine";
  72984. /**
  72985. * Class containing a set of static utilities functions for screenshots
  72986. */
  72987. export class ScreenshotTools {
  72988. /**
  72989. * Captures a screenshot of the current rendering
  72990. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72991. * @param engine defines the rendering engine
  72992. * @param camera defines the source camera
  72993. * @param size This parameter can be set to a single number or to an object with the
  72994. * following (optional) properties: precision, width, height. If a single number is passed,
  72995. * it will be used for both width and height. If an object is passed, the screenshot size
  72996. * will be derived from the parameters. The precision property is a multiplier allowing
  72997. * rendering at a higher or lower resolution
  72998. * @param successCallback defines the callback receives a single parameter which contains the
  72999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73000. * src parameter of an <img> to display it
  73001. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73002. * Check your browser for supported MIME types
  73003. */
  73004. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73005. /**
  73006. * Captures a screenshot of the current rendering
  73007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73008. * @param engine defines the rendering engine
  73009. * @param camera defines the source camera
  73010. * @param size This parameter can be set to a single number or to an object with the
  73011. * following (optional) properties: precision, width, height. If a single number is passed,
  73012. * it will be used for both width and height. If an object is passed, the screenshot size
  73013. * will be derived from the parameters. The precision property is a multiplier allowing
  73014. * rendering at a higher or lower resolution
  73015. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73016. * Check your browser for supported MIME types
  73017. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73018. * to the src parameter of an <img> to display it
  73019. */
  73020. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73021. /**
  73022. * Generates an image screenshot from the specified camera.
  73023. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73024. * @param engine The engine to use for rendering
  73025. * @param camera The camera to use for rendering
  73026. * @param size This parameter can be set to a single number or to an object with the
  73027. * following (optional) properties: precision, width, height. If a single number is passed,
  73028. * it will be used for both width and height. If an object is passed, the screenshot size
  73029. * will be derived from the parameters. The precision property is a multiplier allowing
  73030. * rendering at a higher or lower resolution
  73031. * @param successCallback The callback receives a single parameter which contains the
  73032. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73033. * src parameter of an <img> to display it
  73034. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73035. * Check your browser for supported MIME types
  73036. * @param samples Texture samples (default: 1)
  73037. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73038. * @param fileName A name for for the downloaded file.
  73039. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73040. */
  73041. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73042. /**
  73043. * Generates an image screenshot from the specified camera.
  73044. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73045. * @param engine The engine to use for rendering
  73046. * @param camera The camera to use for rendering
  73047. * @param size This parameter can be set to a single number or to an object with the
  73048. * following (optional) properties: precision, width, height. If a single number is passed,
  73049. * it will be used for both width and height. If an object is passed, the screenshot size
  73050. * will be derived from the parameters. The precision property is a multiplier allowing
  73051. * rendering at a higher or lower resolution
  73052. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73053. * Check your browser for supported MIME types
  73054. * @param samples Texture samples (default: 1)
  73055. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73056. * @param fileName A name for for the downloaded file.
  73057. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73058. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73059. * to the src parameter of an <img> to display it
  73060. */
  73061. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73062. /**
  73063. * Gets height and width for screenshot size
  73064. * @private
  73065. */
  73066. private static _getScreenshotSize;
  73067. }
  73068. }
  73069. declare module "babylonjs/Misc/dataReader" {
  73070. /**
  73071. * Interface for a data buffer
  73072. */
  73073. export interface IDataBuffer {
  73074. /**
  73075. * Reads bytes from the data buffer.
  73076. * @param byteOffset The byte offset to read
  73077. * @param byteLength The byte length to read
  73078. * @returns A promise that resolves when the bytes are read
  73079. */
  73080. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73081. /**
  73082. * The byte length of the buffer.
  73083. */
  73084. readonly byteLength: number;
  73085. }
  73086. /**
  73087. * Utility class for reading from a data buffer
  73088. */
  73089. export class DataReader {
  73090. /**
  73091. * The data buffer associated with this data reader.
  73092. */
  73093. readonly buffer: IDataBuffer;
  73094. /**
  73095. * The current byte offset from the beginning of the data buffer.
  73096. */
  73097. byteOffset: number;
  73098. private _dataView;
  73099. private _dataByteOffset;
  73100. /**
  73101. * Constructor
  73102. * @param buffer The buffer to read
  73103. */
  73104. constructor(buffer: IDataBuffer);
  73105. /**
  73106. * Loads the given byte length.
  73107. * @param byteLength The byte length to load
  73108. * @returns A promise that resolves when the load is complete
  73109. */
  73110. loadAsync(byteLength: number): Promise<void>;
  73111. /**
  73112. * Read a unsigned 32-bit integer from the currently loaded data range.
  73113. * @returns The 32-bit integer read
  73114. */
  73115. readUint32(): number;
  73116. /**
  73117. * Read a byte array from the currently loaded data range.
  73118. * @param byteLength The byte length to read
  73119. * @returns The byte array read
  73120. */
  73121. readUint8Array(byteLength: number): Uint8Array;
  73122. /**
  73123. * Read a string from the currently loaded data range.
  73124. * @param byteLength The byte length to read
  73125. * @returns The string read
  73126. */
  73127. readString(byteLength: number): string;
  73128. /**
  73129. * Skips the given byte length the currently loaded data range.
  73130. * @param byteLength The byte length to skip
  73131. */
  73132. skipBytes(byteLength: number): void;
  73133. }
  73134. }
  73135. declare module "babylonjs/Misc/dataStorage" {
  73136. /**
  73137. * Class for storing data to local storage if available or in-memory storage otherwise
  73138. */
  73139. export class DataStorage {
  73140. private static _Storage;
  73141. private static _GetStorage;
  73142. /**
  73143. * Reads a string from the data storage
  73144. * @param key The key to read
  73145. * @param defaultValue The value if the key doesn't exist
  73146. * @returns The string value
  73147. */
  73148. static ReadString(key: string, defaultValue: string): string;
  73149. /**
  73150. * Writes a string to the data storage
  73151. * @param key The key to write
  73152. * @param value The value to write
  73153. */
  73154. static WriteString(key: string, value: string): void;
  73155. /**
  73156. * Reads a boolean from the data storage
  73157. * @param key The key to read
  73158. * @param defaultValue The value if the key doesn't exist
  73159. * @returns The boolean value
  73160. */
  73161. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73162. /**
  73163. * Writes a boolean to the data storage
  73164. * @param key The key to write
  73165. * @param value The value to write
  73166. */
  73167. static WriteBoolean(key: string, value: boolean): void;
  73168. /**
  73169. * Reads a number from the data storage
  73170. * @param key The key to read
  73171. * @param defaultValue The value if the key doesn't exist
  73172. * @returns The number value
  73173. */
  73174. static ReadNumber(key: string, defaultValue: number): number;
  73175. /**
  73176. * Writes a number to the data storage
  73177. * @param key The key to write
  73178. * @param value The value to write
  73179. */
  73180. static WriteNumber(key: string, value: number): void;
  73181. }
  73182. }
  73183. declare module "babylonjs/Misc/index" {
  73184. export * from "babylonjs/Misc/andOrNotEvaluator";
  73185. export * from "babylonjs/Misc/assetsManager";
  73186. export * from "babylonjs/Misc/basis";
  73187. export * from "babylonjs/Misc/dds";
  73188. export * from "babylonjs/Misc/decorators";
  73189. export * from "babylonjs/Misc/deferred";
  73190. export * from "babylonjs/Misc/environmentTextureTools";
  73191. export * from "babylonjs/Misc/meshExploder";
  73192. export * from "babylonjs/Misc/filesInput";
  73193. export * from "babylonjs/Misc/HighDynamicRange/index";
  73194. export * from "babylonjs/Misc/khronosTextureContainer";
  73195. export * from "babylonjs/Misc/observable";
  73196. export * from "babylonjs/Misc/performanceMonitor";
  73197. export * from "babylonjs/Misc/promise";
  73198. export * from "babylonjs/Misc/sceneOptimizer";
  73199. export * from "babylonjs/Misc/sceneSerializer";
  73200. export * from "babylonjs/Misc/smartArray";
  73201. export * from "babylonjs/Misc/stringDictionary";
  73202. export * from "babylonjs/Misc/tags";
  73203. export * from "babylonjs/Misc/textureTools";
  73204. export * from "babylonjs/Misc/tga";
  73205. export * from "babylonjs/Misc/tools";
  73206. export * from "babylonjs/Misc/videoRecorder";
  73207. export * from "babylonjs/Misc/virtualJoystick";
  73208. export * from "babylonjs/Misc/workerPool";
  73209. export * from "babylonjs/Misc/logger";
  73210. export * from "babylonjs/Misc/typeStore";
  73211. export * from "babylonjs/Misc/filesInputStore";
  73212. export * from "babylonjs/Misc/deepCopier";
  73213. export * from "babylonjs/Misc/pivotTools";
  73214. export * from "babylonjs/Misc/precisionDate";
  73215. export * from "babylonjs/Misc/screenshotTools";
  73216. export * from "babylonjs/Misc/typeStore";
  73217. export * from "babylonjs/Misc/webRequest";
  73218. export * from "babylonjs/Misc/iInspectable";
  73219. export * from "babylonjs/Misc/brdfTextureTools";
  73220. export * from "babylonjs/Misc/rgbdTextureTools";
  73221. export * from "babylonjs/Misc/gradients";
  73222. export * from "babylonjs/Misc/perfCounter";
  73223. export * from "babylonjs/Misc/fileRequest";
  73224. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73225. export * from "babylonjs/Misc/retryStrategy";
  73226. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73227. export * from "babylonjs/Misc/canvasGenerator";
  73228. export * from "babylonjs/Misc/fileTools";
  73229. export * from "babylonjs/Misc/stringTools";
  73230. export * from "babylonjs/Misc/dataReader";
  73231. export * from "babylonjs/Misc/minMaxReducer";
  73232. export * from "babylonjs/Misc/depthReducer";
  73233. export * from "babylonjs/Misc/dataStorage";
  73234. }
  73235. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73236. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73237. import { Observable } from "babylonjs/Misc/observable";
  73238. import { Matrix } from "babylonjs/Maths/math.vector";
  73239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73240. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73241. /**
  73242. * Options used for hit testing
  73243. */
  73244. export interface IWebXRLegacyHitTestOptions {
  73245. /**
  73246. * Only test when user interacted with the scene. Default - hit test every frame
  73247. */
  73248. testOnPointerDownOnly?: boolean;
  73249. /**
  73250. * The node to use to transform the local results to world coordinates
  73251. */
  73252. worldParentNode?: TransformNode;
  73253. }
  73254. /**
  73255. * Interface defining the babylon result of raycasting/hit-test
  73256. */
  73257. export interface IWebXRLegacyHitResult {
  73258. /**
  73259. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73260. */
  73261. transformationMatrix: Matrix;
  73262. /**
  73263. * The native hit test result
  73264. */
  73265. xrHitResult: XRHitResult | XRHitTestResult;
  73266. }
  73267. /**
  73268. * The currently-working hit-test module.
  73269. * Hit test (or Ray-casting) is used to interact with the real world.
  73270. * For further information read here - https://github.com/immersive-web/hit-test
  73271. */
  73272. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73273. /**
  73274. * options to use when constructing this feature
  73275. */
  73276. readonly options: IWebXRLegacyHitTestOptions;
  73277. private _direction;
  73278. private _mat;
  73279. private _onSelectEnabled;
  73280. private _origin;
  73281. /**
  73282. * The module's name
  73283. */
  73284. static readonly Name: string;
  73285. /**
  73286. * The (Babylon) version of this module.
  73287. * This is an integer representing the implementation version.
  73288. * This number does not correspond to the WebXR specs version
  73289. */
  73290. static readonly Version: number;
  73291. /**
  73292. * Populated with the last native XR Hit Results
  73293. */
  73294. lastNativeXRHitResults: XRHitResult[];
  73295. /**
  73296. * Triggered when new babylon (transformed) hit test results are available
  73297. */
  73298. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73299. /**
  73300. * Creates a new instance of the (legacy version) hit test feature
  73301. * @param _xrSessionManager an instance of WebXRSessionManager
  73302. * @param options options to use when constructing this feature
  73303. */
  73304. constructor(_xrSessionManager: WebXRSessionManager,
  73305. /**
  73306. * options to use when constructing this feature
  73307. */
  73308. options?: IWebXRLegacyHitTestOptions);
  73309. /**
  73310. * execute a hit test with an XR Ray
  73311. *
  73312. * @param xrSession a native xrSession that will execute this hit test
  73313. * @param xrRay the ray (position and direction) to use for ray-casting
  73314. * @param referenceSpace native XR reference space to use for the hit-test
  73315. * @param filter filter function that will filter the results
  73316. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73317. */
  73318. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73319. /**
  73320. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73321. * @param event the (select) event to use to select with
  73322. * @param referenceSpace the reference space to use for this hit test
  73323. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73324. */
  73325. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73326. /**
  73327. * attach this feature
  73328. * Will usually be called by the features manager
  73329. *
  73330. * @returns true if successful.
  73331. */
  73332. attach(): boolean;
  73333. /**
  73334. * detach this feature.
  73335. * Will usually be called by the features manager
  73336. *
  73337. * @returns true if successful.
  73338. */
  73339. detach(): boolean;
  73340. /**
  73341. * Dispose this feature and all of the resources attached
  73342. */
  73343. dispose(): void;
  73344. protected _onXRFrame(frame: XRFrame): void;
  73345. private _onHitTestResults;
  73346. private _onSelect;
  73347. }
  73348. }
  73349. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73351. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73352. import { Observable } from "babylonjs/Misc/observable";
  73353. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73354. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73355. /**
  73356. * Options used in the plane detector module
  73357. */
  73358. export interface IWebXRPlaneDetectorOptions {
  73359. /**
  73360. * The node to use to transform the local results to world coordinates
  73361. */
  73362. worldParentNode?: TransformNode;
  73363. }
  73364. /**
  73365. * A babylon interface for a WebXR plane.
  73366. * A Plane is actually a polygon, built from N points in space
  73367. *
  73368. * Supported in chrome 79, not supported in canary 81 ATM
  73369. */
  73370. export interface IWebXRPlane {
  73371. /**
  73372. * a babylon-assigned ID for this polygon
  73373. */
  73374. id: number;
  73375. /**
  73376. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73377. */
  73378. polygonDefinition: Array<Vector3>;
  73379. /**
  73380. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73381. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73382. */
  73383. transformationMatrix: Matrix;
  73384. /**
  73385. * the native xr-plane object
  73386. */
  73387. xrPlane: XRPlane;
  73388. }
  73389. /**
  73390. * The plane detector is used to detect planes in the real world when in AR
  73391. * For more information see https://github.com/immersive-web/real-world-geometry/
  73392. */
  73393. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73394. private _options;
  73395. private _detectedPlanes;
  73396. private _enabled;
  73397. private _lastFrameDetected;
  73398. /**
  73399. * The module's name
  73400. */
  73401. static readonly Name: string;
  73402. /**
  73403. * The (Babylon) version of this module.
  73404. * This is an integer representing the implementation version.
  73405. * This number does not correspond to the WebXR specs version
  73406. */
  73407. static readonly Version: number;
  73408. /**
  73409. * Observers registered here will be executed when a new plane was added to the session
  73410. */
  73411. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73412. /**
  73413. * Observers registered here will be executed when a plane is no longer detected in the session
  73414. */
  73415. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73416. /**
  73417. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73418. * This can execute N times every frame
  73419. */
  73420. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73421. /**
  73422. * construct a new Plane Detector
  73423. * @param _xrSessionManager an instance of xr Session manager
  73424. * @param _options configuration to use when constructing this feature
  73425. */
  73426. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73427. /**
  73428. * Dispose this feature and all of the resources attached
  73429. */
  73430. dispose(): void;
  73431. protected _onXRFrame(frame: XRFrame): void;
  73432. private _init;
  73433. private _updatePlaneWithXRPlane;
  73434. /**
  73435. * avoiding using Array.find for global support.
  73436. * @param xrPlane the plane to find in the array
  73437. */
  73438. private findIndexInPlaneArray;
  73439. }
  73440. }
  73441. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73442. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73443. import { Observable } from "babylonjs/Misc/observable";
  73444. import { Matrix } from "babylonjs/Maths/math.vector";
  73445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73446. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73447. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73448. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73449. /**
  73450. * Configuration options of the anchor system
  73451. */
  73452. export interface IWebXRAnchorSystemOptions {
  73453. /**
  73454. * Should a new anchor be added every time a select event is triggered
  73455. */
  73456. addAnchorOnSelect?: boolean;
  73457. /**
  73458. * should the anchor system use plane detection.
  73459. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73460. */
  73461. usePlaneDetection?: boolean;
  73462. /**
  73463. * a node that will be used to convert local to world coordinates
  73464. */
  73465. worldParentNode?: TransformNode;
  73466. }
  73467. /**
  73468. * A babylon container for an XR Anchor
  73469. */
  73470. export interface IWebXRAnchor {
  73471. /**
  73472. * A babylon-assigned ID for this anchor
  73473. */
  73474. id: number;
  73475. /**
  73476. * Transformation matrix to apply to an object attached to this anchor
  73477. */
  73478. transformationMatrix: Matrix;
  73479. /**
  73480. * The native anchor object
  73481. */
  73482. xrAnchor: XRAnchor;
  73483. }
  73484. /**
  73485. * An implementation of the anchor system of WebXR.
  73486. * Note that the current documented implementation is not available in any browser. Future implementations
  73487. * will use the frame to create an anchor and not the session or a detected plane
  73488. * For further information see https://github.com/immersive-web/anchors/
  73489. */
  73490. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73491. private _options;
  73492. private _enabled;
  73493. private _hitTestModule;
  73494. private _lastFrameDetected;
  73495. private _onSelect;
  73496. private _planeDetector;
  73497. private _trackedAnchors;
  73498. /**
  73499. * The module's name
  73500. */
  73501. static readonly Name: string;
  73502. /**
  73503. * The (Babylon) version of this module.
  73504. * This is an integer representing the implementation version.
  73505. * This number does not correspond to the WebXR specs version
  73506. */
  73507. static readonly Version: number;
  73508. /**
  73509. * Observers registered here will be executed when a new anchor was added to the session
  73510. */
  73511. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73512. /**
  73513. * Observers registered here will be executed when an anchor was removed from the session
  73514. */
  73515. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73516. /**
  73517. * Observers registered here will be executed when an existing anchor updates
  73518. * This can execute N times every frame
  73519. */
  73520. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73521. /**
  73522. * constructs a new anchor system
  73523. * @param _xrSessionManager an instance of WebXRSessionManager
  73524. * @param _options configuration object for this feature
  73525. */
  73526. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73527. /**
  73528. * Add anchor at a specific XR point.
  73529. *
  73530. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73531. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73532. * @returns a promise the fulfills when the anchor was created
  73533. */
  73534. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73535. /**
  73536. * attach this feature
  73537. * Will usually be called by the features manager
  73538. *
  73539. * @returns true if successful.
  73540. */
  73541. attach(): boolean;
  73542. /**
  73543. * detach this feature.
  73544. * Will usually be called by the features manager
  73545. *
  73546. * @returns true if successful.
  73547. */
  73548. detach(): boolean;
  73549. /**
  73550. * Dispose this feature and all of the resources attached
  73551. */
  73552. dispose(): void;
  73553. /**
  73554. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73555. * @param hitTestModule the hit-test module to use.
  73556. */
  73557. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73558. /**
  73559. * set the plane detector to use in order to create anchors from frames
  73560. * @param planeDetector the plane-detector module to use
  73561. * @param enable enable plane-anchors. default is true
  73562. */
  73563. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73564. protected _onXRFrame(frame: XRFrame): void;
  73565. /**
  73566. * avoiding using Array.find for global support.
  73567. * @param xrAnchor the plane to find in the array
  73568. */
  73569. private _findIndexInAnchorArray;
  73570. private _updateAnchorWithXRFrame;
  73571. }
  73572. }
  73573. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73574. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73576. import { Observable } from "babylonjs/Misc/observable";
  73577. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73578. /**
  73579. * Options interface for the background remover plugin
  73580. */
  73581. export interface IWebXRBackgroundRemoverOptions {
  73582. /**
  73583. * Further background meshes to disable when entering AR
  73584. */
  73585. backgroundMeshes?: AbstractMesh[];
  73586. /**
  73587. * flags to configure the removal of the environment helper.
  73588. * If not set, the entire background will be removed. If set, flags should be set as well.
  73589. */
  73590. environmentHelperRemovalFlags?: {
  73591. /**
  73592. * Should the skybox be removed (default false)
  73593. */
  73594. skyBox?: boolean;
  73595. /**
  73596. * Should the ground be removed (default false)
  73597. */
  73598. ground?: boolean;
  73599. };
  73600. /**
  73601. * don't disable the environment helper
  73602. */
  73603. ignoreEnvironmentHelper?: boolean;
  73604. }
  73605. /**
  73606. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73607. */
  73608. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73609. /**
  73610. * read-only options to be used in this module
  73611. */
  73612. readonly options: IWebXRBackgroundRemoverOptions;
  73613. /**
  73614. * The module's name
  73615. */
  73616. static readonly Name: string;
  73617. /**
  73618. * The (Babylon) version of this module.
  73619. * This is an integer representing the implementation version.
  73620. * This number does not correspond to the WebXR specs version
  73621. */
  73622. static readonly Version: number;
  73623. /**
  73624. * registered observers will be triggered when the background state changes
  73625. */
  73626. onBackgroundStateChangedObservable: Observable<boolean>;
  73627. /**
  73628. * constructs a new background remover module
  73629. * @param _xrSessionManager the session manager for this module
  73630. * @param options read-only options to be used in this module
  73631. */
  73632. constructor(_xrSessionManager: WebXRSessionManager,
  73633. /**
  73634. * read-only options to be used in this module
  73635. */
  73636. options?: IWebXRBackgroundRemoverOptions);
  73637. /**
  73638. * attach this feature
  73639. * Will usually be called by the features manager
  73640. *
  73641. * @returns true if successful.
  73642. */
  73643. attach(): boolean;
  73644. /**
  73645. * detach this feature.
  73646. * Will usually be called by the features manager
  73647. *
  73648. * @returns true if successful.
  73649. */
  73650. detach(): boolean;
  73651. /**
  73652. * Dispose this feature and all of the resources attached
  73653. */
  73654. dispose(): void;
  73655. protected _onXRFrame(_xrFrame: XRFrame): void;
  73656. private _setBackgroundState;
  73657. }
  73658. }
  73659. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73660. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73661. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73662. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73663. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73664. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73665. import { Nullable } from "babylonjs/types";
  73666. /**
  73667. * Options for the controller physics feature
  73668. */
  73669. export class IWebXRControllerPhysicsOptions {
  73670. /**
  73671. * Should the headset get its own impostor
  73672. */
  73673. enableHeadsetImpostor?: boolean;
  73674. /**
  73675. * Optional parameters for the headset impostor
  73676. */
  73677. headsetImpostorParams?: {
  73678. /**
  73679. * The type of impostor to create. Default is sphere
  73680. */
  73681. impostorType: number;
  73682. /**
  73683. * the size of the impostor. Defaults to 10cm
  73684. */
  73685. impostorSize?: number | {
  73686. width: number;
  73687. height: number;
  73688. depth: number;
  73689. };
  73690. /**
  73691. * Friction definitions
  73692. */
  73693. friction?: number;
  73694. /**
  73695. * Restitution
  73696. */
  73697. restitution?: number;
  73698. };
  73699. /**
  73700. * The physics properties of the future impostors
  73701. */
  73702. physicsProperties?: {
  73703. /**
  73704. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73705. * Note that this requires a physics engine that supports mesh impostors!
  73706. */
  73707. useControllerMesh?: boolean;
  73708. /**
  73709. * The type of impostor to create. Default is sphere
  73710. */
  73711. impostorType?: number;
  73712. /**
  73713. * the size of the impostor. Defaults to 10cm
  73714. */
  73715. impostorSize?: number | {
  73716. width: number;
  73717. height: number;
  73718. depth: number;
  73719. };
  73720. /**
  73721. * Friction definitions
  73722. */
  73723. friction?: number;
  73724. /**
  73725. * Restitution
  73726. */
  73727. restitution?: number;
  73728. };
  73729. /**
  73730. * the xr input to use with this pointer selection
  73731. */
  73732. xrInput: WebXRInput;
  73733. }
  73734. /**
  73735. * Add physics impostor to your webxr controllers,
  73736. * including naive calculation of their linear and angular velocity
  73737. */
  73738. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73739. private readonly _options;
  73740. private _attachController;
  73741. private _controllers;
  73742. private _debugMode;
  73743. private _delta;
  73744. private _headsetImpostor?;
  73745. private _headsetMesh?;
  73746. private _lastTimestamp;
  73747. private _tmpQuaternion;
  73748. private _tmpVector;
  73749. /**
  73750. * The module's name
  73751. */
  73752. static readonly Name: string;
  73753. /**
  73754. * The (Babylon) version of this module.
  73755. * This is an integer representing the implementation version.
  73756. * This number does not correspond to the webxr specs version
  73757. */
  73758. static readonly Version: number;
  73759. /**
  73760. * Construct a new Controller Physics Feature
  73761. * @param _xrSessionManager the corresponding xr session manager
  73762. * @param _options options to create this feature with
  73763. */
  73764. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73765. /**
  73766. * @hidden
  73767. * enable debugging - will show console outputs and the impostor mesh
  73768. */
  73769. _enablePhysicsDebug(): void;
  73770. /**
  73771. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73772. * @param xrController the controller to add
  73773. */
  73774. addController(xrController: WebXRInputSource): void;
  73775. /**
  73776. * attach this feature
  73777. * Will usually be called by the features manager
  73778. *
  73779. * @returns true if successful.
  73780. */
  73781. attach(): boolean;
  73782. /**
  73783. * detach this feature.
  73784. * Will usually be called by the features manager
  73785. *
  73786. * @returns true if successful.
  73787. */
  73788. detach(): boolean;
  73789. /**
  73790. * Get the headset impostor, if enabled
  73791. * @returns the impostor
  73792. */
  73793. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73794. /**
  73795. * Get the physics impostor of a specific controller.
  73796. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73797. * @param controller the controller or the controller id of which to get the impostor
  73798. * @returns the impostor or null
  73799. */
  73800. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73801. /**
  73802. * Update the physics properties provided in the constructor
  73803. * @param newProperties the new properties object
  73804. */
  73805. setPhysicsProperties(newProperties: {
  73806. impostorType?: number;
  73807. impostorSize?: number | {
  73808. width: number;
  73809. height: number;
  73810. depth: number;
  73811. };
  73812. friction?: number;
  73813. restitution?: number;
  73814. }): void;
  73815. protected _onXRFrame(_xrFrame: any): void;
  73816. private _detachController;
  73817. }
  73818. }
  73819. declare module "babylonjs/XR/features/WebXRHitTest" {
  73820. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73821. import { Observable } from "babylonjs/Misc/observable";
  73822. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73823. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73824. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73825. /**
  73826. * Options used for hit testing (version 2)
  73827. */
  73828. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73829. /**
  73830. * Do not create a permanent hit test. Will usually be used when only
  73831. * transient inputs are needed.
  73832. */
  73833. disablePermanentHitTest?: boolean;
  73834. /**
  73835. * Enable transient (for example touch-based) hit test inspections
  73836. */
  73837. enableTransientHitTest?: boolean;
  73838. /**
  73839. * Offset ray for the permanent hit test
  73840. */
  73841. offsetRay?: Vector3;
  73842. /**
  73843. * Offset ray for the transient hit test
  73844. */
  73845. transientOffsetRay?: Vector3;
  73846. /**
  73847. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73848. */
  73849. useReferenceSpace?: boolean;
  73850. }
  73851. /**
  73852. * Interface defining the babylon result of hit-test
  73853. */
  73854. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73855. /**
  73856. * The input source that generated this hit test (if transient)
  73857. */
  73858. inputSource?: XRInputSource;
  73859. /**
  73860. * Is this a transient hit test
  73861. */
  73862. isTransient?: boolean;
  73863. /**
  73864. * Position of the hit test result
  73865. */
  73866. position: Vector3;
  73867. /**
  73868. * Rotation of the hit test result
  73869. */
  73870. rotationQuaternion: Quaternion;
  73871. }
  73872. /**
  73873. * The currently-working hit-test module.
  73874. * Hit test (or Ray-casting) is used to interact with the real world.
  73875. * For further information read here - https://github.com/immersive-web/hit-test
  73876. *
  73877. * Tested on chrome (mobile) 80.
  73878. */
  73879. export class WebXRHitTest extends WebXRAbstractFeature {
  73880. /**
  73881. * options to use when constructing this feature
  73882. */
  73883. readonly options: IWebXRHitTestOptions;
  73884. private _tmpMat;
  73885. private _tmpPos;
  73886. private _tmpQuat;
  73887. private _transientXrHitTestSource;
  73888. private _xrHitTestSource;
  73889. private initHitTestSource;
  73890. /**
  73891. * The module's name
  73892. */
  73893. static readonly Name: string;
  73894. /**
  73895. * The (Babylon) version of this module.
  73896. * This is an integer representing the implementation version.
  73897. * This number does not correspond to the WebXR specs version
  73898. */
  73899. static readonly Version: number;
  73900. /**
  73901. * When set to true, each hit test will have its own position/rotation objects
  73902. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73903. * the developers will clone them or copy them as they see fit.
  73904. */
  73905. autoCloneTransformation: boolean;
  73906. /**
  73907. * Populated with the last native XR Hit Results
  73908. */
  73909. lastNativeXRHitResults: XRHitResult[];
  73910. /**
  73911. * Triggered when new babylon (transformed) hit test results are available
  73912. */
  73913. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73914. /**
  73915. * Use this to temporarily pause hit test checks.
  73916. */
  73917. paused: boolean;
  73918. /**
  73919. * Creates a new instance of the hit test feature
  73920. * @param _xrSessionManager an instance of WebXRSessionManager
  73921. * @param options options to use when constructing this feature
  73922. */
  73923. constructor(_xrSessionManager: WebXRSessionManager,
  73924. /**
  73925. * options to use when constructing this feature
  73926. */
  73927. options?: IWebXRHitTestOptions);
  73928. /**
  73929. * attach this feature
  73930. * Will usually be called by the features manager
  73931. *
  73932. * @returns true if successful.
  73933. */
  73934. attach(): boolean;
  73935. /**
  73936. * detach this feature.
  73937. * Will usually be called by the features manager
  73938. *
  73939. * @returns true if successful.
  73940. */
  73941. detach(): boolean;
  73942. /**
  73943. * Dispose this feature and all of the resources attached
  73944. */
  73945. dispose(): void;
  73946. protected _onXRFrame(frame: XRFrame): void;
  73947. private _processWebXRHitTestResult;
  73948. }
  73949. }
  73950. declare module "babylonjs/XR/features/index" {
  73951. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73952. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73953. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73954. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73955. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73956. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73957. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73958. export * from "babylonjs/XR/features/WebXRHitTest";
  73959. }
  73960. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73961. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73963. import { Scene } from "babylonjs/scene";
  73964. /**
  73965. * The motion controller class for all microsoft mixed reality controllers
  73966. */
  73967. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73968. protected readonly _mapping: {
  73969. defaultButton: {
  73970. valueNodeName: string;
  73971. unpressedNodeName: string;
  73972. pressedNodeName: string;
  73973. };
  73974. defaultAxis: {
  73975. valueNodeName: string;
  73976. minNodeName: string;
  73977. maxNodeName: string;
  73978. };
  73979. buttons: {
  73980. "xr-standard-trigger": {
  73981. rootNodeName: string;
  73982. componentProperty: string;
  73983. states: string[];
  73984. };
  73985. "xr-standard-squeeze": {
  73986. rootNodeName: string;
  73987. componentProperty: string;
  73988. states: string[];
  73989. };
  73990. "xr-standard-touchpad": {
  73991. rootNodeName: string;
  73992. labelAnchorNodeName: string;
  73993. touchPointNodeName: string;
  73994. };
  73995. "xr-standard-thumbstick": {
  73996. rootNodeName: string;
  73997. componentProperty: string;
  73998. states: string[];
  73999. };
  74000. };
  74001. axes: {
  74002. "xr-standard-touchpad": {
  74003. "x-axis": {
  74004. rootNodeName: string;
  74005. };
  74006. "y-axis": {
  74007. rootNodeName: string;
  74008. };
  74009. };
  74010. "xr-standard-thumbstick": {
  74011. "x-axis": {
  74012. rootNodeName: string;
  74013. };
  74014. "y-axis": {
  74015. rootNodeName: string;
  74016. };
  74017. };
  74018. };
  74019. };
  74020. /**
  74021. * The base url used to load the left and right controller models
  74022. */
  74023. static MODEL_BASE_URL: string;
  74024. /**
  74025. * The name of the left controller model file
  74026. */
  74027. static MODEL_LEFT_FILENAME: string;
  74028. /**
  74029. * The name of the right controller model file
  74030. */
  74031. static MODEL_RIGHT_FILENAME: string;
  74032. profileId: string;
  74033. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74034. protected _getFilenameAndPath(): {
  74035. filename: string;
  74036. path: string;
  74037. };
  74038. protected _getModelLoadingConstraints(): boolean;
  74039. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74040. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74041. protected _updateModel(): void;
  74042. }
  74043. }
  74044. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74045. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74047. import { Scene } from "babylonjs/scene";
  74048. /**
  74049. * The motion controller class for oculus touch (quest, rift).
  74050. * This class supports legacy mapping as well the standard xr mapping
  74051. */
  74052. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74053. private _forceLegacyControllers;
  74054. private _modelRootNode;
  74055. /**
  74056. * The base url used to load the left and right controller models
  74057. */
  74058. static MODEL_BASE_URL: string;
  74059. /**
  74060. * The name of the left controller model file
  74061. */
  74062. static MODEL_LEFT_FILENAME: string;
  74063. /**
  74064. * The name of the right controller model file
  74065. */
  74066. static MODEL_RIGHT_FILENAME: string;
  74067. /**
  74068. * Base Url for the Quest controller model.
  74069. */
  74070. static QUEST_MODEL_BASE_URL: string;
  74071. profileId: string;
  74072. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74073. protected _getFilenameAndPath(): {
  74074. filename: string;
  74075. path: string;
  74076. };
  74077. protected _getModelLoadingConstraints(): boolean;
  74078. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74079. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74080. protected _updateModel(): void;
  74081. /**
  74082. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74083. * between the touch and touch 2.
  74084. */
  74085. private _isQuest;
  74086. }
  74087. }
  74088. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74089. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74090. import { Scene } from "babylonjs/scene";
  74091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74092. /**
  74093. * The motion controller class for the standard HTC-Vive controllers
  74094. */
  74095. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74096. private _modelRootNode;
  74097. /**
  74098. * The base url used to load the left and right controller models
  74099. */
  74100. static MODEL_BASE_URL: string;
  74101. /**
  74102. * File name for the controller model.
  74103. */
  74104. static MODEL_FILENAME: string;
  74105. profileId: string;
  74106. /**
  74107. * Create a new Vive motion controller object
  74108. * @param scene the scene to use to create this controller
  74109. * @param gamepadObject the corresponding gamepad object
  74110. * @param handness the handness of the controller
  74111. */
  74112. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74113. protected _getFilenameAndPath(): {
  74114. filename: string;
  74115. path: string;
  74116. };
  74117. protected _getModelLoadingConstraints(): boolean;
  74118. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74119. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74120. protected _updateModel(): void;
  74121. }
  74122. }
  74123. declare module "babylonjs/XR/motionController/index" {
  74124. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74125. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74126. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74127. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74128. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74129. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74130. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74131. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74132. }
  74133. declare module "babylonjs/XR/index" {
  74134. export * from "babylonjs/XR/webXRCamera";
  74135. export * from "babylonjs/XR/webXREnterExitUI";
  74136. export * from "babylonjs/XR/webXRExperienceHelper";
  74137. export * from "babylonjs/XR/webXRInput";
  74138. export * from "babylonjs/XR/webXRInputSource";
  74139. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74140. export * from "babylonjs/XR/webXRTypes";
  74141. export * from "babylonjs/XR/webXRSessionManager";
  74142. export * from "babylonjs/XR/webXRDefaultExperience";
  74143. export * from "babylonjs/XR/webXRFeaturesManager";
  74144. export * from "babylonjs/XR/features/index";
  74145. export * from "babylonjs/XR/motionController/index";
  74146. }
  74147. declare module "babylonjs/index" {
  74148. export * from "babylonjs/abstractScene";
  74149. export * from "babylonjs/Actions/index";
  74150. export * from "babylonjs/Animations/index";
  74151. export * from "babylonjs/assetContainer";
  74152. export * from "babylonjs/Audio/index";
  74153. export * from "babylonjs/Behaviors/index";
  74154. export * from "babylonjs/Bones/index";
  74155. export * from "babylonjs/Cameras/index";
  74156. export * from "babylonjs/Collisions/index";
  74157. export * from "babylonjs/Culling/index";
  74158. export * from "babylonjs/Debug/index";
  74159. export * from "babylonjs/Engines/index";
  74160. export * from "babylonjs/Events/index";
  74161. export * from "babylonjs/Gamepads/index";
  74162. export * from "babylonjs/Gizmos/index";
  74163. export * from "babylonjs/Helpers/index";
  74164. export * from "babylonjs/Instrumentation/index";
  74165. export * from "babylonjs/Layers/index";
  74166. export * from "babylonjs/LensFlares/index";
  74167. export * from "babylonjs/Lights/index";
  74168. export * from "babylonjs/Loading/index";
  74169. export * from "babylonjs/Materials/index";
  74170. export * from "babylonjs/Maths/index";
  74171. export * from "babylonjs/Meshes/index";
  74172. export * from "babylonjs/Morph/index";
  74173. export * from "babylonjs/Navigation/index";
  74174. export * from "babylonjs/node";
  74175. export * from "babylonjs/Offline/index";
  74176. export * from "babylonjs/Particles/index";
  74177. export * from "babylonjs/Physics/index";
  74178. export * from "babylonjs/PostProcesses/index";
  74179. export * from "babylonjs/Probes/index";
  74180. export * from "babylonjs/Rendering/index";
  74181. export * from "babylonjs/scene";
  74182. export * from "babylonjs/sceneComponent";
  74183. export * from "babylonjs/Sprites/index";
  74184. export * from "babylonjs/States/index";
  74185. export * from "babylonjs/Misc/index";
  74186. export * from "babylonjs/XR/index";
  74187. export * from "babylonjs/types";
  74188. }
  74189. declare module "babylonjs/Animations/pathCursor" {
  74190. import { Vector3 } from "babylonjs/Maths/math.vector";
  74191. import { Path2 } from "babylonjs/Maths/math.path";
  74192. /**
  74193. * A cursor which tracks a point on a path
  74194. */
  74195. export class PathCursor {
  74196. private path;
  74197. /**
  74198. * Stores path cursor callbacks for when an onchange event is triggered
  74199. */
  74200. private _onchange;
  74201. /**
  74202. * The value of the path cursor
  74203. */
  74204. value: number;
  74205. /**
  74206. * The animation array of the path cursor
  74207. */
  74208. animations: Animation[];
  74209. /**
  74210. * Initializes the path cursor
  74211. * @param path The path to track
  74212. */
  74213. constructor(path: Path2);
  74214. /**
  74215. * Gets the cursor point on the path
  74216. * @returns A point on the path cursor at the cursor location
  74217. */
  74218. getPoint(): Vector3;
  74219. /**
  74220. * Moves the cursor ahead by the step amount
  74221. * @param step The amount to move the cursor forward
  74222. * @returns This path cursor
  74223. */
  74224. moveAhead(step?: number): PathCursor;
  74225. /**
  74226. * Moves the cursor behind by the step amount
  74227. * @param step The amount to move the cursor back
  74228. * @returns This path cursor
  74229. */
  74230. moveBack(step?: number): PathCursor;
  74231. /**
  74232. * Moves the cursor by the step amount
  74233. * If the step amount is greater than one, an exception is thrown
  74234. * @param step The amount to move the cursor
  74235. * @returns This path cursor
  74236. */
  74237. move(step: number): PathCursor;
  74238. /**
  74239. * Ensures that the value is limited between zero and one
  74240. * @returns This path cursor
  74241. */
  74242. private ensureLimits;
  74243. /**
  74244. * Runs onchange callbacks on change (used by the animation engine)
  74245. * @returns This path cursor
  74246. */
  74247. private raiseOnChange;
  74248. /**
  74249. * Executes a function on change
  74250. * @param f A path cursor onchange callback
  74251. * @returns This path cursor
  74252. */
  74253. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74254. }
  74255. }
  74256. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74257. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74258. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74259. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74260. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74261. }
  74262. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74263. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74264. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74265. }
  74266. declare module "babylonjs/Engines/Processors/index" {
  74267. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74268. export * from "babylonjs/Engines/Processors/Expressions/index";
  74269. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74270. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74271. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74272. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74273. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74274. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74275. }
  74276. declare module "babylonjs/Legacy/legacy" {
  74277. import * as Babylon from "babylonjs/index";
  74278. export * from "babylonjs/index";
  74279. }
  74280. declare module "babylonjs/Shaders/blur.fragment" {
  74281. /** @hidden */
  74282. export var blurPixelShader: {
  74283. name: string;
  74284. shader: string;
  74285. };
  74286. }
  74287. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74288. /** @hidden */
  74289. export var pointCloudVertexDeclaration: {
  74290. name: string;
  74291. shader: string;
  74292. };
  74293. }
  74294. declare module "babylonjs" {
  74295. export * from "babylonjs/Legacy/legacy";
  74296. }
  74297. declare module BABYLON {
  74298. /** Alias type for value that can be null */
  74299. export type Nullable<T> = T | null;
  74300. /**
  74301. * Alias type for number that are floats
  74302. * @ignorenaming
  74303. */
  74304. export type float = number;
  74305. /**
  74306. * Alias type for number that are doubles.
  74307. * @ignorenaming
  74308. */
  74309. export type double = number;
  74310. /**
  74311. * Alias type for number that are integer
  74312. * @ignorenaming
  74313. */
  74314. export type int = number;
  74315. /** Alias type for number array or Float32Array */
  74316. export type FloatArray = number[] | Float32Array;
  74317. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74318. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74319. /**
  74320. * Alias for types that can be used by a Buffer or VertexBuffer.
  74321. */
  74322. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74323. /**
  74324. * Alias type for primitive types
  74325. * @ignorenaming
  74326. */
  74327. type Primitive = undefined | null | boolean | string | number | Function;
  74328. /**
  74329. * Type modifier to make all the properties of an object Readonly
  74330. */
  74331. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74332. /**
  74333. * Type modifier to make all the properties of an object Readonly recursively
  74334. */
  74335. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74336. /**
  74337. * Type modifier to make object properties readonly.
  74338. */
  74339. export type DeepImmutableObject<T> = {
  74340. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74341. };
  74342. /** @hidden */
  74343. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74344. }
  74345. }
  74346. declare module BABYLON {
  74347. /**
  74348. * A class serves as a medium between the observable and its observers
  74349. */
  74350. export class EventState {
  74351. /**
  74352. * Create a new EventState
  74353. * @param mask defines the mask associated with this state
  74354. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74355. * @param target defines the original target of the state
  74356. * @param currentTarget defines the current target of the state
  74357. */
  74358. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74359. /**
  74360. * Initialize the current event state
  74361. * @param mask defines the mask associated with this state
  74362. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74363. * @param target defines the original target of the state
  74364. * @param currentTarget defines the current target of the state
  74365. * @returns the current event state
  74366. */
  74367. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74368. /**
  74369. * An Observer can set this property to true to prevent subsequent observers of being notified
  74370. */
  74371. skipNextObservers: boolean;
  74372. /**
  74373. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74374. */
  74375. mask: number;
  74376. /**
  74377. * The object that originally notified the event
  74378. */
  74379. target?: any;
  74380. /**
  74381. * The current object in the bubbling phase
  74382. */
  74383. currentTarget?: any;
  74384. /**
  74385. * This will be populated with the return value of the last function that was executed.
  74386. * If it is the first function in the callback chain it will be the event data.
  74387. */
  74388. lastReturnValue?: any;
  74389. }
  74390. /**
  74391. * Represent an Observer registered to a given Observable object.
  74392. */
  74393. export class Observer<T> {
  74394. /**
  74395. * Defines the callback to call when the observer is notified
  74396. */
  74397. callback: (eventData: T, eventState: EventState) => void;
  74398. /**
  74399. * Defines the mask of the observer (used to filter notifications)
  74400. */
  74401. mask: number;
  74402. /**
  74403. * Defines the current scope used to restore the JS context
  74404. */
  74405. scope: any;
  74406. /** @hidden */
  74407. _willBeUnregistered: boolean;
  74408. /**
  74409. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74410. */
  74411. unregisterOnNextCall: boolean;
  74412. /**
  74413. * Creates a new observer
  74414. * @param callback defines the callback to call when the observer is notified
  74415. * @param mask defines the mask of the observer (used to filter notifications)
  74416. * @param scope defines the current scope used to restore the JS context
  74417. */
  74418. constructor(
  74419. /**
  74420. * Defines the callback to call when the observer is notified
  74421. */
  74422. callback: (eventData: T, eventState: EventState) => void,
  74423. /**
  74424. * Defines the mask of the observer (used to filter notifications)
  74425. */
  74426. mask: number,
  74427. /**
  74428. * Defines the current scope used to restore the JS context
  74429. */
  74430. scope?: any);
  74431. }
  74432. /**
  74433. * Represent a list of observers registered to multiple Observables object.
  74434. */
  74435. export class MultiObserver<T> {
  74436. private _observers;
  74437. private _observables;
  74438. /**
  74439. * Release associated resources
  74440. */
  74441. dispose(): void;
  74442. /**
  74443. * Raise a callback when one of the observable will notify
  74444. * @param observables defines a list of observables to watch
  74445. * @param callback defines the callback to call on notification
  74446. * @param mask defines the mask used to filter notifications
  74447. * @param scope defines the current scope used to restore the JS context
  74448. * @returns the new MultiObserver
  74449. */
  74450. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74451. }
  74452. /**
  74453. * The Observable class is a simple implementation of the Observable pattern.
  74454. *
  74455. * 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.
  74456. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74457. * 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).
  74458. * 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.
  74459. */
  74460. export class Observable<T> {
  74461. private _observers;
  74462. private _eventState;
  74463. private _onObserverAdded;
  74464. /**
  74465. * Gets the list of observers
  74466. */
  74467. get observers(): Array<Observer<T>>;
  74468. /**
  74469. * Creates a new observable
  74470. * @param onObserverAdded defines a callback to call when a new observer is added
  74471. */
  74472. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74473. /**
  74474. * Create a new Observer with the specified callback
  74475. * @param callback the callback that will be executed for that Observer
  74476. * @param mask the mask used to filter observers
  74477. * @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.
  74478. * @param scope optional scope for the callback to be called from
  74479. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74480. * @returns the new observer created for the callback
  74481. */
  74482. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74483. /**
  74484. * Create a new Observer with the specified callback and unregisters after the next notification
  74485. * @param callback the callback that will be executed for that Observer
  74486. * @returns the new observer created for the callback
  74487. */
  74488. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74489. /**
  74490. * Remove an Observer from the Observable object
  74491. * @param observer the instance of the Observer to remove
  74492. * @returns false if it doesn't belong to this Observable
  74493. */
  74494. remove(observer: Nullable<Observer<T>>): boolean;
  74495. /**
  74496. * Remove a callback from the Observable object
  74497. * @param callback the callback to remove
  74498. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74499. * @returns false if it doesn't belong to this Observable
  74500. */
  74501. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74502. private _deferUnregister;
  74503. private _remove;
  74504. /**
  74505. * Moves the observable to the top of the observer list making it get called first when notified
  74506. * @param observer the observer to move
  74507. */
  74508. makeObserverTopPriority(observer: Observer<T>): void;
  74509. /**
  74510. * Moves the observable to the bottom of the observer list making it get called last when notified
  74511. * @param observer the observer to move
  74512. */
  74513. makeObserverBottomPriority(observer: Observer<T>): void;
  74514. /**
  74515. * Notify all Observers by calling their respective callback with the given data
  74516. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74517. * @param eventData defines the data to send to all observers
  74518. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74519. * @param target defines the original target of the state
  74520. * @param currentTarget defines the current target of the state
  74521. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74522. */
  74523. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74524. /**
  74525. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74526. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74527. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74528. * and it is crucial that all callbacks will be executed.
  74529. * The order of the callbacks is kept, callbacks are not executed parallel.
  74530. *
  74531. * @param eventData The data to be sent to each callback
  74532. * @param mask is used to filter observers defaults to -1
  74533. * @param target defines the callback target (see EventState)
  74534. * @param currentTarget defines he current object in the bubbling phase
  74535. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74536. */
  74537. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74538. /**
  74539. * Notify a specific observer
  74540. * @param observer defines the observer to notify
  74541. * @param eventData defines the data to be sent to each callback
  74542. * @param mask is used to filter observers defaults to -1
  74543. */
  74544. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74545. /**
  74546. * Gets a boolean indicating if the observable has at least one observer
  74547. * @returns true is the Observable has at least one Observer registered
  74548. */
  74549. hasObservers(): boolean;
  74550. /**
  74551. * Clear the list of observers
  74552. */
  74553. clear(): void;
  74554. /**
  74555. * Clone the current observable
  74556. * @returns a new observable
  74557. */
  74558. clone(): Observable<T>;
  74559. /**
  74560. * Does this observable handles observer registered with a given mask
  74561. * @param mask defines the mask to be tested
  74562. * @return whether or not one observer registered with the given mask is handeled
  74563. **/
  74564. hasSpecificMask(mask?: number): boolean;
  74565. }
  74566. }
  74567. declare module BABYLON {
  74568. /**
  74569. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74570. * Babylon.js
  74571. */
  74572. export class DomManagement {
  74573. /**
  74574. * Checks if the window object exists
  74575. * @returns true if the window object exists
  74576. */
  74577. static IsWindowObjectExist(): boolean;
  74578. /**
  74579. * Checks if the navigator object exists
  74580. * @returns true if the navigator object exists
  74581. */
  74582. static IsNavigatorAvailable(): boolean;
  74583. /**
  74584. * Extracts text content from a DOM element hierarchy
  74585. * @param element defines the root element
  74586. * @returns a string
  74587. */
  74588. static GetDOMTextContent(element: HTMLElement): string;
  74589. }
  74590. }
  74591. declare module BABYLON {
  74592. /**
  74593. * Logger used througouht the application to allow configuration of
  74594. * the log level required for the messages.
  74595. */
  74596. export class Logger {
  74597. /**
  74598. * No log
  74599. */
  74600. static readonly NoneLogLevel: number;
  74601. /**
  74602. * Only message logs
  74603. */
  74604. static readonly MessageLogLevel: number;
  74605. /**
  74606. * Only warning logs
  74607. */
  74608. static readonly WarningLogLevel: number;
  74609. /**
  74610. * Only error logs
  74611. */
  74612. static readonly ErrorLogLevel: number;
  74613. /**
  74614. * All logs
  74615. */
  74616. static readonly AllLogLevel: number;
  74617. private static _LogCache;
  74618. /**
  74619. * Gets a value indicating the number of loading errors
  74620. * @ignorenaming
  74621. */
  74622. static errorsCount: number;
  74623. /**
  74624. * Callback called when a new log is added
  74625. */
  74626. static OnNewCacheEntry: (entry: string) => void;
  74627. private static _AddLogEntry;
  74628. private static _FormatMessage;
  74629. private static _LogDisabled;
  74630. private static _LogEnabled;
  74631. private static _WarnDisabled;
  74632. private static _WarnEnabled;
  74633. private static _ErrorDisabled;
  74634. private static _ErrorEnabled;
  74635. /**
  74636. * Log a message to the console
  74637. */
  74638. static Log: (message: string) => void;
  74639. /**
  74640. * Write a warning message to the console
  74641. */
  74642. static Warn: (message: string) => void;
  74643. /**
  74644. * Write an error message to the console
  74645. */
  74646. static Error: (message: string) => void;
  74647. /**
  74648. * Gets current log cache (list of logs)
  74649. */
  74650. static get LogCache(): string;
  74651. /**
  74652. * Clears the log cache
  74653. */
  74654. static ClearLogCache(): void;
  74655. /**
  74656. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74657. */
  74658. static set LogLevels(level: number);
  74659. }
  74660. }
  74661. declare module BABYLON {
  74662. /** @hidden */
  74663. export class _TypeStore {
  74664. /** @hidden */
  74665. static RegisteredTypes: {
  74666. [key: string]: Object;
  74667. };
  74668. /** @hidden */
  74669. static GetClass(fqdn: string): any;
  74670. }
  74671. }
  74672. declare module BABYLON {
  74673. /**
  74674. * Helper to manipulate strings
  74675. */
  74676. export class StringTools {
  74677. /**
  74678. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74679. * @param str Source string
  74680. * @param suffix Suffix to search for in the source string
  74681. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74682. */
  74683. static EndsWith(str: string, suffix: string): boolean;
  74684. /**
  74685. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74686. * @param str Source string
  74687. * @param suffix Suffix to search for in the source string
  74688. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74689. */
  74690. static StartsWith(str: string, suffix: string): boolean;
  74691. /**
  74692. * Decodes a buffer into a string
  74693. * @param buffer The buffer to decode
  74694. * @returns The decoded string
  74695. */
  74696. static Decode(buffer: Uint8Array | Uint16Array): string;
  74697. /**
  74698. * Encode a buffer to a base64 string
  74699. * @param buffer defines the buffer to encode
  74700. * @returns the encoded string
  74701. */
  74702. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74703. /**
  74704. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74705. * @param num the number to convert and pad
  74706. * @param length the expected length of the string
  74707. * @returns the padded string
  74708. */
  74709. static PadNumber(num: number, length: number): string;
  74710. }
  74711. }
  74712. declare module BABYLON {
  74713. /**
  74714. * Class containing a set of static utilities functions for deep copy.
  74715. */
  74716. export class DeepCopier {
  74717. /**
  74718. * Tries to copy an object by duplicating every property
  74719. * @param source defines the source object
  74720. * @param destination defines the target object
  74721. * @param doNotCopyList defines a list of properties to avoid
  74722. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74723. */
  74724. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74725. }
  74726. }
  74727. declare module BABYLON {
  74728. /**
  74729. * Class containing a set of static utilities functions for precision date
  74730. */
  74731. export class PrecisionDate {
  74732. /**
  74733. * Gets either window.performance.now() if supported or Date.now() else
  74734. */
  74735. static get Now(): number;
  74736. }
  74737. }
  74738. declare module BABYLON {
  74739. /** @hidden */
  74740. export class _DevTools {
  74741. static WarnImport(name: string): string;
  74742. }
  74743. }
  74744. declare module BABYLON {
  74745. /**
  74746. * Interface used to define the mechanism to get data from the network
  74747. */
  74748. export interface IWebRequest {
  74749. /**
  74750. * Returns client's response url
  74751. */
  74752. responseURL: string;
  74753. /**
  74754. * Returns client's status
  74755. */
  74756. status: number;
  74757. /**
  74758. * Returns client's status as a text
  74759. */
  74760. statusText: string;
  74761. }
  74762. }
  74763. declare module BABYLON {
  74764. /**
  74765. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74766. */
  74767. export class WebRequest implements IWebRequest {
  74768. private _xhr;
  74769. /**
  74770. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74771. * i.e. when loading files, where the server/service expects an Authorization header
  74772. */
  74773. static CustomRequestHeaders: {
  74774. [key: string]: string;
  74775. };
  74776. /**
  74777. * Add callback functions in this array to update all the requests before they get sent to the network
  74778. */
  74779. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74780. private _injectCustomRequestHeaders;
  74781. /**
  74782. * Gets or sets a function to be called when loading progress changes
  74783. */
  74784. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74785. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74786. /**
  74787. * Returns client's state
  74788. */
  74789. get readyState(): number;
  74790. /**
  74791. * Returns client's status
  74792. */
  74793. get status(): number;
  74794. /**
  74795. * Returns client's status as a text
  74796. */
  74797. get statusText(): string;
  74798. /**
  74799. * Returns client's response
  74800. */
  74801. get response(): any;
  74802. /**
  74803. * Returns client's response url
  74804. */
  74805. get responseURL(): string;
  74806. /**
  74807. * Returns client's response as text
  74808. */
  74809. get responseText(): string;
  74810. /**
  74811. * Gets or sets the expected response type
  74812. */
  74813. get responseType(): XMLHttpRequestResponseType;
  74814. set responseType(value: XMLHttpRequestResponseType);
  74815. /** @hidden */
  74816. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74817. /** @hidden */
  74818. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74819. /**
  74820. * Cancels any network activity
  74821. */
  74822. abort(): void;
  74823. /**
  74824. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74825. * @param body defines an optional request body
  74826. */
  74827. send(body?: Document | BodyInit | null): void;
  74828. /**
  74829. * Sets the request method, request URL
  74830. * @param method defines the method to use (GET, POST, etc..)
  74831. * @param url defines the url to connect with
  74832. */
  74833. open(method: string, url: string): void;
  74834. /**
  74835. * Sets the value of a request header.
  74836. * @param name The name of the header whose value is to be set
  74837. * @param value The value to set as the body of the header
  74838. */
  74839. setRequestHeader(name: string, value: string): void;
  74840. /**
  74841. * Get the string containing the text of a particular header's value.
  74842. * @param name The name of the header
  74843. * @returns The string containing the text of the given header name
  74844. */
  74845. getResponseHeader(name: string): Nullable<string>;
  74846. }
  74847. }
  74848. declare module BABYLON {
  74849. /**
  74850. * File request interface
  74851. */
  74852. export interface IFileRequest {
  74853. /**
  74854. * Raised when the request is complete (success or error).
  74855. */
  74856. onCompleteObservable: Observable<IFileRequest>;
  74857. /**
  74858. * Aborts the request for a file.
  74859. */
  74860. abort: () => void;
  74861. }
  74862. }
  74863. declare module BABYLON {
  74864. /**
  74865. * Define options used to create a render target texture
  74866. */
  74867. export class RenderTargetCreationOptions {
  74868. /**
  74869. * Specifies is mipmaps must be generated
  74870. */
  74871. generateMipMaps?: boolean;
  74872. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74873. generateDepthBuffer?: boolean;
  74874. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74875. generateStencilBuffer?: boolean;
  74876. /** Defines texture type (int by default) */
  74877. type?: number;
  74878. /** Defines sampling mode (trilinear by default) */
  74879. samplingMode?: number;
  74880. /** Defines format (RGBA by default) */
  74881. format?: number;
  74882. }
  74883. }
  74884. declare module BABYLON {
  74885. /** Defines the cross module used constants to avoid circular dependncies */
  74886. export class Constants {
  74887. /** Defines that alpha blending is disabled */
  74888. static readonly ALPHA_DISABLE: number;
  74889. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74890. static readonly ALPHA_ADD: number;
  74891. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74892. static readonly ALPHA_COMBINE: number;
  74893. /** Defines that alpha blending is DEST - SRC * DEST */
  74894. static readonly ALPHA_SUBTRACT: number;
  74895. /** Defines that alpha blending is SRC * DEST */
  74896. static readonly ALPHA_MULTIPLY: number;
  74897. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74898. static readonly ALPHA_MAXIMIZED: number;
  74899. /** Defines that alpha blending is SRC + DEST */
  74900. static readonly ALPHA_ONEONE: number;
  74901. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74902. static readonly ALPHA_PREMULTIPLIED: number;
  74903. /**
  74904. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74905. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74906. */
  74907. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74908. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74909. static readonly ALPHA_INTERPOLATE: number;
  74910. /**
  74911. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74912. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74913. */
  74914. static readonly ALPHA_SCREENMODE: number;
  74915. /**
  74916. * Defines that alpha blending is SRC + DST
  74917. * Alpha will be set to SRC ALPHA + DST ALPHA
  74918. */
  74919. static readonly ALPHA_ONEONE_ONEONE: number;
  74920. /**
  74921. * Defines that alpha blending is SRC * DST ALPHA + DST
  74922. * Alpha will be set to 0
  74923. */
  74924. static readonly ALPHA_ALPHATOCOLOR: number;
  74925. /**
  74926. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74927. */
  74928. static readonly ALPHA_REVERSEONEMINUS: number;
  74929. /**
  74930. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74931. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74932. */
  74933. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74934. /**
  74935. * Defines that alpha blending is SRC + DST
  74936. * Alpha will be set to SRC ALPHA
  74937. */
  74938. static readonly ALPHA_ONEONE_ONEZERO: number;
  74939. /**
  74940. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74941. * Alpha will be set to DST ALPHA
  74942. */
  74943. static readonly ALPHA_EXCLUSION: number;
  74944. /** Defines that alpha blending equation a SUM */
  74945. static readonly ALPHA_EQUATION_ADD: number;
  74946. /** Defines that alpha blending equation a SUBSTRACTION */
  74947. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74948. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74949. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74950. /** Defines that alpha blending equation a MAX operation */
  74951. static readonly ALPHA_EQUATION_MAX: number;
  74952. /** Defines that alpha blending equation a MIN operation */
  74953. static readonly ALPHA_EQUATION_MIN: number;
  74954. /**
  74955. * Defines that alpha blending equation a DARKEN operation:
  74956. * It takes the min of the src and sums the alpha channels.
  74957. */
  74958. static readonly ALPHA_EQUATION_DARKEN: number;
  74959. /** Defines that the ressource is not delayed*/
  74960. static readonly DELAYLOADSTATE_NONE: number;
  74961. /** Defines that the ressource was successfully delay loaded */
  74962. static readonly DELAYLOADSTATE_LOADED: number;
  74963. /** Defines that the ressource is currently delay loading */
  74964. static readonly DELAYLOADSTATE_LOADING: number;
  74965. /** Defines that the ressource is delayed and has not started loading */
  74966. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74968. static readonly NEVER: number;
  74969. /** 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 */
  74970. static readonly ALWAYS: number;
  74971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74972. static readonly LESS: number;
  74973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74974. static readonly EQUAL: number;
  74975. /** 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 */
  74976. static readonly LEQUAL: number;
  74977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74978. static readonly GREATER: number;
  74979. /** 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 */
  74980. static readonly GEQUAL: number;
  74981. /** 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 */
  74982. static readonly NOTEQUAL: number;
  74983. /** Passed to stencilOperation to specify that stencil value must be kept */
  74984. static readonly KEEP: number;
  74985. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74986. static readonly REPLACE: number;
  74987. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74988. static readonly INCR: number;
  74989. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74990. static readonly DECR: number;
  74991. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74992. static readonly INVERT: number;
  74993. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74994. static readonly INCR_WRAP: number;
  74995. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74996. static readonly DECR_WRAP: number;
  74997. /** Texture is not repeating outside of 0..1 UVs */
  74998. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74999. /** Texture is repeating outside of 0..1 UVs */
  75000. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  75001. /** Texture is repeating and mirrored */
  75002. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  75003. /** ALPHA */
  75004. static readonly TEXTUREFORMAT_ALPHA: number;
  75005. /** LUMINANCE */
  75006. static readonly TEXTUREFORMAT_LUMINANCE: number;
  75007. /** LUMINANCE_ALPHA */
  75008. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  75009. /** RGB */
  75010. static readonly TEXTUREFORMAT_RGB: number;
  75011. /** RGBA */
  75012. static readonly TEXTUREFORMAT_RGBA: number;
  75013. /** RED */
  75014. static readonly TEXTUREFORMAT_RED: number;
  75015. /** RED (2nd reference) */
  75016. static readonly TEXTUREFORMAT_R: number;
  75017. /** RG */
  75018. static readonly TEXTUREFORMAT_RG: number;
  75019. /** RED_INTEGER */
  75020. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  75021. /** RED_INTEGER (2nd reference) */
  75022. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75023. /** RG_INTEGER */
  75024. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75025. /** RGB_INTEGER */
  75026. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75027. /** RGBA_INTEGER */
  75028. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75029. /** UNSIGNED_BYTE */
  75030. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75031. /** UNSIGNED_BYTE (2nd reference) */
  75032. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75033. /** FLOAT */
  75034. static readonly TEXTURETYPE_FLOAT: number;
  75035. /** HALF_FLOAT */
  75036. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75037. /** BYTE */
  75038. static readonly TEXTURETYPE_BYTE: number;
  75039. /** SHORT */
  75040. static readonly TEXTURETYPE_SHORT: number;
  75041. /** UNSIGNED_SHORT */
  75042. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75043. /** INT */
  75044. static readonly TEXTURETYPE_INT: number;
  75045. /** UNSIGNED_INT */
  75046. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75047. /** UNSIGNED_SHORT_4_4_4_4 */
  75048. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75049. /** UNSIGNED_SHORT_5_5_5_1 */
  75050. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75051. /** UNSIGNED_SHORT_5_6_5 */
  75052. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75053. /** UNSIGNED_INT_2_10_10_10_REV */
  75054. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75055. /** UNSIGNED_INT_24_8 */
  75056. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75057. /** UNSIGNED_INT_10F_11F_11F_REV */
  75058. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75059. /** UNSIGNED_INT_5_9_9_9_REV */
  75060. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75061. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75062. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75063. /** nearest is mag = nearest and min = nearest and no mip */
  75064. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75065. /** mag = nearest and min = nearest and mip = none */
  75066. static readonly TEXTURE_NEAREST_NEAREST: number;
  75067. /** Bilinear is mag = linear and min = linear and no mip */
  75068. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75069. /** mag = linear and min = linear and mip = none */
  75070. static readonly TEXTURE_LINEAR_LINEAR: number;
  75071. /** Trilinear is mag = linear and min = linear and mip = linear */
  75072. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75073. /** Trilinear is mag = linear and min = linear and mip = linear */
  75074. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75075. /** mag = nearest and min = nearest and mip = nearest */
  75076. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75077. /** mag = nearest and min = linear and mip = nearest */
  75078. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75079. /** mag = nearest and min = linear and mip = linear */
  75080. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75081. /** mag = nearest and min = linear and mip = none */
  75082. static readonly TEXTURE_NEAREST_LINEAR: number;
  75083. /** nearest is mag = nearest and min = nearest and mip = linear */
  75084. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75085. /** mag = linear and min = nearest and mip = nearest */
  75086. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75087. /** mag = linear and min = nearest and mip = linear */
  75088. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75089. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75090. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75091. /** mag = linear and min = nearest and mip = none */
  75092. static readonly TEXTURE_LINEAR_NEAREST: number;
  75093. /** Explicit coordinates mode */
  75094. static readonly TEXTURE_EXPLICIT_MODE: number;
  75095. /** Spherical coordinates mode */
  75096. static readonly TEXTURE_SPHERICAL_MODE: number;
  75097. /** Planar coordinates mode */
  75098. static readonly TEXTURE_PLANAR_MODE: number;
  75099. /** Cubic coordinates mode */
  75100. static readonly TEXTURE_CUBIC_MODE: number;
  75101. /** Projection coordinates mode */
  75102. static readonly TEXTURE_PROJECTION_MODE: number;
  75103. /** Skybox coordinates mode */
  75104. static readonly TEXTURE_SKYBOX_MODE: number;
  75105. /** Inverse Cubic coordinates mode */
  75106. static readonly TEXTURE_INVCUBIC_MODE: number;
  75107. /** Equirectangular coordinates mode */
  75108. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75109. /** Equirectangular Fixed coordinates mode */
  75110. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75111. /** Equirectangular Fixed Mirrored coordinates mode */
  75112. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75113. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75114. static readonly SCALEMODE_FLOOR: number;
  75115. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75116. static readonly SCALEMODE_NEAREST: number;
  75117. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75118. static readonly SCALEMODE_CEILING: number;
  75119. /**
  75120. * The dirty texture flag value
  75121. */
  75122. static readonly MATERIAL_TextureDirtyFlag: number;
  75123. /**
  75124. * The dirty light flag value
  75125. */
  75126. static readonly MATERIAL_LightDirtyFlag: number;
  75127. /**
  75128. * The dirty fresnel flag value
  75129. */
  75130. static readonly MATERIAL_FresnelDirtyFlag: number;
  75131. /**
  75132. * The dirty attribute flag value
  75133. */
  75134. static readonly MATERIAL_AttributesDirtyFlag: number;
  75135. /**
  75136. * The dirty misc flag value
  75137. */
  75138. static readonly MATERIAL_MiscDirtyFlag: number;
  75139. /**
  75140. * The all dirty flag value
  75141. */
  75142. static readonly MATERIAL_AllDirtyFlag: number;
  75143. /**
  75144. * Returns the triangle fill mode
  75145. */
  75146. static readonly MATERIAL_TriangleFillMode: number;
  75147. /**
  75148. * Returns the wireframe mode
  75149. */
  75150. static readonly MATERIAL_WireFrameFillMode: number;
  75151. /**
  75152. * Returns the point fill mode
  75153. */
  75154. static readonly MATERIAL_PointFillMode: number;
  75155. /**
  75156. * Returns the point list draw mode
  75157. */
  75158. static readonly MATERIAL_PointListDrawMode: number;
  75159. /**
  75160. * Returns the line list draw mode
  75161. */
  75162. static readonly MATERIAL_LineListDrawMode: number;
  75163. /**
  75164. * Returns the line loop draw mode
  75165. */
  75166. static readonly MATERIAL_LineLoopDrawMode: number;
  75167. /**
  75168. * Returns the line strip draw mode
  75169. */
  75170. static readonly MATERIAL_LineStripDrawMode: number;
  75171. /**
  75172. * Returns the triangle strip draw mode
  75173. */
  75174. static readonly MATERIAL_TriangleStripDrawMode: number;
  75175. /**
  75176. * Returns the triangle fan draw mode
  75177. */
  75178. static readonly MATERIAL_TriangleFanDrawMode: number;
  75179. /**
  75180. * Stores the clock-wise side orientation
  75181. */
  75182. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75183. /**
  75184. * Stores the counter clock-wise side orientation
  75185. */
  75186. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75187. /**
  75188. * Nothing
  75189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75190. */
  75191. static readonly ACTION_NothingTrigger: number;
  75192. /**
  75193. * On pick
  75194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75195. */
  75196. static readonly ACTION_OnPickTrigger: number;
  75197. /**
  75198. * On left pick
  75199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75200. */
  75201. static readonly ACTION_OnLeftPickTrigger: number;
  75202. /**
  75203. * On right pick
  75204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75205. */
  75206. static readonly ACTION_OnRightPickTrigger: number;
  75207. /**
  75208. * On center pick
  75209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75210. */
  75211. static readonly ACTION_OnCenterPickTrigger: number;
  75212. /**
  75213. * On pick down
  75214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75215. */
  75216. static readonly ACTION_OnPickDownTrigger: number;
  75217. /**
  75218. * On double pick
  75219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75220. */
  75221. static readonly ACTION_OnDoublePickTrigger: number;
  75222. /**
  75223. * On pick up
  75224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75225. */
  75226. static readonly ACTION_OnPickUpTrigger: number;
  75227. /**
  75228. * On pick out.
  75229. * This trigger will only be raised if you also declared a OnPickDown
  75230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75231. */
  75232. static readonly ACTION_OnPickOutTrigger: number;
  75233. /**
  75234. * On long press
  75235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75236. */
  75237. static readonly ACTION_OnLongPressTrigger: number;
  75238. /**
  75239. * On pointer over
  75240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75241. */
  75242. static readonly ACTION_OnPointerOverTrigger: number;
  75243. /**
  75244. * On pointer out
  75245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75246. */
  75247. static readonly ACTION_OnPointerOutTrigger: number;
  75248. /**
  75249. * On every frame
  75250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75251. */
  75252. static readonly ACTION_OnEveryFrameTrigger: number;
  75253. /**
  75254. * On intersection enter
  75255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75256. */
  75257. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75258. /**
  75259. * On intersection exit
  75260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75261. */
  75262. static readonly ACTION_OnIntersectionExitTrigger: number;
  75263. /**
  75264. * On key down
  75265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75266. */
  75267. static readonly ACTION_OnKeyDownTrigger: number;
  75268. /**
  75269. * On key up
  75270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75271. */
  75272. static readonly ACTION_OnKeyUpTrigger: number;
  75273. /**
  75274. * Billboard mode will only apply to Y axis
  75275. */
  75276. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75277. /**
  75278. * Billboard mode will apply to all axes
  75279. */
  75280. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75281. /**
  75282. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75283. */
  75284. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75285. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75286. * Test order :
  75287. * Is the bounding sphere outside the frustum ?
  75288. * If not, are the bounding box vertices outside the frustum ?
  75289. * It not, then the cullable object is in the frustum.
  75290. */
  75291. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75292. /** Culling strategy : Bounding Sphere Only.
  75293. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75294. * It's also less accurate than the standard because some not visible objects can still be selected.
  75295. * Test : is the bounding sphere outside the frustum ?
  75296. * If not, then the cullable object is in the frustum.
  75297. */
  75298. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75299. /** Culling strategy : Optimistic Inclusion.
  75300. * This in an inclusion test first, then the standard exclusion test.
  75301. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75302. * 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.
  75303. * Anyway, it's as accurate as the standard strategy.
  75304. * Test :
  75305. * Is the cullable object bounding sphere center in the frustum ?
  75306. * If not, apply the default culling strategy.
  75307. */
  75308. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75309. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75310. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75311. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75312. * 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.
  75313. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75314. * Test :
  75315. * Is the cullable object bounding sphere center in the frustum ?
  75316. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75317. */
  75318. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75319. /**
  75320. * No logging while loading
  75321. */
  75322. static readonly SCENELOADER_NO_LOGGING: number;
  75323. /**
  75324. * Minimal logging while loading
  75325. */
  75326. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75327. /**
  75328. * Summary logging while loading
  75329. */
  75330. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75331. /**
  75332. * Detailled logging while loading
  75333. */
  75334. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75335. }
  75336. }
  75337. declare module BABYLON {
  75338. /**
  75339. * This represents the required contract to create a new type of texture loader.
  75340. */
  75341. export interface IInternalTextureLoader {
  75342. /**
  75343. * Defines wether the loader supports cascade loading the different faces.
  75344. */
  75345. supportCascades: boolean;
  75346. /**
  75347. * This returns if the loader support the current file information.
  75348. * @param extension defines the file extension of the file being loaded
  75349. * @returns true if the loader can load the specified file
  75350. */
  75351. canLoad(extension: string): boolean;
  75352. /**
  75353. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75354. * @param data contains the texture data
  75355. * @param texture defines the BabylonJS internal texture
  75356. * @param createPolynomials will be true if polynomials have been requested
  75357. * @param onLoad defines the callback to trigger once the texture is ready
  75358. * @param onError defines the callback to trigger in case of error
  75359. */
  75360. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75361. /**
  75362. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75363. * @param data contains the texture data
  75364. * @param texture defines the BabylonJS internal texture
  75365. * @param callback defines the method to call once ready to upload
  75366. */
  75367. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75368. }
  75369. }
  75370. declare module BABYLON {
  75371. /**
  75372. * Class used to store and describe the pipeline context associated with an effect
  75373. */
  75374. export interface IPipelineContext {
  75375. /**
  75376. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75377. */
  75378. isAsync: boolean;
  75379. /**
  75380. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75381. */
  75382. isReady: boolean;
  75383. /** @hidden */
  75384. _getVertexShaderCode(): string | null;
  75385. /** @hidden */
  75386. _getFragmentShaderCode(): string | null;
  75387. /** @hidden */
  75388. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75389. }
  75390. }
  75391. declare module BABYLON {
  75392. /**
  75393. * Class used to store gfx data (like WebGLBuffer)
  75394. */
  75395. export class DataBuffer {
  75396. /**
  75397. * Gets or sets the number of objects referencing this buffer
  75398. */
  75399. references: number;
  75400. /** Gets or sets the size of the underlying buffer */
  75401. capacity: number;
  75402. /**
  75403. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75404. */
  75405. is32Bits: boolean;
  75406. /**
  75407. * Gets the underlying buffer
  75408. */
  75409. get underlyingResource(): any;
  75410. }
  75411. }
  75412. declare module BABYLON {
  75413. /** @hidden */
  75414. export interface IShaderProcessor {
  75415. attributeProcessor?: (attribute: string) => string;
  75416. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75417. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75418. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75419. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75420. lineProcessor?: (line: string, isFragment: boolean) => string;
  75421. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75422. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75423. }
  75424. }
  75425. declare module BABYLON {
  75426. /** @hidden */
  75427. export interface ProcessingOptions {
  75428. defines: string[];
  75429. indexParameters: any;
  75430. isFragment: boolean;
  75431. shouldUseHighPrecisionShader: boolean;
  75432. supportsUniformBuffers: boolean;
  75433. shadersRepository: string;
  75434. includesShadersStore: {
  75435. [key: string]: string;
  75436. };
  75437. processor?: IShaderProcessor;
  75438. version: string;
  75439. platformName: string;
  75440. lookForClosingBracketForUniformBuffer?: boolean;
  75441. }
  75442. }
  75443. declare module BABYLON {
  75444. /** @hidden */
  75445. export class ShaderCodeNode {
  75446. line: string;
  75447. children: ShaderCodeNode[];
  75448. additionalDefineKey?: string;
  75449. additionalDefineValue?: string;
  75450. isValid(preprocessors: {
  75451. [key: string]: string;
  75452. }): boolean;
  75453. process(preprocessors: {
  75454. [key: string]: string;
  75455. }, options: ProcessingOptions): string;
  75456. }
  75457. }
  75458. declare module BABYLON {
  75459. /** @hidden */
  75460. export class ShaderCodeCursor {
  75461. private _lines;
  75462. lineIndex: number;
  75463. get currentLine(): string;
  75464. get canRead(): boolean;
  75465. set lines(value: string[]);
  75466. }
  75467. }
  75468. declare module BABYLON {
  75469. /** @hidden */
  75470. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75471. process(preprocessors: {
  75472. [key: string]: string;
  75473. }, options: ProcessingOptions): string;
  75474. }
  75475. }
  75476. declare module BABYLON {
  75477. /** @hidden */
  75478. export class ShaderDefineExpression {
  75479. isTrue(preprocessors: {
  75480. [key: string]: string;
  75481. }): boolean;
  75482. private static _OperatorPriority;
  75483. private static _Stack;
  75484. static postfixToInfix(postfix: string[]): string;
  75485. static infixToPostfix(infix: string): string[];
  75486. }
  75487. }
  75488. declare module BABYLON {
  75489. /** @hidden */
  75490. export class ShaderCodeTestNode extends ShaderCodeNode {
  75491. testExpression: ShaderDefineExpression;
  75492. isValid(preprocessors: {
  75493. [key: string]: string;
  75494. }): boolean;
  75495. }
  75496. }
  75497. declare module BABYLON {
  75498. /** @hidden */
  75499. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75500. define: string;
  75501. not: boolean;
  75502. constructor(define: string, not?: boolean);
  75503. isTrue(preprocessors: {
  75504. [key: string]: string;
  75505. }): boolean;
  75506. }
  75507. }
  75508. declare module BABYLON {
  75509. /** @hidden */
  75510. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75511. leftOperand: ShaderDefineExpression;
  75512. rightOperand: ShaderDefineExpression;
  75513. isTrue(preprocessors: {
  75514. [key: string]: string;
  75515. }): boolean;
  75516. }
  75517. }
  75518. declare module BABYLON {
  75519. /** @hidden */
  75520. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75521. leftOperand: ShaderDefineExpression;
  75522. rightOperand: ShaderDefineExpression;
  75523. isTrue(preprocessors: {
  75524. [key: string]: string;
  75525. }): boolean;
  75526. }
  75527. }
  75528. declare module BABYLON {
  75529. /** @hidden */
  75530. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75531. define: string;
  75532. operand: string;
  75533. testValue: string;
  75534. constructor(define: string, operand: string, testValue: string);
  75535. isTrue(preprocessors: {
  75536. [key: string]: string;
  75537. }): boolean;
  75538. }
  75539. }
  75540. declare module BABYLON {
  75541. /**
  75542. * Class used to enable access to offline support
  75543. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75544. */
  75545. export interface IOfflineProvider {
  75546. /**
  75547. * Gets a boolean indicating if scene must be saved in the database
  75548. */
  75549. enableSceneOffline: boolean;
  75550. /**
  75551. * Gets a boolean indicating if textures must be saved in the database
  75552. */
  75553. enableTexturesOffline: boolean;
  75554. /**
  75555. * Open the offline support and make it available
  75556. * @param successCallback defines the callback to call on success
  75557. * @param errorCallback defines the callback to call on error
  75558. */
  75559. open(successCallback: () => void, errorCallback: () => void): void;
  75560. /**
  75561. * Loads an image from the offline support
  75562. * @param url defines the url to load from
  75563. * @param image defines the target DOM image
  75564. */
  75565. loadImage(url: string, image: HTMLImageElement): void;
  75566. /**
  75567. * Loads a file from offline support
  75568. * @param url defines the URL to load from
  75569. * @param sceneLoaded defines a callback to call on success
  75570. * @param progressCallBack defines a callback to call when progress changed
  75571. * @param errorCallback defines a callback to call on error
  75572. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75573. */
  75574. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75575. }
  75576. }
  75577. declare module BABYLON {
  75578. /**
  75579. * Class used to help managing file picking and drag'n'drop
  75580. * File Storage
  75581. */
  75582. export class FilesInputStore {
  75583. /**
  75584. * List of files ready to be loaded
  75585. */
  75586. static FilesToLoad: {
  75587. [key: string]: File;
  75588. };
  75589. }
  75590. }
  75591. declare module BABYLON {
  75592. /**
  75593. * Class used to define a retry strategy when error happens while loading assets
  75594. */
  75595. export class RetryStrategy {
  75596. /**
  75597. * Function used to defines an exponential back off strategy
  75598. * @param maxRetries defines the maximum number of retries (3 by default)
  75599. * @param baseInterval defines the interval between retries
  75600. * @returns the strategy function to use
  75601. */
  75602. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75603. }
  75604. }
  75605. declare module BABYLON {
  75606. /**
  75607. * @ignore
  75608. * Application error to support additional information when loading a file
  75609. */
  75610. export abstract class BaseError extends Error {
  75611. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75612. }
  75613. }
  75614. declare module BABYLON {
  75615. /** @ignore */
  75616. export class LoadFileError extends BaseError {
  75617. request?: WebRequest;
  75618. file?: File;
  75619. /**
  75620. * Creates a new LoadFileError
  75621. * @param message defines the message of the error
  75622. * @param request defines the optional web request
  75623. * @param file defines the optional file
  75624. */
  75625. constructor(message: string, object?: WebRequest | File);
  75626. }
  75627. /** @ignore */
  75628. export class RequestFileError extends BaseError {
  75629. request: WebRequest;
  75630. /**
  75631. * Creates a new LoadFileError
  75632. * @param message defines the message of the error
  75633. * @param request defines the optional web request
  75634. */
  75635. constructor(message: string, request: WebRequest);
  75636. }
  75637. /** @ignore */
  75638. export class ReadFileError extends BaseError {
  75639. file: File;
  75640. /**
  75641. * Creates a new ReadFileError
  75642. * @param message defines the message of the error
  75643. * @param file defines the optional file
  75644. */
  75645. constructor(message: string, file: File);
  75646. }
  75647. /**
  75648. * @hidden
  75649. */
  75650. export class FileTools {
  75651. /**
  75652. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75653. */
  75654. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75655. /**
  75656. * Gets or sets the base URL to use to load assets
  75657. */
  75658. static BaseUrl: string;
  75659. /**
  75660. * Default behaviour for cors in the application.
  75661. * It can be a string if the expected behavior is identical in the entire app.
  75662. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75663. */
  75664. static CorsBehavior: string | ((url: string | string[]) => string);
  75665. /**
  75666. * Gets or sets a function used to pre-process url before using them to load assets
  75667. */
  75668. static PreprocessUrl: (url: string) => string;
  75669. /**
  75670. * Removes unwanted characters from an url
  75671. * @param url defines the url to clean
  75672. * @returns the cleaned url
  75673. */
  75674. private static _CleanUrl;
  75675. /**
  75676. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75677. * @param url define the url we are trying
  75678. * @param element define the dom element where to configure the cors policy
  75679. */
  75680. static SetCorsBehavior(url: string | string[], element: {
  75681. crossOrigin: string | null;
  75682. }): void;
  75683. /**
  75684. * Loads an image as an HTMLImageElement.
  75685. * @param input url string, ArrayBuffer, or Blob to load
  75686. * @param onLoad callback called when the image successfully loads
  75687. * @param onError callback called when the image fails to load
  75688. * @param offlineProvider offline provider for caching
  75689. * @param mimeType optional mime type
  75690. * @returns the HTMLImageElement of the loaded image
  75691. */
  75692. 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>;
  75693. /**
  75694. * Reads a file from a File object
  75695. * @param file defines the file to load
  75696. * @param onSuccess defines the callback to call when data is loaded
  75697. * @param onProgress defines the callback to call during loading process
  75698. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75699. * @param onError defines the callback to call when an error occurs
  75700. * @returns a file request object
  75701. */
  75702. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75703. /**
  75704. * Loads a file from a url
  75705. * @param url url to load
  75706. * @param onSuccess callback called when the file successfully loads
  75707. * @param onProgress callback called while file is loading (if the server supports this mode)
  75708. * @param offlineProvider defines the offline provider for caching
  75709. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75710. * @param onError callback called when the file fails to load
  75711. * @returns a file request object
  75712. */
  75713. 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;
  75714. /**
  75715. * Loads a file
  75716. * @param url url to load
  75717. * @param onSuccess callback called when the file successfully loads
  75718. * @param onProgress callback called while file is loading (if the server supports this mode)
  75719. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75720. * @param onError callback called when the file fails to load
  75721. * @param onOpened callback called when the web request is opened
  75722. * @returns a file request object
  75723. */
  75724. 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;
  75725. /**
  75726. * Checks if the loaded document was accessed via `file:`-Protocol.
  75727. * @returns boolean
  75728. */
  75729. static IsFileURL(): boolean;
  75730. }
  75731. }
  75732. declare module BABYLON {
  75733. /** @hidden */
  75734. export class ShaderProcessor {
  75735. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75736. private static _ProcessPrecision;
  75737. private static _ExtractOperation;
  75738. private static _BuildSubExpression;
  75739. private static _BuildExpression;
  75740. private static _MoveCursorWithinIf;
  75741. private static _MoveCursor;
  75742. private static _EvaluatePreProcessors;
  75743. private static _PreparePreProcessors;
  75744. private static _ProcessShaderConversion;
  75745. private static _ProcessIncludes;
  75746. /**
  75747. * Loads a file from a url
  75748. * @param url url to load
  75749. * @param onSuccess callback called when the file successfully loads
  75750. * @param onProgress callback called while file is loading (if the server supports this mode)
  75751. * @param offlineProvider defines the offline provider for caching
  75752. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75753. * @param onError callback called when the file fails to load
  75754. * @returns a file request object
  75755. * @hidden
  75756. */
  75757. 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;
  75758. }
  75759. }
  75760. declare module BABYLON {
  75761. /**
  75762. * @hidden
  75763. */
  75764. export interface IColor4Like {
  75765. r: float;
  75766. g: float;
  75767. b: float;
  75768. a: float;
  75769. }
  75770. /**
  75771. * @hidden
  75772. */
  75773. export interface IColor3Like {
  75774. r: float;
  75775. g: float;
  75776. b: float;
  75777. }
  75778. /**
  75779. * @hidden
  75780. */
  75781. export interface IVector4Like {
  75782. x: float;
  75783. y: float;
  75784. z: float;
  75785. w: float;
  75786. }
  75787. /**
  75788. * @hidden
  75789. */
  75790. export interface IVector3Like {
  75791. x: float;
  75792. y: float;
  75793. z: float;
  75794. }
  75795. /**
  75796. * @hidden
  75797. */
  75798. export interface IVector2Like {
  75799. x: float;
  75800. y: float;
  75801. }
  75802. /**
  75803. * @hidden
  75804. */
  75805. export interface IMatrixLike {
  75806. toArray(): DeepImmutable<Float32Array>;
  75807. updateFlag: int;
  75808. }
  75809. /**
  75810. * @hidden
  75811. */
  75812. export interface IViewportLike {
  75813. x: float;
  75814. y: float;
  75815. width: float;
  75816. height: float;
  75817. }
  75818. /**
  75819. * @hidden
  75820. */
  75821. export interface IPlaneLike {
  75822. normal: IVector3Like;
  75823. d: float;
  75824. normalize(): void;
  75825. }
  75826. }
  75827. declare module BABYLON {
  75828. /**
  75829. * Interface used to define common properties for effect fallbacks
  75830. */
  75831. export interface IEffectFallbacks {
  75832. /**
  75833. * Removes the defines that should be removed when falling back.
  75834. * @param currentDefines defines the current define statements for the shader.
  75835. * @param effect defines the current effect we try to compile
  75836. * @returns The resulting defines with defines of the current rank removed.
  75837. */
  75838. reduce(currentDefines: string, effect: Effect): string;
  75839. /**
  75840. * Removes the fallback from the bound mesh.
  75841. */
  75842. unBindMesh(): void;
  75843. /**
  75844. * Checks to see if more fallbacks are still availible.
  75845. */
  75846. hasMoreFallbacks: boolean;
  75847. }
  75848. }
  75849. declare module BABYLON {
  75850. /**
  75851. * Class used to evalaute queries containing `and` and `or` operators
  75852. */
  75853. export class AndOrNotEvaluator {
  75854. /**
  75855. * Evaluate a query
  75856. * @param query defines the query to evaluate
  75857. * @param evaluateCallback defines the callback used to filter result
  75858. * @returns true if the query matches
  75859. */
  75860. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75861. private static _HandleParenthesisContent;
  75862. private static _SimplifyNegation;
  75863. }
  75864. }
  75865. declare module BABYLON {
  75866. /**
  75867. * Class used to store custom tags
  75868. */
  75869. export class Tags {
  75870. /**
  75871. * Adds support for tags on the given object
  75872. * @param obj defines the object to use
  75873. */
  75874. static EnableFor(obj: any): void;
  75875. /**
  75876. * Removes tags support
  75877. * @param obj defines the object to use
  75878. */
  75879. static DisableFor(obj: any): void;
  75880. /**
  75881. * Gets a boolean indicating if the given object has tags
  75882. * @param obj defines the object to use
  75883. * @returns a boolean
  75884. */
  75885. static HasTags(obj: any): boolean;
  75886. /**
  75887. * Gets the tags available on a given object
  75888. * @param obj defines the object to use
  75889. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75890. * @returns the tags
  75891. */
  75892. static GetTags(obj: any, asString?: boolean): any;
  75893. /**
  75894. * Adds tags to an object
  75895. * @param obj defines the object to use
  75896. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75897. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75898. */
  75899. static AddTagsTo(obj: any, tagsString: string): void;
  75900. /**
  75901. * @hidden
  75902. */
  75903. static _AddTagTo(obj: any, tag: string): void;
  75904. /**
  75905. * Removes specific tags from a specific object
  75906. * @param obj defines the object to use
  75907. * @param tagsString defines the tags to remove
  75908. */
  75909. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75910. /**
  75911. * @hidden
  75912. */
  75913. static _RemoveTagFrom(obj: any, tag: string): void;
  75914. /**
  75915. * Defines if tags hosted on an object match a given query
  75916. * @param obj defines the object to use
  75917. * @param tagsQuery defines the tag query
  75918. * @returns a boolean
  75919. */
  75920. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75921. }
  75922. }
  75923. declare module BABYLON {
  75924. /**
  75925. * Scalar computation library
  75926. */
  75927. export class Scalar {
  75928. /**
  75929. * Two pi constants convenient for computation.
  75930. */
  75931. static TwoPi: number;
  75932. /**
  75933. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75934. * @param a number
  75935. * @param b number
  75936. * @param epsilon (default = 1.401298E-45)
  75937. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75938. */
  75939. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75940. /**
  75941. * Returns a string : the upper case translation of the number i to hexadecimal.
  75942. * @param i number
  75943. * @returns the upper case translation of the number i to hexadecimal.
  75944. */
  75945. static ToHex(i: number): string;
  75946. /**
  75947. * Returns -1 if value is negative and +1 is value is positive.
  75948. * @param value the value
  75949. * @returns the value itself if it's equal to zero.
  75950. */
  75951. static Sign(value: number): number;
  75952. /**
  75953. * Returns the value itself if it's between min and max.
  75954. * Returns min if the value is lower than min.
  75955. * Returns max if the value is greater than max.
  75956. * @param value the value to clmap
  75957. * @param min the min value to clamp to (default: 0)
  75958. * @param max the max value to clamp to (default: 1)
  75959. * @returns the clamped value
  75960. */
  75961. static Clamp(value: number, min?: number, max?: number): number;
  75962. /**
  75963. * the log2 of value.
  75964. * @param value the value to compute log2 of
  75965. * @returns the log2 of value.
  75966. */
  75967. static Log2(value: number): number;
  75968. /**
  75969. * Loops the value, so that it is never larger than length and never smaller than 0.
  75970. *
  75971. * This is similar to the modulo operator but it works with floating point numbers.
  75972. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75973. * With t = 5 and length = 2.5, the result would be 0.0.
  75974. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75975. * @param value the value
  75976. * @param length the length
  75977. * @returns the looped value
  75978. */
  75979. static Repeat(value: number, length: number): number;
  75980. /**
  75981. * Normalize the value between 0.0 and 1.0 using min and max values
  75982. * @param value value to normalize
  75983. * @param min max to normalize between
  75984. * @param max min to normalize between
  75985. * @returns the normalized value
  75986. */
  75987. static Normalize(value: number, min: number, max: number): number;
  75988. /**
  75989. * Denormalize the value from 0.0 and 1.0 using min and max values
  75990. * @param normalized value to denormalize
  75991. * @param min max to denormalize between
  75992. * @param max min to denormalize between
  75993. * @returns the denormalized value
  75994. */
  75995. static Denormalize(normalized: number, min: number, max: number): number;
  75996. /**
  75997. * Calculates the shortest difference between two given angles given in degrees.
  75998. * @param current current angle in degrees
  75999. * @param target target angle in degrees
  76000. * @returns the delta
  76001. */
  76002. static DeltaAngle(current: number, target: number): number;
  76003. /**
  76004. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  76005. * @param tx value
  76006. * @param length length
  76007. * @returns The returned value will move back and forth between 0 and length
  76008. */
  76009. static PingPong(tx: number, length: number): number;
  76010. /**
  76011. * Interpolates between min and max with smoothing at the limits.
  76012. *
  76013. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  76014. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  76015. * @param from from
  76016. * @param to to
  76017. * @param tx value
  76018. * @returns the smooth stepped value
  76019. */
  76020. static SmoothStep(from: number, to: number, tx: number): number;
  76021. /**
  76022. * Moves a value current towards target.
  76023. *
  76024. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76025. * Negative values of maxDelta pushes the value away from target.
  76026. * @param current current value
  76027. * @param target target value
  76028. * @param maxDelta max distance to move
  76029. * @returns resulting value
  76030. */
  76031. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76032. /**
  76033. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76034. *
  76035. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76036. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76037. * @param current current value
  76038. * @param target target value
  76039. * @param maxDelta max distance to move
  76040. * @returns resulting angle
  76041. */
  76042. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76043. /**
  76044. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76045. * @param start start value
  76046. * @param end target value
  76047. * @param amount amount to lerp between
  76048. * @returns the lerped value
  76049. */
  76050. static Lerp(start: number, end: number, amount: number): number;
  76051. /**
  76052. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76053. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76054. * @param start start value
  76055. * @param end target value
  76056. * @param amount amount to lerp between
  76057. * @returns the lerped value
  76058. */
  76059. static LerpAngle(start: number, end: number, amount: number): number;
  76060. /**
  76061. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76062. * @param a start value
  76063. * @param b target value
  76064. * @param value value between a and b
  76065. * @returns the inverseLerp value
  76066. */
  76067. static InverseLerp(a: number, b: number, value: number): number;
  76068. /**
  76069. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76070. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76071. * @param value1 spline value
  76072. * @param tangent1 spline value
  76073. * @param value2 spline value
  76074. * @param tangent2 spline value
  76075. * @param amount input value
  76076. * @returns hermite result
  76077. */
  76078. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76079. /**
  76080. * Returns a random float number between and min and max values
  76081. * @param min min value of random
  76082. * @param max max value of random
  76083. * @returns random value
  76084. */
  76085. static RandomRange(min: number, max: number): number;
  76086. /**
  76087. * This function returns percentage of a number in a given range.
  76088. *
  76089. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76090. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76091. * @param number to convert to percentage
  76092. * @param min min range
  76093. * @param max max range
  76094. * @returns the percentage
  76095. */
  76096. static RangeToPercent(number: number, min: number, max: number): number;
  76097. /**
  76098. * This function returns number that corresponds to the percentage in a given range.
  76099. *
  76100. * PercentToRange(0.34,0,100) will return 34.
  76101. * @param percent to convert to number
  76102. * @param min min range
  76103. * @param max max range
  76104. * @returns the number
  76105. */
  76106. static PercentToRange(percent: number, min: number, max: number): number;
  76107. /**
  76108. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76109. * @param angle The angle to normalize in radian.
  76110. * @return The converted angle.
  76111. */
  76112. static NormalizeRadians(angle: number): number;
  76113. }
  76114. }
  76115. declare module BABYLON {
  76116. /**
  76117. * Constant used to convert a value to gamma space
  76118. * @ignorenaming
  76119. */
  76120. export const ToGammaSpace: number;
  76121. /**
  76122. * Constant used to convert a value to linear space
  76123. * @ignorenaming
  76124. */
  76125. export const ToLinearSpace = 2.2;
  76126. /**
  76127. * Constant used to define the minimal number value in Babylon.js
  76128. * @ignorenaming
  76129. */
  76130. let Epsilon: number;
  76131. }
  76132. declare module BABYLON {
  76133. /**
  76134. * Class used to represent a viewport on screen
  76135. */
  76136. export class Viewport {
  76137. /** viewport left coordinate */
  76138. x: number;
  76139. /** viewport top coordinate */
  76140. y: number;
  76141. /**viewport width */
  76142. width: number;
  76143. /** viewport height */
  76144. height: number;
  76145. /**
  76146. * Creates a Viewport object located at (x, y) and sized (width, height)
  76147. * @param x defines viewport left coordinate
  76148. * @param y defines viewport top coordinate
  76149. * @param width defines the viewport width
  76150. * @param height defines the viewport height
  76151. */
  76152. constructor(
  76153. /** viewport left coordinate */
  76154. x: number,
  76155. /** viewport top coordinate */
  76156. y: number,
  76157. /**viewport width */
  76158. width: number,
  76159. /** viewport height */
  76160. height: number);
  76161. /**
  76162. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76163. * @param renderWidth defines the rendering width
  76164. * @param renderHeight defines the rendering height
  76165. * @returns a new Viewport
  76166. */
  76167. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76168. /**
  76169. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76170. * @param renderWidth defines the rendering width
  76171. * @param renderHeight defines the rendering height
  76172. * @param ref defines the target viewport
  76173. * @returns the current viewport
  76174. */
  76175. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76176. /**
  76177. * Returns a new Viewport copied from the current one
  76178. * @returns a new Viewport
  76179. */
  76180. clone(): Viewport;
  76181. }
  76182. }
  76183. declare module BABYLON {
  76184. /**
  76185. * Class containing a set of static utilities functions for arrays.
  76186. */
  76187. export class ArrayTools {
  76188. /**
  76189. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76190. * @param size the number of element to construct and put in the array
  76191. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76192. * @returns a new array filled with new objects
  76193. */
  76194. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76195. }
  76196. }
  76197. declare module BABYLON {
  76198. /**
  76199. * Class representing a vector containing 2 coordinates
  76200. */
  76201. export class Vector2 {
  76202. /** defines the first coordinate */
  76203. x: number;
  76204. /** defines the second coordinate */
  76205. y: number;
  76206. /**
  76207. * Creates a new Vector2 from the given x and y coordinates
  76208. * @param x defines the first coordinate
  76209. * @param y defines the second coordinate
  76210. */
  76211. constructor(
  76212. /** defines the first coordinate */
  76213. x?: number,
  76214. /** defines the second coordinate */
  76215. y?: number);
  76216. /**
  76217. * Gets a string with the Vector2 coordinates
  76218. * @returns a string with the Vector2 coordinates
  76219. */
  76220. toString(): string;
  76221. /**
  76222. * Gets class name
  76223. * @returns the string "Vector2"
  76224. */
  76225. getClassName(): string;
  76226. /**
  76227. * Gets current vector hash code
  76228. * @returns the Vector2 hash code as a number
  76229. */
  76230. getHashCode(): number;
  76231. /**
  76232. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76233. * @param array defines the source array
  76234. * @param index defines the offset in source array
  76235. * @returns the current Vector2
  76236. */
  76237. toArray(array: FloatArray, index?: number): Vector2;
  76238. /**
  76239. * Copy the current vector to an array
  76240. * @returns a new array with 2 elements: the Vector2 coordinates.
  76241. */
  76242. asArray(): number[];
  76243. /**
  76244. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76245. * @param source defines the source Vector2
  76246. * @returns the current updated Vector2
  76247. */
  76248. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76249. /**
  76250. * Sets the Vector2 coordinates with the given floats
  76251. * @param x defines the first coordinate
  76252. * @param y defines the second coordinate
  76253. * @returns the current updated Vector2
  76254. */
  76255. copyFromFloats(x: number, y: number): Vector2;
  76256. /**
  76257. * Sets the Vector2 coordinates with the given floats
  76258. * @param x defines the first coordinate
  76259. * @param y defines the second coordinate
  76260. * @returns the current updated Vector2
  76261. */
  76262. set(x: number, y: number): Vector2;
  76263. /**
  76264. * Add another vector with the current one
  76265. * @param otherVector defines the other vector
  76266. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76267. */
  76268. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76269. /**
  76270. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76271. * @param otherVector defines the other vector
  76272. * @param result defines the target vector
  76273. * @returns the unmodified current Vector2
  76274. */
  76275. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76276. /**
  76277. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76278. * @param otherVector defines the other vector
  76279. * @returns the current updated Vector2
  76280. */
  76281. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76282. /**
  76283. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76284. * @param otherVector defines the other vector
  76285. * @returns a new Vector2
  76286. */
  76287. addVector3(otherVector: Vector3): Vector2;
  76288. /**
  76289. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76290. * @param otherVector defines the other vector
  76291. * @returns a new Vector2
  76292. */
  76293. subtract(otherVector: Vector2): Vector2;
  76294. /**
  76295. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76296. * @param otherVector defines the other vector
  76297. * @param result defines the target vector
  76298. * @returns the unmodified current Vector2
  76299. */
  76300. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76301. /**
  76302. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76303. * @param otherVector defines the other vector
  76304. * @returns the current updated Vector2
  76305. */
  76306. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76307. /**
  76308. * Multiplies in place the current Vector2 coordinates by the given ones
  76309. * @param otherVector defines the other vector
  76310. * @returns the current updated Vector2
  76311. */
  76312. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76313. /**
  76314. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76315. * @param otherVector defines the other vector
  76316. * @returns a new Vector2
  76317. */
  76318. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76319. /**
  76320. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76321. * @param otherVector defines the other vector
  76322. * @param result defines the target vector
  76323. * @returns the unmodified current Vector2
  76324. */
  76325. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76326. /**
  76327. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76328. * @param x defines the first coordinate
  76329. * @param y defines the second coordinate
  76330. * @returns a new Vector2
  76331. */
  76332. multiplyByFloats(x: number, y: number): Vector2;
  76333. /**
  76334. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76335. * @param otherVector defines the other vector
  76336. * @returns a new Vector2
  76337. */
  76338. divide(otherVector: Vector2): Vector2;
  76339. /**
  76340. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76341. * @param otherVector defines the other vector
  76342. * @param result defines the target vector
  76343. * @returns the unmodified current Vector2
  76344. */
  76345. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76346. /**
  76347. * Divides the current Vector2 coordinates by the given ones
  76348. * @param otherVector defines the other vector
  76349. * @returns the current updated Vector2
  76350. */
  76351. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76352. /**
  76353. * Gets a new Vector2 with current Vector2 negated coordinates
  76354. * @returns a new Vector2
  76355. */
  76356. negate(): Vector2;
  76357. /**
  76358. * Negate this vector in place
  76359. * @returns this
  76360. */
  76361. negateInPlace(): Vector2;
  76362. /**
  76363. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76364. * @param result defines the Vector3 object where to store the result
  76365. * @returns the current Vector2
  76366. */
  76367. negateToRef(result: Vector2): Vector2;
  76368. /**
  76369. * Multiply the Vector2 coordinates by scale
  76370. * @param scale defines the scaling factor
  76371. * @returns the current updated Vector2
  76372. */
  76373. scaleInPlace(scale: number): Vector2;
  76374. /**
  76375. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76376. * @param scale defines the scaling factor
  76377. * @returns a new Vector2
  76378. */
  76379. scale(scale: number): Vector2;
  76380. /**
  76381. * Scale the current Vector2 values by a factor to a given Vector2
  76382. * @param scale defines the scale factor
  76383. * @param result defines the Vector2 object where to store the result
  76384. * @returns the unmodified current Vector2
  76385. */
  76386. scaleToRef(scale: number, result: Vector2): Vector2;
  76387. /**
  76388. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76389. * @param scale defines the scale factor
  76390. * @param result defines the Vector2 object where to store the result
  76391. * @returns the unmodified current Vector2
  76392. */
  76393. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76394. /**
  76395. * Gets a boolean if two vectors are equals
  76396. * @param otherVector defines the other vector
  76397. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76398. */
  76399. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76400. /**
  76401. * Gets a boolean if two vectors are equals (using an epsilon value)
  76402. * @param otherVector defines the other vector
  76403. * @param epsilon defines the minimal distance to consider equality
  76404. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76405. */
  76406. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76407. /**
  76408. * Gets a new Vector2 from current Vector2 floored values
  76409. * @returns a new Vector2
  76410. */
  76411. floor(): Vector2;
  76412. /**
  76413. * Gets a new Vector2 from current Vector2 floored values
  76414. * @returns a new Vector2
  76415. */
  76416. fract(): Vector2;
  76417. /**
  76418. * Gets the length of the vector
  76419. * @returns the vector length (float)
  76420. */
  76421. length(): number;
  76422. /**
  76423. * Gets the vector squared length
  76424. * @returns the vector squared length (float)
  76425. */
  76426. lengthSquared(): number;
  76427. /**
  76428. * Normalize the vector
  76429. * @returns the current updated Vector2
  76430. */
  76431. normalize(): Vector2;
  76432. /**
  76433. * Gets a new Vector2 copied from the Vector2
  76434. * @returns a new Vector2
  76435. */
  76436. clone(): Vector2;
  76437. /**
  76438. * Gets a new Vector2(0, 0)
  76439. * @returns a new Vector2
  76440. */
  76441. static Zero(): Vector2;
  76442. /**
  76443. * Gets a new Vector2(1, 1)
  76444. * @returns a new Vector2
  76445. */
  76446. static One(): Vector2;
  76447. /**
  76448. * Gets a new Vector2 set from the given index element of the given array
  76449. * @param array defines the data source
  76450. * @param offset defines the offset in the data source
  76451. * @returns a new Vector2
  76452. */
  76453. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76454. /**
  76455. * Sets "result" from the given index element of the given array
  76456. * @param array defines the data source
  76457. * @param offset defines the offset in the data source
  76458. * @param result defines the target vector
  76459. */
  76460. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76461. /**
  76462. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76463. * @param value1 defines 1st point of control
  76464. * @param value2 defines 2nd point of control
  76465. * @param value3 defines 3rd point of control
  76466. * @param value4 defines 4th point of control
  76467. * @param amount defines the interpolation factor
  76468. * @returns a new Vector2
  76469. */
  76470. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76471. /**
  76472. * 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".
  76473. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76474. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76475. * @param value defines the value to clamp
  76476. * @param min defines the lower limit
  76477. * @param max defines the upper limit
  76478. * @returns a new Vector2
  76479. */
  76480. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76481. /**
  76482. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76483. * @param value1 defines the 1st control point
  76484. * @param tangent1 defines the outgoing tangent
  76485. * @param value2 defines the 2nd control point
  76486. * @param tangent2 defines the incoming tangent
  76487. * @param amount defines the interpolation factor
  76488. * @returns a new Vector2
  76489. */
  76490. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76491. /**
  76492. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76493. * @param start defines the start vector
  76494. * @param end defines the end vector
  76495. * @param amount defines the interpolation factor
  76496. * @returns a new Vector2
  76497. */
  76498. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76499. /**
  76500. * Gets the dot product of the vector "left" and the vector "right"
  76501. * @param left defines first vector
  76502. * @param right defines second vector
  76503. * @returns the dot product (float)
  76504. */
  76505. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76506. /**
  76507. * Returns a new Vector2 equal to the normalized given vector
  76508. * @param vector defines the vector to normalize
  76509. * @returns a new Vector2
  76510. */
  76511. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76512. /**
  76513. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76514. * @param left defines 1st vector
  76515. * @param right defines 2nd vector
  76516. * @returns a new Vector2
  76517. */
  76518. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76519. /**
  76520. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76521. * @param left defines 1st vector
  76522. * @param right defines 2nd vector
  76523. * @returns a new Vector2
  76524. */
  76525. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76526. /**
  76527. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76528. * @param vector defines the vector to transform
  76529. * @param transformation defines the matrix to apply
  76530. * @returns a new Vector2
  76531. */
  76532. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76533. /**
  76534. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76535. * @param vector defines the vector to transform
  76536. * @param transformation defines the matrix to apply
  76537. * @param result defines the target vector
  76538. */
  76539. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76540. /**
  76541. * Determines if a given vector is included in a triangle
  76542. * @param p defines the vector to test
  76543. * @param p0 defines 1st triangle point
  76544. * @param p1 defines 2nd triangle point
  76545. * @param p2 defines 3rd triangle point
  76546. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76547. */
  76548. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76549. /**
  76550. * Gets the distance between the vectors "value1" and "value2"
  76551. * @param value1 defines first vector
  76552. * @param value2 defines second vector
  76553. * @returns the distance between vectors
  76554. */
  76555. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76556. /**
  76557. * Returns the squared distance between the vectors "value1" and "value2"
  76558. * @param value1 defines first vector
  76559. * @param value2 defines second vector
  76560. * @returns the squared distance between vectors
  76561. */
  76562. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76563. /**
  76564. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76565. * @param value1 defines first vector
  76566. * @param value2 defines second vector
  76567. * @returns a new Vector2
  76568. */
  76569. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76570. /**
  76571. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76572. * @param p defines the middle point
  76573. * @param segA defines one point of the segment
  76574. * @param segB defines the other point of the segment
  76575. * @returns the shortest distance
  76576. */
  76577. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76578. }
  76579. /**
  76580. * Class used to store (x,y,z) vector representation
  76581. * A Vector3 is the main object used in 3D geometry
  76582. * It can represent etiher the coordinates of a point the space, either a direction
  76583. * Reminder: js uses a left handed forward facing system
  76584. */
  76585. export class Vector3 {
  76586. /**
  76587. * Defines the first coordinates (on X axis)
  76588. */
  76589. x: number;
  76590. /**
  76591. * Defines the second coordinates (on Y axis)
  76592. */
  76593. y: number;
  76594. /**
  76595. * Defines the third coordinates (on Z axis)
  76596. */
  76597. z: number;
  76598. private static _UpReadOnly;
  76599. private static _ZeroReadOnly;
  76600. /**
  76601. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76602. * @param x defines the first coordinates (on X axis)
  76603. * @param y defines the second coordinates (on Y axis)
  76604. * @param z defines the third coordinates (on Z axis)
  76605. */
  76606. constructor(
  76607. /**
  76608. * Defines the first coordinates (on X axis)
  76609. */
  76610. x?: number,
  76611. /**
  76612. * Defines the second coordinates (on Y axis)
  76613. */
  76614. y?: number,
  76615. /**
  76616. * Defines the third coordinates (on Z axis)
  76617. */
  76618. z?: number);
  76619. /**
  76620. * Creates a string representation of the Vector3
  76621. * @returns a string with the Vector3 coordinates.
  76622. */
  76623. toString(): string;
  76624. /**
  76625. * Gets the class name
  76626. * @returns the string "Vector3"
  76627. */
  76628. getClassName(): string;
  76629. /**
  76630. * Creates the Vector3 hash code
  76631. * @returns a number which tends to be unique between Vector3 instances
  76632. */
  76633. getHashCode(): number;
  76634. /**
  76635. * Creates an array containing three elements : the coordinates of the Vector3
  76636. * @returns a new array of numbers
  76637. */
  76638. asArray(): number[];
  76639. /**
  76640. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76641. * @param array defines the destination array
  76642. * @param index defines the offset in the destination array
  76643. * @returns the current Vector3
  76644. */
  76645. toArray(array: FloatArray, index?: number): Vector3;
  76646. /**
  76647. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76648. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76649. */
  76650. toQuaternion(): Quaternion;
  76651. /**
  76652. * Adds the given vector to the current Vector3
  76653. * @param otherVector defines the second operand
  76654. * @returns the current updated Vector3
  76655. */
  76656. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76657. /**
  76658. * Adds the given coordinates to the current Vector3
  76659. * @param x defines the x coordinate of the operand
  76660. * @param y defines the y coordinate of the operand
  76661. * @param z defines the z coordinate of the operand
  76662. * @returns the current updated Vector3
  76663. */
  76664. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76665. /**
  76666. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76667. * @param otherVector defines the second operand
  76668. * @returns the resulting Vector3
  76669. */
  76670. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76671. /**
  76672. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76673. * @param otherVector defines the second operand
  76674. * @param result defines the Vector3 object where to store the result
  76675. * @returns the current Vector3
  76676. */
  76677. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76678. /**
  76679. * Subtract the given vector from the current Vector3
  76680. * @param otherVector defines the second operand
  76681. * @returns the current updated Vector3
  76682. */
  76683. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76684. /**
  76685. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76686. * @param otherVector defines the second operand
  76687. * @returns the resulting Vector3
  76688. */
  76689. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76690. /**
  76691. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76692. * @param otherVector defines the second operand
  76693. * @param result defines the Vector3 object where to store the result
  76694. * @returns the current Vector3
  76695. */
  76696. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76697. /**
  76698. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76699. * @param x defines the x coordinate of the operand
  76700. * @param y defines the y coordinate of the operand
  76701. * @param z defines the z coordinate of the operand
  76702. * @returns the resulting Vector3
  76703. */
  76704. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76705. /**
  76706. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76707. * @param x defines the x coordinate of the operand
  76708. * @param y defines the y coordinate of the operand
  76709. * @param z defines the z coordinate of the operand
  76710. * @param result defines the Vector3 object where to store the result
  76711. * @returns the current Vector3
  76712. */
  76713. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76714. /**
  76715. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76716. * @returns a new Vector3
  76717. */
  76718. negate(): Vector3;
  76719. /**
  76720. * Negate this vector in place
  76721. * @returns this
  76722. */
  76723. negateInPlace(): Vector3;
  76724. /**
  76725. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76726. * @param result defines the Vector3 object where to store the result
  76727. * @returns the current Vector3
  76728. */
  76729. negateToRef(result: Vector3): Vector3;
  76730. /**
  76731. * Multiplies the Vector3 coordinates by the float "scale"
  76732. * @param scale defines the multiplier factor
  76733. * @returns the current updated Vector3
  76734. */
  76735. scaleInPlace(scale: number): Vector3;
  76736. /**
  76737. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76738. * @param scale defines the multiplier factor
  76739. * @returns a new Vector3
  76740. */
  76741. scale(scale: number): Vector3;
  76742. /**
  76743. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76744. * @param scale defines the multiplier factor
  76745. * @param result defines the Vector3 object where to store the result
  76746. * @returns the current Vector3
  76747. */
  76748. scaleToRef(scale: number, result: Vector3): Vector3;
  76749. /**
  76750. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76751. * @param scale defines the scale factor
  76752. * @param result defines the Vector3 object where to store the result
  76753. * @returns the unmodified current Vector3
  76754. */
  76755. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76756. /**
  76757. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76758. * @param otherVector defines the second operand
  76759. * @returns true if both vectors are equals
  76760. */
  76761. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76762. /**
  76763. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76764. * @param otherVector defines the second operand
  76765. * @param epsilon defines the minimal distance to define values as equals
  76766. * @returns true if both vectors are distant less than epsilon
  76767. */
  76768. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76769. /**
  76770. * Returns true if the current Vector3 coordinates equals the given floats
  76771. * @param x defines the x coordinate of the operand
  76772. * @param y defines the y coordinate of the operand
  76773. * @param z defines the z coordinate of the operand
  76774. * @returns true if both vectors are equals
  76775. */
  76776. equalsToFloats(x: number, y: number, z: number): boolean;
  76777. /**
  76778. * Multiplies the current Vector3 coordinates by the given ones
  76779. * @param otherVector defines the second operand
  76780. * @returns the current updated Vector3
  76781. */
  76782. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76783. /**
  76784. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76785. * @param otherVector defines the second operand
  76786. * @returns the new Vector3
  76787. */
  76788. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76789. /**
  76790. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76791. * @param otherVector defines the second operand
  76792. * @param result defines the Vector3 object where to store the result
  76793. * @returns the current Vector3
  76794. */
  76795. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76796. /**
  76797. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76798. * @param x defines the x coordinate of the operand
  76799. * @param y defines the y coordinate of the operand
  76800. * @param z defines the z coordinate of the operand
  76801. * @returns the new Vector3
  76802. */
  76803. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76804. /**
  76805. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76806. * @param otherVector defines the second operand
  76807. * @returns the new Vector3
  76808. */
  76809. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76810. /**
  76811. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76812. * @param otherVector defines the second operand
  76813. * @param result defines the Vector3 object where to store the result
  76814. * @returns the current Vector3
  76815. */
  76816. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76817. /**
  76818. * Divides the current Vector3 coordinates by the given ones.
  76819. * @param otherVector defines the second operand
  76820. * @returns the current updated Vector3
  76821. */
  76822. divideInPlace(otherVector: Vector3): Vector3;
  76823. /**
  76824. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76825. * @param other defines the second operand
  76826. * @returns the current updated Vector3
  76827. */
  76828. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76829. /**
  76830. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76831. * @param other defines the second operand
  76832. * @returns the current updated Vector3
  76833. */
  76834. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76835. /**
  76836. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76837. * @param x defines the x coordinate of the operand
  76838. * @param y defines the y coordinate of the operand
  76839. * @param z defines the z coordinate of the operand
  76840. * @returns the current updated Vector3
  76841. */
  76842. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76843. /**
  76844. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76845. * @param x defines the x coordinate of the operand
  76846. * @param y defines the y coordinate of the operand
  76847. * @param z defines the z coordinate of the operand
  76848. * @returns the current updated Vector3
  76849. */
  76850. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76851. /**
  76852. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76853. * Check if is non uniform within a certain amount of decimal places to account for this
  76854. * @param epsilon the amount the values can differ
  76855. * @returns if the the vector is non uniform to a certain number of decimal places
  76856. */
  76857. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76858. /**
  76859. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76860. */
  76861. get isNonUniform(): boolean;
  76862. /**
  76863. * Gets a new Vector3 from current Vector3 floored values
  76864. * @returns a new Vector3
  76865. */
  76866. floor(): Vector3;
  76867. /**
  76868. * Gets a new Vector3 from current Vector3 floored values
  76869. * @returns a new Vector3
  76870. */
  76871. fract(): Vector3;
  76872. /**
  76873. * Gets the length of the Vector3
  76874. * @returns the length of the Vector3
  76875. */
  76876. length(): number;
  76877. /**
  76878. * Gets the squared length of the Vector3
  76879. * @returns squared length of the Vector3
  76880. */
  76881. lengthSquared(): number;
  76882. /**
  76883. * Normalize the current Vector3.
  76884. * Please note that this is an in place operation.
  76885. * @returns the current updated Vector3
  76886. */
  76887. normalize(): Vector3;
  76888. /**
  76889. * Reorders the x y z properties of the vector in place
  76890. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76891. * @returns the current updated vector
  76892. */
  76893. reorderInPlace(order: string): this;
  76894. /**
  76895. * Rotates the vector around 0,0,0 by a quaternion
  76896. * @param quaternion the rotation quaternion
  76897. * @param result vector to store the result
  76898. * @returns the resulting vector
  76899. */
  76900. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76901. /**
  76902. * Rotates a vector around a given point
  76903. * @param quaternion the rotation quaternion
  76904. * @param point the point to rotate around
  76905. * @param result vector to store the result
  76906. * @returns the resulting vector
  76907. */
  76908. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76909. /**
  76910. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76911. * The cross product is then orthogonal to both current and "other"
  76912. * @param other defines the right operand
  76913. * @returns the cross product
  76914. */
  76915. cross(other: Vector3): Vector3;
  76916. /**
  76917. * Normalize the current Vector3 with the given input length.
  76918. * Please note that this is an in place operation.
  76919. * @param len the length of the vector
  76920. * @returns the current updated Vector3
  76921. */
  76922. normalizeFromLength(len: number): Vector3;
  76923. /**
  76924. * Normalize the current Vector3 to a new vector
  76925. * @returns the new Vector3
  76926. */
  76927. normalizeToNew(): Vector3;
  76928. /**
  76929. * Normalize the current Vector3 to the reference
  76930. * @param reference define the Vector3 to update
  76931. * @returns the updated Vector3
  76932. */
  76933. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76934. /**
  76935. * Creates a new Vector3 copied from the current Vector3
  76936. * @returns the new Vector3
  76937. */
  76938. clone(): Vector3;
  76939. /**
  76940. * Copies the given vector coordinates to the current Vector3 ones
  76941. * @param source defines the source Vector3
  76942. * @returns the current updated Vector3
  76943. */
  76944. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76945. /**
  76946. * Copies the given floats to the current Vector3 coordinates
  76947. * @param x defines the x coordinate of the operand
  76948. * @param y defines the y coordinate of the operand
  76949. * @param z defines the z coordinate of the operand
  76950. * @returns the current updated Vector3
  76951. */
  76952. copyFromFloats(x: number, y: number, z: number): Vector3;
  76953. /**
  76954. * Copies the given floats to the current Vector3 coordinates
  76955. * @param x defines the x coordinate of the operand
  76956. * @param y defines the y coordinate of the operand
  76957. * @param z defines the z coordinate of the operand
  76958. * @returns the current updated Vector3
  76959. */
  76960. set(x: number, y: number, z: number): Vector3;
  76961. /**
  76962. * Copies the given float to the current Vector3 coordinates
  76963. * @param v defines the x, y and z coordinates of the operand
  76964. * @returns the current updated Vector3
  76965. */
  76966. setAll(v: number): Vector3;
  76967. /**
  76968. * Get the clip factor between two vectors
  76969. * @param vector0 defines the first operand
  76970. * @param vector1 defines the second operand
  76971. * @param axis defines the axis to use
  76972. * @param size defines the size along the axis
  76973. * @returns the clip factor
  76974. */
  76975. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76976. /**
  76977. * Get angle between two vectors
  76978. * @param vector0 angle between vector0 and vector1
  76979. * @param vector1 angle between vector0 and vector1
  76980. * @param normal direction of the normal
  76981. * @return the angle between vector0 and vector1
  76982. */
  76983. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76984. /**
  76985. * Returns a new Vector3 set from the index "offset" of the given array
  76986. * @param array defines the source array
  76987. * @param offset defines the offset in the source array
  76988. * @returns the new Vector3
  76989. */
  76990. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76991. /**
  76992. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76993. * @param array defines the source array
  76994. * @param offset defines the offset in the source array
  76995. * @returns the new Vector3
  76996. * @deprecated Please use FromArray instead.
  76997. */
  76998. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76999. /**
  77000. * Sets the given vector "result" with the element values from the index "offset" of the given array
  77001. * @param array defines the source array
  77002. * @param offset defines the offset in the source array
  77003. * @param result defines the Vector3 where to store the result
  77004. */
  77005. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  77006. /**
  77007. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  77008. * @param array defines the source array
  77009. * @param offset defines the offset in the source array
  77010. * @param result defines the Vector3 where to store the result
  77011. * @deprecated Please use FromArrayToRef instead.
  77012. */
  77013. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  77014. /**
  77015. * Sets the given vector "result" with the given floats.
  77016. * @param x defines the x coordinate of the source
  77017. * @param y defines the y coordinate of the source
  77018. * @param z defines the z coordinate of the source
  77019. * @param result defines the Vector3 where to store the result
  77020. */
  77021. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  77022. /**
  77023. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77024. * @returns a new empty Vector3
  77025. */
  77026. static Zero(): Vector3;
  77027. /**
  77028. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77029. * @returns a new unit Vector3
  77030. */
  77031. static One(): Vector3;
  77032. /**
  77033. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77034. * @returns a new up Vector3
  77035. */
  77036. static Up(): Vector3;
  77037. /**
  77038. * Gets a up Vector3 that must not be updated
  77039. */
  77040. static get UpReadOnly(): DeepImmutable<Vector3>;
  77041. /**
  77042. * Gets a zero Vector3 that must not be updated
  77043. */
  77044. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77045. /**
  77046. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77047. * @returns a new down Vector3
  77048. */
  77049. static Down(): Vector3;
  77050. /**
  77051. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77052. * @returns a new forward Vector3
  77053. */
  77054. static Forward(): Vector3;
  77055. /**
  77056. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77057. * @returns a new forward Vector3
  77058. */
  77059. static Backward(): Vector3;
  77060. /**
  77061. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77062. * @returns a new right Vector3
  77063. */
  77064. static Right(): Vector3;
  77065. /**
  77066. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77067. * @returns a new left Vector3
  77068. */
  77069. static Left(): Vector3;
  77070. /**
  77071. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77072. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77073. * @param vector defines the Vector3 to transform
  77074. * @param transformation defines the transformation matrix
  77075. * @returns the transformed Vector3
  77076. */
  77077. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77078. /**
  77079. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77080. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77081. * @param vector defines the Vector3 to transform
  77082. * @param transformation defines the transformation matrix
  77083. * @param result defines the Vector3 where to store the result
  77084. */
  77085. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77086. /**
  77087. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77088. * This method computes tranformed coordinates only, not transformed direction vectors
  77089. * @param x define the x coordinate of the source vector
  77090. * @param y define the y coordinate of the source vector
  77091. * @param z define the z coordinate of the source vector
  77092. * @param transformation defines the transformation matrix
  77093. * @param result defines the Vector3 where to store the result
  77094. */
  77095. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77096. /**
  77097. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77098. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77099. * @param vector defines the Vector3 to transform
  77100. * @param transformation defines the transformation matrix
  77101. * @returns the new Vector3
  77102. */
  77103. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77104. /**
  77105. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77106. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77107. * @param vector defines the Vector3 to transform
  77108. * @param transformation defines the transformation matrix
  77109. * @param result defines the Vector3 where to store the result
  77110. */
  77111. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77112. /**
  77113. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77114. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77115. * @param x define the x coordinate of the source vector
  77116. * @param y define the y coordinate of the source vector
  77117. * @param z define the z coordinate of the source vector
  77118. * @param transformation defines the transformation matrix
  77119. * @param result defines the Vector3 where to store the result
  77120. */
  77121. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77122. /**
  77123. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77124. * @param value1 defines the first control point
  77125. * @param value2 defines the second control point
  77126. * @param value3 defines the third control point
  77127. * @param value4 defines the fourth control point
  77128. * @param amount defines the amount on the spline to use
  77129. * @returns the new Vector3
  77130. */
  77131. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77132. /**
  77133. * 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"
  77134. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77135. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77136. * @param value defines the current value
  77137. * @param min defines the lower range value
  77138. * @param max defines the upper range value
  77139. * @returns the new Vector3
  77140. */
  77141. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77142. /**
  77143. * 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"
  77144. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77145. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77146. * @param value defines the current value
  77147. * @param min defines the lower range value
  77148. * @param max defines the upper range value
  77149. * @param result defines the Vector3 where to store the result
  77150. */
  77151. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77152. /**
  77153. * Checks if a given vector is inside a specific range
  77154. * @param v defines the vector to test
  77155. * @param min defines the minimum range
  77156. * @param max defines the maximum range
  77157. */
  77158. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77159. /**
  77160. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77161. * @param value1 defines the first control point
  77162. * @param tangent1 defines the first tangent vector
  77163. * @param value2 defines the second control point
  77164. * @param tangent2 defines the second tangent vector
  77165. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77166. * @returns the new Vector3
  77167. */
  77168. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77169. /**
  77170. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77171. * @param start defines the start value
  77172. * @param end defines the end value
  77173. * @param amount max defines amount between both (between 0 and 1)
  77174. * @returns the new Vector3
  77175. */
  77176. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77177. /**
  77178. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77179. * @param start defines the start value
  77180. * @param end defines the end value
  77181. * @param amount max defines amount between both (between 0 and 1)
  77182. * @param result defines the Vector3 where to store the result
  77183. */
  77184. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77185. /**
  77186. * Returns the dot product (float) between the vectors "left" and "right"
  77187. * @param left defines the left operand
  77188. * @param right defines the right operand
  77189. * @returns the dot product
  77190. */
  77191. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77192. /**
  77193. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77194. * The cross product is then orthogonal to both "left" and "right"
  77195. * @param left defines the left operand
  77196. * @param right defines the right operand
  77197. * @returns the cross product
  77198. */
  77199. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77200. /**
  77201. * Sets the given vector "result" with the cross product of "left" and "right"
  77202. * The cross product is then orthogonal to both "left" and "right"
  77203. * @param left defines the left operand
  77204. * @param right defines the right operand
  77205. * @param result defines the Vector3 where to store the result
  77206. */
  77207. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77208. /**
  77209. * Returns a new Vector3 as the normalization of the given vector
  77210. * @param vector defines the Vector3 to normalize
  77211. * @returns the new Vector3
  77212. */
  77213. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77214. /**
  77215. * Sets the given vector "result" with the normalization of the given first vector
  77216. * @param vector defines the Vector3 to normalize
  77217. * @param result defines the Vector3 where to store the result
  77218. */
  77219. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77220. /**
  77221. * Project a Vector3 onto screen space
  77222. * @param vector defines the Vector3 to project
  77223. * @param world defines the world matrix to use
  77224. * @param transform defines the transform (view x projection) matrix to use
  77225. * @param viewport defines the screen viewport to use
  77226. * @returns the new Vector3
  77227. */
  77228. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77229. /** @hidden */
  77230. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77231. /**
  77232. * Unproject from screen space to object space
  77233. * @param source defines the screen space Vector3 to use
  77234. * @param viewportWidth defines the current width of the viewport
  77235. * @param viewportHeight defines the current height of the viewport
  77236. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77237. * @param transform defines the transform (view x projection) matrix to use
  77238. * @returns the new Vector3
  77239. */
  77240. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77241. /**
  77242. * Unproject from screen space to object space
  77243. * @param source defines the screen space Vector3 to use
  77244. * @param viewportWidth defines the current width of the viewport
  77245. * @param viewportHeight defines the current height of the viewport
  77246. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77247. * @param view defines the view matrix to use
  77248. * @param projection defines the projection matrix to use
  77249. * @returns the new Vector3
  77250. */
  77251. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77252. /**
  77253. * Unproject from screen space to object space
  77254. * @param source defines the screen space Vector3 to use
  77255. * @param viewportWidth defines the current width of the viewport
  77256. * @param viewportHeight defines the current height of the viewport
  77257. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77258. * @param view defines the view matrix to use
  77259. * @param projection defines the projection matrix to use
  77260. * @param result defines the Vector3 where to store the result
  77261. */
  77262. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77263. /**
  77264. * Unproject from screen space to object space
  77265. * @param sourceX defines the screen space x coordinate to use
  77266. * @param sourceY defines the screen space y coordinate to use
  77267. * @param sourceZ defines the screen space z coordinate to use
  77268. * @param viewportWidth defines the current width of the viewport
  77269. * @param viewportHeight defines the current height of the viewport
  77270. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77271. * @param view defines the view matrix to use
  77272. * @param projection defines the projection matrix to use
  77273. * @param result defines the Vector3 where to store the result
  77274. */
  77275. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77276. /**
  77277. * Gets the minimal coordinate values between two Vector3
  77278. * @param left defines the first operand
  77279. * @param right defines the second operand
  77280. * @returns the new Vector3
  77281. */
  77282. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77283. /**
  77284. * Gets the maximal coordinate values between two Vector3
  77285. * @param left defines the first operand
  77286. * @param right defines the second operand
  77287. * @returns the new Vector3
  77288. */
  77289. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77290. /**
  77291. * Returns the distance between the vectors "value1" and "value2"
  77292. * @param value1 defines the first operand
  77293. * @param value2 defines the second operand
  77294. * @returns the distance
  77295. */
  77296. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77297. /**
  77298. * Returns the squared distance between the vectors "value1" and "value2"
  77299. * @param value1 defines the first operand
  77300. * @param value2 defines the second operand
  77301. * @returns the squared distance
  77302. */
  77303. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77304. /**
  77305. * Returns a new Vector3 located at the center between "value1" and "value2"
  77306. * @param value1 defines the first operand
  77307. * @param value2 defines the second operand
  77308. * @returns the new Vector3
  77309. */
  77310. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77311. /**
  77312. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77313. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77314. * to something in order to rotate it from its local system to the given target system
  77315. * Note: axis1, axis2 and axis3 are normalized during this operation
  77316. * @param axis1 defines the first axis
  77317. * @param axis2 defines the second axis
  77318. * @param axis3 defines the third axis
  77319. * @returns a new Vector3
  77320. */
  77321. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77322. /**
  77323. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77324. * @param axis1 defines the first axis
  77325. * @param axis2 defines the second axis
  77326. * @param axis3 defines the third axis
  77327. * @param ref defines the Vector3 where to store the result
  77328. */
  77329. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77330. }
  77331. /**
  77332. * Vector4 class created for EulerAngle class conversion to Quaternion
  77333. */
  77334. export class Vector4 {
  77335. /** x value of the vector */
  77336. x: number;
  77337. /** y value of the vector */
  77338. y: number;
  77339. /** z value of the vector */
  77340. z: number;
  77341. /** w value of the vector */
  77342. w: number;
  77343. /**
  77344. * Creates a Vector4 object from the given floats.
  77345. * @param x x value of the vector
  77346. * @param y y value of the vector
  77347. * @param z z value of the vector
  77348. * @param w w value of the vector
  77349. */
  77350. constructor(
  77351. /** x value of the vector */
  77352. x: number,
  77353. /** y value of the vector */
  77354. y: number,
  77355. /** z value of the vector */
  77356. z: number,
  77357. /** w value of the vector */
  77358. w: number);
  77359. /**
  77360. * Returns the string with the Vector4 coordinates.
  77361. * @returns a string containing all the vector values
  77362. */
  77363. toString(): string;
  77364. /**
  77365. * Returns the string "Vector4".
  77366. * @returns "Vector4"
  77367. */
  77368. getClassName(): string;
  77369. /**
  77370. * Returns the Vector4 hash code.
  77371. * @returns a unique hash code
  77372. */
  77373. getHashCode(): number;
  77374. /**
  77375. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77376. * @returns the resulting array
  77377. */
  77378. asArray(): number[];
  77379. /**
  77380. * Populates the given array from the given index with the Vector4 coordinates.
  77381. * @param array array to populate
  77382. * @param index index of the array to start at (default: 0)
  77383. * @returns the Vector4.
  77384. */
  77385. toArray(array: FloatArray, index?: number): Vector4;
  77386. /**
  77387. * Adds the given vector to the current Vector4.
  77388. * @param otherVector the vector to add
  77389. * @returns the updated Vector4.
  77390. */
  77391. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77392. /**
  77393. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77394. * @param otherVector the vector to add
  77395. * @returns the resulting vector
  77396. */
  77397. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77398. /**
  77399. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77400. * @param otherVector the vector to add
  77401. * @param result the vector to store the result
  77402. * @returns the current Vector4.
  77403. */
  77404. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77405. /**
  77406. * Subtract in place the given vector from the current Vector4.
  77407. * @param otherVector the vector to subtract
  77408. * @returns the updated Vector4.
  77409. */
  77410. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77411. /**
  77412. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77413. * @param otherVector the vector to add
  77414. * @returns the new vector with the result
  77415. */
  77416. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77417. /**
  77418. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77419. * @param otherVector the vector to subtract
  77420. * @param result the vector to store the result
  77421. * @returns the current Vector4.
  77422. */
  77423. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77424. /**
  77425. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77426. */
  77427. /**
  77428. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77429. * @param x value to subtract
  77430. * @param y value to subtract
  77431. * @param z value to subtract
  77432. * @param w value to subtract
  77433. * @returns new vector containing the result
  77434. */
  77435. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77436. /**
  77437. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77438. * @param x value to subtract
  77439. * @param y value to subtract
  77440. * @param z value to subtract
  77441. * @param w value to subtract
  77442. * @param result the vector to store the result in
  77443. * @returns the current Vector4.
  77444. */
  77445. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77446. /**
  77447. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77448. * @returns a new vector with the negated values
  77449. */
  77450. negate(): Vector4;
  77451. /**
  77452. * Negate this vector in place
  77453. * @returns this
  77454. */
  77455. negateInPlace(): Vector4;
  77456. /**
  77457. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77458. * @param result defines the Vector3 object where to store the result
  77459. * @returns the current Vector4
  77460. */
  77461. negateToRef(result: Vector4): Vector4;
  77462. /**
  77463. * Multiplies the current Vector4 coordinates by scale (float).
  77464. * @param scale the number to scale with
  77465. * @returns the updated Vector4.
  77466. */
  77467. scaleInPlace(scale: number): Vector4;
  77468. /**
  77469. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77470. * @param scale the number to scale with
  77471. * @returns a new vector with the result
  77472. */
  77473. scale(scale: number): Vector4;
  77474. /**
  77475. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77476. * @param scale the number to scale with
  77477. * @param result a vector to store the result in
  77478. * @returns the current Vector4.
  77479. */
  77480. scaleToRef(scale: number, result: Vector4): Vector4;
  77481. /**
  77482. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77483. * @param scale defines the scale factor
  77484. * @param result defines the Vector4 object where to store the result
  77485. * @returns the unmodified current Vector4
  77486. */
  77487. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77488. /**
  77489. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77490. * @param otherVector the vector to compare against
  77491. * @returns true if they are equal
  77492. */
  77493. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77494. /**
  77495. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77496. * @param otherVector vector to compare against
  77497. * @param epsilon (Default: very small number)
  77498. * @returns true if they are equal
  77499. */
  77500. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77501. /**
  77502. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77503. * @param x x value to compare against
  77504. * @param y y value to compare against
  77505. * @param z z value to compare against
  77506. * @param w w value to compare against
  77507. * @returns true if equal
  77508. */
  77509. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77510. /**
  77511. * Multiplies in place the current Vector4 by the given one.
  77512. * @param otherVector vector to multiple with
  77513. * @returns the updated Vector4.
  77514. */
  77515. multiplyInPlace(otherVector: Vector4): Vector4;
  77516. /**
  77517. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77518. * @param otherVector vector to multiple with
  77519. * @returns resulting new vector
  77520. */
  77521. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77522. /**
  77523. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77524. * @param otherVector vector to multiple with
  77525. * @param result vector to store the result
  77526. * @returns the current Vector4.
  77527. */
  77528. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77529. /**
  77530. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77531. * @param x x value multiply with
  77532. * @param y y value multiply with
  77533. * @param z z value multiply with
  77534. * @param w w value multiply with
  77535. * @returns resulting new vector
  77536. */
  77537. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77538. /**
  77539. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77540. * @param otherVector vector to devide with
  77541. * @returns resulting new vector
  77542. */
  77543. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77544. /**
  77545. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77546. * @param otherVector vector to devide with
  77547. * @param result vector to store the result
  77548. * @returns the current Vector4.
  77549. */
  77550. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77551. /**
  77552. * Divides the current Vector3 coordinates by the given ones.
  77553. * @param otherVector vector to devide with
  77554. * @returns the updated Vector3.
  77555. */
  77556. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77557. /**
  77558. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77559. * @param other defines the second operand
  77560. * @returns the current updated Vector4
  77561. */
  77562. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77563. /**
  77564. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77565. * @param other defines the second operand
  77566. * @returns the current updated Vector4
  77567. */
  77568. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77569. /**
  77570. * Gets a new Vector4 from current Vector4 floored values
  77571. * @returns a new Vector4
  77572. */
  77573. floor(): Vector4;
  77574. /**
  77575. * Gets a new Vector4 from current Vector3 floored values
  77576. * @returns a new Vector4
  77577. */
  77578. fract(): Vector4;
  77579. /**
  77580. * Returns the Vector4 length (float).
  77581. * @returns the length
  77582. */
  77583. length(): number;
  77584. /**
  77585. * Returns the Vector4 squared length (float).
  77586. * @returns the length squared
  77587. */
  77588. lengthSquared(): number;
  77589. /**
  77590. * Normalizes in place the Vector4.
  77591. * @returns the updated Vector4.
  77592. */
  77593. normalize(): Vector4;
  77594. /**
  77595. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77596. * @returns this converted to a new vector3
  77597. */
  77598. toVector3(): Vector3;
  77599. /**
  77600. * Returns a new Vector4 copied from the current one.
  77601. * @returns the new cloned vector
  77602. */
  77603. clone(): Vector4;
  77604. /**
  77605. * Updates the current Vector4 with the given one coordinates.
  77606. * @param source the source vector to copy from
  77607. * @returns the updated Vector4.
  77608. */
  77609. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77610. /**
  77611. * Updates the current Vector4 coordinates with the given floats.
  77612. * @param x float to copy from
  77613. * @param y float to copy from
  77614. * @param z float to copy from
  77615. * @param w float to copy from
  77616. * @returns the updated Vector4.
  77617. */
  77618. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77619. /**
  77620. * Updates the current Vector4 coordinates with the given floats.
  77621. * @param x float to set from
  77622. * @param y float to set from
  77623. * @param z float to set from
  77624. * @param w float to set from
  77625. * @returns the updated Vector4.
  77626. */
  77627. set(x: number, y: number, z: number, w: number): Vector4;
  77628. /**
  77629. * Copies the given float to the current Vector3 coordinates
  77630. * @param v defines the x, y, z and w coordinates of the operand
  77631. * @returns the current updated Vector3
  77632. */
  77633. setAll(v: number): Vector4;
  77634. /**
  77635. * Returns a new Vector4 set from the starting index of the given array.
  77636. * @param array the array to pull values from
  77637. * @param offset the offset into the array to start at
  77638. * @returns the new vector
  77639. */
  77640. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77641. /**
  77642. * Updates the given vector "result" from the starting index of the given array.
  77643. * @param array the array to pull values from
  77644. * @param offset the offset into the array to start at
  77645. * @param result the vector to store the result in
  77646. */
  77647. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77648. /**
  77649. * Updates the given vector "result" from the starting index of the given Float32Array.
  77650. * @param array the array to pull values from
  77651. * @param offset the offset into the array to start at
  77652. * @param result the vector to store the result in
  77653. */
  77654. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77655. /**
  77656. * Updates the given vector "result" coordinates from the given floats.
  77657. * @param x float to set from
  77658. * @param y float to set from
  77659. * @param z float to set from
  77660. * @param w float to set from
  77661. * @param result the vector to the floats in
  77662. */
  77663. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77664. /**
  77665. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77666. * @returns the new vector
  77667. */
  77668. static Zero(): Vector4;
  77669. /**
  77670. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77671. * @returns the new vector
  77672. */
  77673. static One(): Vector4;
  77674. /**
  77675. * Returns a new normalized Vector4 from the given one.
  77676. * @param vector the vector to normalize
  77677. * @returns the vector
  77678. */
  77679. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77680. /**
  77681. * Updates the given vector "result" from the normalization of the given one.
  77682. * @param vector the vector to normalize
  77683. * @param result the vector to store the result in
  77684. */
  77685. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77686. /**
  77687. * Returns a vector with the minimum values from the left and right vectors
  77688. * @param left left vector to minimize
  77689. * @param right right vector to minimize
  77690. * @returns a new vector with the minimum of the left and right vector values
  77691. */
  77692. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77693. /**
  77694. * Returns a vector with the maximum values from the left and right vectors
  77695. * @param left left vector to maximize
  77696. * @param right right vector to maximize
  77697. * @returns a new vector with the maximum of the left and right vector values
  77698. */
  77699. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77700. /**
  77701. * Returns the distance (float) between the vectors "value1" and "value2".
  77702. * @param value1 value to calulate the distance between
  77703. * @param value2 value to calulate the distance between
  77704. * @return the distance between the two vectors
  77705. */
  77706. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77707. /**
  77708. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77709. * @param value1 value to calulate the distance between
  77710. * @param value2 value to calulate the distance between
  77711. * @return the distance between the two vectors squared
  77712. */
  77713. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77714. /**
  77715. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77716. * @param value1 value to calulate the center between
  77717. * @param value2 value to calulate the center between
  77718. * @return the center between the two vectors
  77719. */
  77720. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77721. /**
  77722. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77723. * This methods computes transformed normalized direction vectors only.
  77724. * @param vector the vector to transform
  77725. * @param transformation the transformation matrix to apply
  77726. * @returns the new vector
  77727. */
  77728. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77729. /**
  77730. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77731. * This methods computes transformed normalized direction vectors only.
  77732. * @param vector the vector to transform
  77733. * @param transformation the transformation matrix to apply
  77734. * @param result the vector to store the result in
  77735. */
  77736. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77737. /**
  77738. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77739. * This methods computes transformed normalized direction vectors only.
  77740. * @param x value to transform
  77741. * @param y value to transform
  77742. * @param z value to transform
  77743. * @param w value to transform
  77744. * @param transformation the transformation matrix to apply
  77745. * @param result the vector to store the results in
  77746. */
  77747. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77748. /**
  77749. * Creates a new Vector4 from a Vector3
  77750. * @param source defines the source data
  77751. * @param w defines the 4th component (default is 0)
  77752. * @returns a new Vector4
  77753. */
  77754. static FromVector3(source: Vector3, w?: number): Vector4;
  77755. }
  77756. /**
  77757. * Class used to store quaternion data
  77758. * @see https://en.wikipedia.org/wiki/Quaternion
  77759. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77760. */
  77761. export class Quaternion {
  77762. /** defines the first component (0 by default) */
  77763. x: number;
  77764. /** defines the second component (0 by default) */
  77765. y: number;
  77766. /** defines the third component (0 by default) */
  77767. z: number;
  77768. /** defines the fourth component (1.0 by default) */
  77769. w: number;
  77770. /**
  77771. * Creates a new Quaternion from the given floats
  77772. * @param x defines the first component (0 by default)
  77773. * @param y defines the second component (0 by default)
  77774. * @param z defines the third component (0 by default)
  77775. * @param w defines the fourth component (1.0 by default)
  77776. */
  77777. constructor(
  77778. /** defines the first component (0 by default) */
  77779. x?: number,
  77780. /** defines the second component (0 by default) */
  77781. y?: number,
  77782. /** defines the third component (0 by default) */
  77783. z?: number,
  77784. /** defines the fourth component (1.0 by default) */
  77785. w?: number);
  77786. /**
  77787. * Gets a string representation for the current quaternion
  77788. * @returns a string with the Quaternion coordinates
  77789. */
  77790. toString(): string;
  77791. /**
  77792. * Gets the class name of the quaternion
  77793. * @returns the string "Quaternion"
  77794. */
  77795. getClassName(): string;
  77796. /**
  77797. * Gets a hash code for this quaternion
  77798. * @returns the quaternion hash code
  77799. */
  77800. getHashCode(): number;
  77801. /**
  77802. * Copy the quaternion to an array
  77803. * @returns a new array populated with 4 elements from the quaternion coordinates
  77804. */
  77805. asArray(): number[];
  77806. /**
  77807. * Check if two quaternions are equals
  77808. * @param otherQuaternion defines the second operand
  77809. * @return true if the current quaternion and the given one coordinates are strictly equals
  77810. */
  77811. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77812. /**
  77813. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77814. * @param otherQuaternion defines the other quaternion
  77815. * @param epsilon defines the minimal distance to consider equality
  77816. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77817. */
  77818. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77819. /**
  77820. * Clone the current quaternion
  77821. * @returns a new quaternion copied from the current one
  77822. */
  77823. clone(): Quaternion;
  77824. /**
  77825. * Copy a quaternion to the current one
  77826. * @param other defines the other quaternion
  77827. * @returns the updated current quaternion
  77828. */
  77829. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77830. /**
  77831. * Updates the current quaternion with the given float coordinates
  77832. * @param x defines the x coordinate
  77833. * @param y defines the y coordinate
  77834. * @param z defines the z coordinate
  77835. * @param w defines the w coordinate
  77836. * @returns the updated current quaternion
  77837. */
  77838. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77839. /**
  77840. * Updates the current quaternion from the given float coordinates
  77841. * @param x defines the x coordinate
  77842. * @param y defines the y coordinate
  77843. * @param z defines the z coordinate
  77844. * @param w defines the w coordinate
  77845. * @returns the updated current quaternion
  77846. */
  77847. set(x: number, y: number, z: number, w: number): Quaternion;
  77848. /**
  77849. * Adds two quaternions
  77850. * @param other defines the second operand
  77851. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77852. */
  77853. add(other: DeepImmutable<Quaternion>): Quaternion;
  77854. /**
  77855. * Add a quaternion to the current one
  77856. * @param other defines the quaternion to add
  77857. * @returns the current quaternion
  77858. */
  77859. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77860. /**
  77861. * Subtract two quaternions
  77862. * @param other defines the second operand
  77863. * @returns a new quaternion as the subtraction result of the given one from the current one
  77864. */
  77865. subtract(other: Quaternion): Quaternion;
  77866. /**
  77867. * Multiplies the current quaternion by a scale factor
  77868. * @param value defines the scale factor
  77869. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77870. */
  77871. scale(value: number): Quaternion;
  77872. /**
  77873. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77874. * @param scale defines the scale factor
  77875. * @param result defines the Quaternion object where to store the result
  77876. * @returns the unmodified current quaternion
  77877. */
  77878. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77879. /**
  77880. * Multiplies in place the current quaternion by a scale factor
  77881. * @param value defines the scale factor
  77882. * @returns the current modified quaternion
  77883. */
  77884. scaleInPlace(value: number): Quaternion;
  77885. /**
  77886. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77887. * @param scale defines the scale factor
  77888. * @param result defines the Quaternion object where to store the result
  77889. * @returns the unmodified current quaternion
  77890. */
  77891. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77892. /**
  77893. * Multiplies two quaternions
  77894. * @param q1 defines the second operand
  77895. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77896. */
  77897. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77898. /**
  77899. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77900. * @param q1 defines the second operand
  77901. * @param result defines the target quaternion
  77902. * @returns the current quaternion
  77903. */
  77904. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77905. /**
  77906. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77907. * @param q1 defines the second operand
  77908. * @returns the currentupdated quaternion
  77909. */
  77910. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77911. /**
  77912. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77913. * @param ref defines the target quaternion
  77914. * @returns the current quaternion
  77915. */
  77916. conjugateToRef(ref: Quaternion): Quaternion;
  77917. /**
  77918. * Conjugates in place (1-q) the current quaternion
  77919. * @returns the current updated quaternion
  77920. */
  77921. conjugateInPlace(): Quaternion;
  77922. /**
  77923. * Conjugates in place (1-q) the current quaternion
  77924. * @returns a new quaternion
  77925. */
  77926. conjugate(): Quaternion;
  77927. /**
  77928. * Gets length of current quaternion
  77929. * @returns the quaternion length (float)
  77930. */
  77931. length(): number;
  77932. /**
  77933. * Normalize in place the current quaternion
  77934. * @returns the current updated quaternion
  77935. */
  77936. normalize(): Quaternion;
  77937. /**
  77938. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77939. * @param order is a reserved parameter and is ignore for now
  77940. * @returns a new Vector3 containing the Euler angles
  77941. */
  77942. toEulerAngles(order?: string): Vector3;
  77943. /**
  77944. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77945. * @param result defines the vector which will be filled with the Euler angles
  77946. * @param order is a reserved parameter and is ignore for now
  77947. * @returns the current unchanged quaternion
  77948. */
  77949. toEulerAnglesToRef(result: Vector3): Quaternion;
  77950. /**
  77951. * Updates the given rotation matrix with the current quaternion values
  77952. * @param result defines the target matrix
  77953. * @returns the current unchanged quaternion
  77954. */
  77955. toRotationMatrix(result: Matrix): Quaternion;
  77956. /**
  77957. * Updates the current quaternion from the given rotation matrix values
  77958. * @param matrix defines the source matrix
  77959. * @returns the current updated quaternion
  77960. */
  77961. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77962. /**
  77963. * Creates a new quaternion from a rotation matrix
  77964. * @param matrix defines the source matrix
  77965. * @returns a new quaternion created from the given rotation matrix values
  77966. */
  77967. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77968. /**
  77969. * Updates the given quaternion with the given rotation matrix values
  77970. * @param matrix defines the source matrix
  77971. * @param result defines the target quaternion
  77972. */
  77973. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77974. /**
  77975. * Returns the dot product (float) between the quaternions "left" and "right"
  77976. * @param left defines the left operand
  77977. * @param right defines the right operand
  77978. * @returns the dot product
  77979. */
  77980. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77981. /**
  77982. * Checks if the two quaternions are close to each other
  77983. * @param quat0 defines the first quaternion to check
  77984. * @param quat1 defines the second quaternion to check
  77985. * @returns true if the two quaternions are close to each other
  77986. */
  77987. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77988. /**
  77989. * Creates an empty quaternion
  77990. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77991. */
  77992. static Zero(): Quaternion;
  77993. /**
  77994. * Inverse a given quaternion
  77995. * @param q defines the source quaternion
  77996. * @returns a new quaternion as the inverted current quaternion
  77997. */
  77998. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77999. /**
  78000. * Inverse a given quaternion
  78001. * @param q defines the source quaternion
  78002. * @param result the quaternion the result will be stored in
  78003. * @returns the result quaternion
  78004. */
  78005. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  78006. /**
  78007. * Creates an identity quaternion
  78008. * @returns the identity quaternion
  78009. */
  78010. static Identity(): Quaternion;
  78011. /**
  78012. * Gets a boolean indicating if the given quaternion is identity
  78013. * @param quaternion defines the quaternion to check
  78014. * @returns true if the quaternion is identity
  78015. */
  78016. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  78017. /**
  78018. * Creates a quaternion from a rotation around an axis
  78019. * @param axis defines the axis to use
  78020. * @param angle defines the angle to use
  78021. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  78022. */
  78023. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78024. /**
  78025. * Creates a rotation around an axis and stores it into the given quaternion
  78026. * @param axis defines the axis to use
  78027. * @param angle defines the angle to use
  78028. * @param result defines the target quaternion
  78029. * @returns the target quaternion
  78030. */
  78031. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78032. /**
  78033. * Creates a new quaternion from data stored into an array
  78034. * @param array defines the data source
  78035. * @param offset defines the offset in the source array where the data starts
  78036. * @returns a new quaternion
  78037. */
  78038. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78039. /**
  78040. * Updates the given quaternion "result" from the starting index of the given array.
  78041. * @param array the array to pull values from
  78042. * @param offset the offset into the array to start at
  78043. * @param result the quaternion to store the result in
  78044. */
  78045. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78046. /**
  78047. * Create a quaternion from Euler rotation angles
  78048. * @param x Pitch
  78049. * @param y Yaw
  78050. * @param z Roll
  78051. * @returns the new Quaternion
  78052. */
  78053. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78054. /**
  78055. * Updates a quaternion from Euler rotation angles
  78056. * @param x Pitch
  78057. * @param y Yaw
  78058. * @param z Roll
  78059. * @param result the quaternion to store the result
  78060. * @returns the updated quaternion
  78061. */
  78062. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78063. /**
  78064. * Create a quaternion from Euler rotation vector
  78065. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78066. * @returns the new Quaternion
  78067. */
  78068. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78069. /**
  78070. * Updates a quaternion from Euler rotation vector
  78071. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78072. * @param result the quaternion to store the result
  78073. * @returns the updated quaternion
  78074. */
  78075. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78076. /**
  78077. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78078. * @param yaw defines the rotation around Y axis
  78079. * @param pitch defines the rotation around X axis
  78080. * @param roll defines the rotation around Z axis
  78081. * @returns the new quaternion
  78082. */
  78083. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78084. /**
  78085. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78086. * @param yaw defines the rotation around Y axis
  78087. * @param pitch defines the rotation around X axis
  78088. * @param roll defines the rotation around Z axis
  78089. * @param result defines the target quaternion
  78090. */
  78091. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78092. /**
  78093. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78094. * @param alpha defines the rotation around first axis
  78095. * @param beta defines the rotation around second axis
  78096. * @param gamma defines the rotation around third axis
  78097. * @returns the new quaternion
  78098. */
  78099. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78100. /**
  78101. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78102. * @param alpha defines the rotation around first axis
  78103. * @param beta defines the rotation around second axis
  78104. * @param gamma defines the rotation around third axis
  78105. * @param result defines the target quaternion
  78106. */
  78107. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78108. /**
  78109. * 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)
  78110. * @param axis1 defines the first axis
  78111. * @param axis2 defines the second axis
  78112. * @param axis3 defines the third axis
  78113. * @returns the new quaternion
  78114. */
  78115. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78116. /**
  78117. * 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
  78118. * @param axis1 defines the first axis
  78119. * @param axis2 defines the second axis
  78120. * @param axis3 defines the third axis
  78121. * @param ref defines the target quaternion
  78122. */
  78123. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78124. /**
  78125. * Interpolates between two quaternions
  78126. * @param left defines first quaternion
  78127. * @param right defines second quaternion
  78128. * @param amount defines the gradient to use
  78129. * @returns the new interpolated quaternion
  78130. */
  78131. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78132. /**
  78133. * Interpolates between two quaternions and stores it into a target quaternion
  78134. * @param left defines first quaternion
  78135. * @param right defines second quaternion
  78136. * @param amount defines the gradient to use
  78137. * @param result defines the target quaternion
  78138. */
  78139. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78140. /**
  78141. * Interpolate between two quaternions using Hermite interpolation
  78142. * @param value1 defines first quaternion
  78143. * @param tangent1 defines the incoming tangent
  78144. * @param value2 defines second quaternion
  78145. * @param tangent2 defines the outgoing tangent
  78146. * @param amount defines the target quaternion
  78147. * @returns the new interpolated quaternion
  78148. */
  78149. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78150. }
  78151. /**
  78152. * Class used to store matrix data (4x4)
  78153. */
  78154. export class Matrix {
  78155. private static _updateFlagSeed;
  78156. private static _identityReadOnly;
  78157. private _isIdentity;
  78158. private _isIdentityDirty;
  78159. private _isIdentity3x2;
  78160. private _isIdentity3x2Dirty;
  78161. /**
  78162. * Gets the update flag of the matrix which is an unique number for the matrix.
  78163. * It will be incremented every time the matrix data change.
  78164. * You can use it to speed the comparison between two versions of the same matrix.
  78165. */
  78166. updateFlag: number;
  78167. private readonly _m;
  78168. /**
  78169. * Gets the internal data of the matrix
  78170. */
  78171. get m(): DeepImmutable<Float32Array>;
  78172. /** @hidden */
  78173. _markAsUpdated(): void;
  78174. /** @hidden */
  78175. private _updateIdentityStatus;
  78176. /**
  78177. * Creates an empty matrix (filled with zeros)
  78178. */
  78179. constructor();
  78180. /**
  78181. * Check if the current matrix is identity
  78182. * @returns true is the matrix is the identity matrix
  78183. */
  78184. isIdentity(): boolean;
  78185. /**
  78186. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78187. * @returns true is the matrix is the identity matrix
  78188. */
  78189. isIdentityAs3x2(): boolean;
  78190. /**
  78191. * Gets the determinant of the matrix
  78192. * @returns the matrix determinant
  78193. */
  78194. determinant(): number;
  78195. /**
  78196. * Returns the matrix as a Float32Array
  78197. * @returns the matrix underlying array
  78198. */
  78199. toArray(): DeepImmutable<Float32Array>;
  78200. /**
  78201. * Returns the matrix as a Float32Array
  78202. * @returns the matrix underlying array.
  78203. */
  78204. asArray(): DeepImmutable<Float32Array>;
  78205. /**
  78206. * Inverts the current matrix in place
  78207. * @returns the current inverted matrix
  78208. */
  78209. invert(): Matrix;
  78210. /**
  78211. * Sets all the matrix elements to zero
  78212. * @returns the current matrix
  78213. */
  78214. reset(): Matrix;
  78215. /**
  78216. * Adds the current matrix with a second one
  78217. * @param other defines the matrix to add
  78218. * @returns a new matrix as the addition of the current matrix and the given one
  78219. */
  78220. add(other: DeepImmutable<Matrix>): Matrix;
  78221. /**
  78222. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78223. * @param other defines the matrix to add
  78224. * @param result defines the target matrix
  78225. * @returns the current matrix
  78226. */
  78227. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78228. /**
  78229. * Adds in place the given matrix to the current matrix
  78230. * @param other defines the second operand
  78231. * @returns the current updated matrix
  78232. */
  78233. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78234. /**
  78235. * Sets the given matrix to the current inverted Matrix
  78236. * @param other defines the target matrix
  78237. * @returns the unmodified current matrix
  78238. */
  78239. invertToRef(other: Matrix): Matrix;
  78240. /**
  78241. * add a value at the specified position in the current Matrix
  78242. * @param index the index of the value within the matrix. between 0 and 15.
  78243. * @param value the value to be added
  78244. * @returns the current updated matrix
  78245. */
  78246. addAtIndex(index: number, value: number): Matrix;
  78247. /**
  78248. * mutiply the specified position in the current Matrix by a value
  78249. * @param index the index of the value within the matrix. between 0 and 15.
  78250. * @param value the value to be added
  78251. * @returns the current updated matrix
  78252. */
  78253. multiplyAtIndex(index: number, value: number): Matrix;
  78254. /**
  78255. * Inserts the translation vector (using 3 floats) in the current matrix
  78256. * @param x defines the 1st component of the translation
  78257. * @param y defines the 2nd component of the translation
  78258. * @param z defines the 3rd component of the translation
  78259. * @returns the current updated matrix
  78260. */
  78261. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78262. /**
  78263. * Adds the translation vector (using 3 floats) in the current matrix
  78264. * @param x defines the 1st component of the translation
  78265. * @param y defines the 2nd component of the translation
  78266. * @param z defines the 3rd component of the translation
  78267. * @returns the current updated matrix
  78268. */
  78269. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78270. /**
  78271. * Inserts the translation vector in the current matrix
  78272. * @param vector3 defines the translation to insert
  78273. * @returns the current updated matrix
  78274. */
  78275. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78276. /**
  78277. * Gets the translation value of the current matrix
  78278. * @returns a new Vector3 as the extracted translation from the matrix
  78279. */
  78280. getTranslation(): Vector3;
  78281. /**
  78282. * Fill a Vector3 with the extracted translation from the matrix
  78283. * @param result defines the Vector3 where to store the translation
  78284. * @returns the current matrix
  78285. */
  78286. getTranslationToRef(result: Vector3): Matrix;
  78287. /**
  78288. * Remove rotation and scaling part from the matrix
  78289. * @returns the updated matrix
  78290. */
  78291. removeRotationAndScaling(): Matrix;
  78292. /**
  78293. * Multiply two matrices
  78294. * @param other defines the second operand
  78295. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78296. */
  78297. multiply(other: DeepImmutable<Matrix>): Matrix;
  78298. /**
  78299. * Copy the current matrix from the given one
  78300. * @param other defines the source matrix
  78301. * @returns the current updated matrix
  78302. */
  78303. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78304. /**
  78305. * Populates the given array from the starting index with the current matrix values
  78306. * @param array defines the target array
  78307. * @param offset defines the offset in the target array where to start storing values
  78308. * @returns the current matrix
  78309. */
  78310. copyToArray(array: Float32Array, offset?: number): Matrix;
  78311. /**
  78312. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78313. * @param other defines the second operand
  78314. * @param result defines the matrix where to store the multiplication
  78315. * @returns the current matrix
  78316. */
  78317. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78318. /**
  78319. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78320. * @param other defines the second operand
  78321. * @param result defines the array where to store the multiplication
  78322. * @param offset defines the offset in the target array where to start storing values
  78323. * @returns the current matrix
  78324. */
  78325. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78326. /**
  78327. * Check equality between this matrix and a second one
  78328. * @param value defines the second matrix to compare
  78329. * @returns true is the current matrix and the given one values are strictly equal
  78330. */
  78331. equals(value: DeepImmutable<Matrix>): boolean;
  78332. /**
  78333. * Clone the current matrix
  78334. * @returns a new matrix from the current matrix
  78335. */
  78336. clone(): Matrix;
  78337. /**
  78338. * Returns the name of the current matrix class
  78339. * @returns the string "Matrix"
  78340. */
  78341. getClassName(): string;
  78342. /**
  78343. * Gets the hash code of the current matrix
  78344. * @returns the hash code
  78345. */
  78346. getHashCode(): number;
  78347. /**
  78348. * Decomposes the current Matrix into a translation, rotation and scaling components
  78349. * @param scale defines the scale vector3 given as a reference to update
  78350. * @param rotation defines the rotation quaternion given as a reference to update
  78351. * @param translation defines the translation vector3 given as a reference to update
  78352. * @returns true if operation was successful
  78353. */
  78354. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78355. /**
  78356. * Gets specific row of the matrix
  78357. * @param index defines the number of the row to get
  78358. * @returns the index-th row of the current matrix as a new Vector4
  78359. */
  78360. getRow(index: number): Nullable<Vector4>;
  78361. /**
  78362. * Sets the index-th row of the current matrix to the vector4 values
  78363. * @param index defines the number of the row to set
  78364. * @param row defines the target vector4
  78365. * @returns the updated current matrix
  78366. */
  78367. setRow(index: number, row: Vector4): Matrix;
  78368. /**
  78369. * Compute the transpose of the matrix
  78370. * @returns the new transposed matrix
  78371. */
  78372. transpose(): Matrix;
  78373. /**
  78374. * Compute the transpose of the matrix and store it in a given matrix
  78375. * @param result defines the target matrix
  78376. * @returns the current matrix
  78377. */
  78378. transposeToRef(result: Matrix): Matrix;
  78379. /**
  78380. * Sets the index-th row of the current matrix with the given 4 x float values
  78381. * @param index defines the row index
  78382. * @param x defines the x component to set
  78383. * @param y defines the y component to set
  78384. * @param z defines the z component to set
  78385. * @param w defines the w component to set
  78386. * @returns the updated current matrix
  78387. */
  78388. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78389. /**
  78390. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78391. * @param scale defines the scale factor
  78392. * @returns a new matrix
  78393. */
  78394. scale(scale: number): Matrix;
  78395. /**
  78396. * Scale the current matrix values by a factor to a given result matrix
  78397. * @param scale defines the scale factor
  78398. * @param result defines the matrix to store the result
  78399. * @returns the current matrix
  78400. */
  78401. scaleToRef(scale: number, result: Matrix): Matrix;
  78402. /**
  78403. * Scale the current matrix values by a factor and add the result to a given matrix
  78404. * @param scale defines the scale factor
  78405. * @param result defines the Matrix to store the result
  78406. * @returns the current matrix
  78407. */
  78408. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78409. /**
  78410. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78411. * @param ref matrix to store the result
  78412. */
  78413. toNormalMatrix(ref: Matrix): void;
  78414. /**
  78415. * Gets only rotation part of the current matrix
  78416. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78417. */
  78418. getRotationMatrix(): Matrix;
  78419. /**
  78420. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78421. * @param result defines the target matrix to store data to
  78422. * @returns the current matrix
  78423. */
  78424. getRotationMatrixToRef(result: Matrix): Matrix;
  78425. /**
  78426. * Toggles model matrix from being right handed to left handed in place and vice versa
  78427. */
  78428. toggleModelMatrixHandInPlace(): void;
  78429. /**
  78430. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78431. */
  78432. toggleProjectionMatrixHandInPlace(): void;
  78433. /**
  78434. * Creates a matrix from an array
  78435. * @param array defines the source array
  78436. * @param offset defines an offset in the source array
  78437. * @returns a new Matrix set from the starting index of the given array
  78438. */
  78439. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78440. /**
  78441. * Copy the content of an array into a given matrix
  78442. * @param array defines the source array
  78443. * @param offset defines an offset in the source array
  78444. * @param result defines the target matrix
  78445. */
  78446. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78447. /**
  78448. * Stores an array into a matrix after having multiplied each component by a given factor
  78449. * @param array defines the source array
  78450. * @param offset defines the offset in the source array
  78451. * @param scale defines the scaling factor
  78452. * @param result defines the target matrix
  78453. */
  78454. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78455. /**
  78456. * Gets an identity matrix that must not be updated
  78457. */
  78458. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78459. /**
  78460. * Stores a list of values (16) inside a given matrix
  78461. * @param initialM11 defines 1st value of 1st row
  78462. * @param initialM12 defines 2nd value of 1st row
  78463. * @param initialM13 defines 3rd value of 1st row
  78464. * @param initialM14 defines 4th value of 1st row
  78465. * @param initialM21 defines 1st value of 2nd row
  78466. * @param initialM22 defines 2nd value of 2nd row
  78467. * @param initialM23 defines 3rd value of 2nd row
  78468. * @param initialM24 defines 4th value of 2nd row
  78469. * @param initialM31 defines 1st value of 3rd row
  78470. * @param initialM32 defines 2nd value of 3rd row
  78471. * @param initialM33 defines 3rd value of 3rd row
  78472. * @param initialM34 defines 4th value of 3rd row
  78473. * @param initialM41 defines 1st value of 4th row
  78474. * @param initialM42 defines 2nd value of 4th row
  78475. * @param initialM43 defines 3rd value of 4th row
  78476. * @param initialM44 defines 4th value of 4th row
  78477. * @param result defines the target matrix
  78478. */
  78479. 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;
  78480. /**
  78481. * Creates new matrix from a list of values (16)
  78482. * @param initialM11 defines 1st value of 1st row
  78483. * @param initialM12 defines 2nd value of 1st row
  78484. * @param initialM13 defines 3rd value of 1st row
  78485. * @param initialM14 defines 4th value of 1st row
  78486. * @param initialM21 defines 1st value of 2nd row
  78487. * @param initialM22 defines 2nd value of 2nd row
  78488. * @param initialM23 defines 3rd value of 2nd row
  78489. * @param initialM24 defines 4th value of 2nd row
  78490. * @param initialM31 defines 1st value of 3rd row
  78491. * @param initialM32 defines 2nd value of 3rd row
  78492. * @param initialM33 defines 3rd value of 3rd row
  78493. * @param initialM34 defines 4th value of 3rd row
  78494. * @param initialM41 defines 1st value of 4th row
  78495. * @param initialM42 defines 2nd value of 4th row
  78496. * @param initialM43 defines 3rd value of 4th row
  78497. * @param initialM44 defines 4th value of 4th row
  78498. * @returns the new matrix
  78499. */
  78500. 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;
  78501. /**
  78502. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78503. * @param scale defines the scale vector3
  78504. * @param rotation defines the rotation quaternion
  78505. * @param translation defines the translation vector3
  78506. * @returns a new matrix
  78507. */
  78508. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78509. /**
  78510. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78511. * @param scale defines the scale vector3
  78512. * @param rotation defines the rotation quaternion
  78513. * @param translation defines the translation vector3
  78514. * @param result defines the target matrix
  78515. */
  78516. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78517. /**
  78518. * Creates a new identity matrix
  78519. * @returns a new identity matrix
  78520. */
  78521. static Identity(): Matrix;
  78522. /**
  78523. * Creates a new identity matrix and stores the result in a given matrix
  78524. * @param result defines the target matrix
  78525. */
  78526. static IdentityToRef(result: Matrix): void;
  78527. /**
  78528. * Creates a new zero matrix
  78529. * @returns a new zero matrix
  78530. */
  78531. static Zero(): Matrix;
  78532. /**
  78533. * Creates a new rotation matrix for "angle" radians around the X axis
  78534. * @param angle defines the angle (in radians) to use
  78535. * @return the new matrix
  78536. */
  78537. static RotationX(angle: number): Matrix;
  78538. /**
  78539. * Creates a new matrix as the invert of a given matrix
  78540. * @param source defines the source matrix
  78541. * @returns the new matrix
  78542. */
  78543. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78544. /**
  78545. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78546. * @param angle defines the angle (in radians) to use
  78547. * @param result defines the target matrix
  78548. */
  78549. static RotationXToRef(angle: number, result: Matrix): void;
  78550. /**
  78551. * Creates a new rotation matrix for "angle" radians around the Y axis
  78552. * @param angle defines the angle (in radians) to use
  78553. * @return the new matrix
  78554. */
  78555. static RotationY(angle: number): Matrix;
  78556. /**
  78557. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78558. * @param angle defines the angle (in radians) to use
  78559. * @param result defines the target matrix
  78560. */
  78561. static RotationYToRef(angle: number, result: Matrix): void;
  78562. /**
  78563. * Creates a new rotation matrix for "angle" radians around the Z axis
  78564. * @param angle defines the angle (in radians) to use
  78565. * @return the new matrix
  78566. */
  78567. static RotationZ(angle: number): Matrix;
  78568. /**
  78569. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78570. * @param angle defines the angle (in radians) to use
  78571. * @param result defines the target matrix
  78572. */
  78573. static RotationZToRef(angle: number, result: Matrix): void;
  78574. /**
  78575. * Creates a new rotation matrix for "angle" radians around the given axis
  78576. * @param axis defines the axis to use
  78577. * @param angle defines the angle (in radians) to use
  78578. * @return the new matrix
  78579. */
  78580. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78581. /**
  78582. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78583. * @param axis defines the axis to use
  78584. * @param angle defines the angle (in radians) to use
  78585. * @param result defines the target matrix
  78586. */
  78587. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78588. /**
  78589. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78590. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78591. * @param from defines the vector to align
  78592. * @param to defines the vector to align to
  78593. * @param result defines the target matrix
  78594. */
  78595. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78596. /**
  78597. * Creates a rotation matrix
  78598. * @param yaw defines the yaw angle in radians (Y axis)
  78599. * @param pitch defines the pitch angle in radians (X axis)
  78600. * @param roll defines the roll angle in radians (X axis)
  78601. * @returns the new rotation matrix
  78602. */
  78603. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78604. /**
  78605. * Creates a rotation matrix and stores it in a given matrix
  78606. * @param yaw defines the yaw angle in radians (Y axis)
  78607. * @param pitch defines the pitch angle in radians (X axis)
  78608. * @param roll defines the roll angle in radians (X axis)
  78609. * @param result defines the target matrix
  78610. */
  78611. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78612. /**
  78613. * Creates a scaling matrix
  78614. * @param x defines the scale factor on X axis
  78615. * @param y defines the scale factor on Y axis
  78616. * @param z defines the scale factor on Z axis
  78617. * @returns the new matrix
  78618. */
  78619. static Scaling(x: number, y: number, z: number): Matrix;
  78620. /**
  78621. * Creates a scaling matrix and stores it in a given matrix
  78622. * @param x defines the scale factor on X axis
  78623. * @param y defines the scale factor on Y axis
  78624. * @param z defines the scale factor on Z axis
  78625. * @param result defines the target matrix
  78626. */
  78627. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78628. /**
  78629. * Creates a translation matrix
  78630. * @param x defines the translation on X axis
  78631. * @param y defines the translation on Y axis
  78632. * @param z defines the translationon Z axis
  78633. * @returns the new matrix
  78634. */
  78635. static Translation(x: number, y: number, z: number): Matrix;
  78636. /**
  78637. * Creates a translation matrix and stores it in a given matrix
  78638. * @param x defines the translation on X axis
  78639. * @param y defines the translation on Y axis
  78640. * @param z defines the translationon Z axis
  78641. * @param result defines the target matrix
  78642. */
  78643. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78644. /**
  78645. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78646. * @param startValue defines the start value
  78647. * @param endValue defines the end value
  78648. * @param gradient defines the gradient factor
  78649. * @returns the new matrix
  78650. */
  78651. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78652. /**
  78653. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78654. * @param startValue defines the start value
  78655. * @param endValue defines the end value
  78656. * @param gradient defines the gradient factor
  78657. * @param result defines the Matrix object where to store data
  78658. */
  78659. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78660. /**
  78661. * Builds a new matrix whose values are computed by:
  78662. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78663. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78664. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78665. * @param startValue defines the first matrix
  78666. * @param endValue defines the second matrix
  78667. * @param gradient defines the gradient between the two matrices
  78668. * @returns the new matrix
  78669. */
  78670. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78671. /**
  78672. * Update a matrix to values which are computed by:
  78673. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78674. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78675. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78676. * @param startValue defines the first matrix
  78677. * @param endValue defines the second matrix
  78678. * @param gradient defines the gradient between the two matrices
  78679. * @param result defines the target matrix
  78680. */
  78681. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78682. /**
  78683. * 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"
  78684. * This function works in left handed mode
  78685. * @param eye defines the final position of the entity
  78686. * @param target defines where the entity should look at
  78687. * @param up defines the up vector for the entity
  78688. * @returns the new matrix
  78689. */
  78690. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78691. /**
  78692. * 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".
  78693. * This function works in left handed mode
  78694. * @param eye defines the final position of the entity
  78695. * @param target defines where the entity should look at
  78696. * @param up defines the up vector for the entity
  78697. * @param result defines the target matrix
  78698. */
  78699. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78700. /**
  78701. * 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"
  78702. * This function works in right handed mode
  78703. * @param eye defines the final position of the entity
  78704. * @param target defines where the entity should look at
  78705. * @param up defines the up vector for the entity
  78706. * @returns the new matrix
  78707. */
  78708. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78709. /**
  78710. * 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".
  78711. * This function works in right handed mode
  78712. * @param eye defines the final position of the entity
  78713. * @param target defines where the entity should look at
  78714. * @param up defines the up vector for the entity
  78715. * @param result defines the target matrix
  78716. */
  78717. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78718. /**
  78719. * Create a left-handed orthographic projection matrix
  78720. * @param width defines the viewport width
  78721. * @param height defines the viewport height
  78722. * @param znear defines the near clip plane
  78723. * @param zfar defines the far clip plane
  78724. * @returns a new matrix as a left-handed orthographic projection matrix
  78725. */
  78726. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78727. /**
  78728. * Store a left-handed orthographic projection to a given matrix
  78729. * @param width defines the viewport width
  78730. * @param height defines the viewport height
  78731. * @param znear defines the near clip plane
  78732. * @param zfar defines the far clip plane
  78733. * @param result defines the target matrix
  78734. */
  78735. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78736. /**
  78737. * Create a left-handed orthographic projection matrix
  78738. * @param left defines the viewport left coordinate
  78739. * @param right defines the viewport right coordinate
  78740. * @param bottom defines the viewport bottom coordinate
  78741. * @param top defines the viewport top coordinate
  78742. * @param znear defines the near clip plane
  78743. * @param zfar defines the far clip plane
  78744. * @returns a new matrix as a left-handed orthographic projection matrix
  78745. */
  78746. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78747. /**
  78748. * Stores a left-handed orthographic projection into a given matrix
  78749. * @param left defines the viewport left coordinate
  78750. * @param right defines the viewport right coordinate
  78751. * @param bottom defines the viewport bottom coordinate
  78752. * @param top defines the viewport top coordinate
  78753. * @param znear defines the near clip plane
  78754. * @param zfar defines the far clip plane
  78755. * @param result defines the target matrix
  78756. */
  78757. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78758. /**
  78759. * Creates a right-handed orthographic projection matrix
  78760. * @param left defines the viewport left coordinate
  78761. * @param right defines the viewport right coordinate
  78762. * @param bottom defines the viewport bottom coordinate
  78763. * @param top defines the viewport top coordinate
  78764. * @param znear defines the near clip plane
  78765. * @param zfar defines the far clip plane
  78766. * @returns a new matrix as a right-handed orthographic projection matrix
  78767. */
  78768. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78769. /**
  78770. * Stores a right-handed orthographic projection into a given matrix
  78771. * @param left defines the viewport left coordinate
  78772. * @param right defines the viewport right coordinate
  78773. * @param bottom defines the viewport bottom coordinate
  78774. * @param top defines the viewport top coordinate
  78775. * @param znear defines the near clip plane
  78776. * @param zfar defines the far clip plane
  78777. * @param result defines the target matrix
  78778. */
  78779. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78780. /**
  78781. * Creates a left-handed perspective projection matrix
  78782. * @param width defines the viewport width
  78783. * @param height defines the viewport height
  78784. * @param znear defines the near clip plane
  78785. * @param zfar defines the far clip plane
  78786. * @returns a new matrix as a left-handed perspective projection matrix
  78787. */
  78788. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78789. /**
  78790. * Creates a left-handed perspective projection matrix
  78791. * @param fov defines the horizontal field of view
  78792. * @param aspect defines the aspect ratio
  78793. * @param znear defines the near clip plane
  78794. * @param zfar defines the far clip plane
  78795. * @returns a new matrix as a left-handed perspective projection matrix
  78796. */
  78797. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78798. /**
  78799. * Stores a left-handed perspective projection into a given matrix
  78800. * @param fov defines the horizontal field of view
  78801. * @param aspect defines the aspect ratio
  78802. * @param znear defines the near clip plane
  78803. * @param zfar defines the far clip plane
  78804. * @param result defines the target matrix
  78805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78806. */
  78807. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78808. /**
  78809. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78810. * @param fov defines the horizontal field of view
  78811. * @param aspect defines the aspect ratio
  78812. * @param znear defines the near clip plane
  78813. * @param zfar not used as infinity is used as far clip
  78814. * @param result defines the target matrix
  78815. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78816. */
  78817. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78818. /**
  78819. * Creates a right-handed perspective projection matrix
  78820. * @param fov defines the horizontal field of view
  78821. * @param aspect defines the aspect ratio
  78822. * @param znear defines the near clip plane
  78823. * @param zfar defines the far clip plane
  78824. * @returns a new matrix as a right-handed perspective projection matrix
  78825. */
  78826. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78827. /**
  78828. * Stores a right-handed perspective projection into a given matrix
  78829. * @param fov defines the horizontal field of view
  78830. * @param aspect defines the aspect ratio
  78831. * @param znear defines the near clip plane
  78832. * @param zfar defines the far clip plane
  78833. * @param result defines the target matrix
  78834. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78835. */
  78836. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78837. /**
  78838. * Stores a right-handed perspective projection into a given matrix
  78839. * @param fov defines the horizontal field of view
  78840. * @param aspect defines the aspect ratio
  78841. * @param znear defines the near clip plane
  78842. * @param zfar not used as infinity is used as far clip
  78843. * @param result defines the target matrix
  78844. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78845. */
  78846. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78847. /**
  78848. * Stores a perspective projection for WebVR info a given matrix
  78849. * @param fov defines the field of view
  78850. * @param znear defines the near clip plane
  78851. * @param zfar defines the far clip plane
  78852. * @param result defines the target matrix
  78853. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78854. */
  78855. static PerspectiveFovWebVRToRef(fov: {
  78856. upDegrees: number;
  78857. downDegrees: number;
  78858. leftDegrees: number;
  78859. rightDegrees: number;
  78860. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78861. /**
  78862. * Computes a complete transformation matrix
  78863. * @param viewport defines the viewport to use
  78864. * @param world defines the world matrix
  78865. * @param view defines the view matrix
  78866. * @param projection defines the projection matrix
  78867. * @param zmin defines the near clip plane
  78868. * @param zmax defines the far clip plane
  78869. * @returns the transformation matrix
  78870. */
  78871. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78872. /**
  78873. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78874. * @param matrix defines the matrix to use
  78875. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78876. */
  78877. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78878. /**
  78879. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78880. * @param matrix defines the matrix to use
  78881. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78882. */
  78883. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78884. /**
  78885. * Compute the transpose of a given matrix
  78886. * @param matrix defines the matrix to transpose
  78887. * @returns the new matrix
  78888. */
  78889. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78890. /**
  78891. * Compute the transpose of a matrix and store it in a target matrix
  78892. * @param matrix defines the matrix to transpose
  78893. * @param result defines the target matrix
  78894. */
  78895. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78896. /**
  78897. * Computes a reflection matrix from a plane
  78898. * @param plane defines the reflection plane
  78899. * @returns a new matrix
  78900. */
  78901. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78902. /**
  78903. * Computes a reflection matrix from a plane
  78904. * @param plane defines the reflection plane
  78905. * @param result defines the target matrix
  78906. */
  78907. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78908. /**
  78909. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78910. * @param xaxis defines the value of the 1st axis
  78911. * @param yaxis defines the value of the 2nd axis
  78912. * @param zaxis defines the value of the 3rd axis
  78913. * @param result defines the target matrix
  78914. */
  78915. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78916. /**
  78917. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78918. * @param quat defines the quaternion to use
  78919. * @param result defines the target matrix
  78920. */
  78921. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78922. }
  78923. /**
  78924. * @hidden
  78925. */
  78926. export class TmpVectors {
  78927. static Vector2: Vector2[];
  78928. static Vector3: Vector3[];
  78929. static Vector4: Vector4[];
  78930. static Quaternion: Quaternion[];
  78931. static Matrix: Matrix[];
  78932. }
  78933. }
  78934. declare module BABYLON {
  78935. /**
  78936. * Defines potential orientation for back face culling
  78937. */
  78938. export enum Orientation {
  78939. /**
  78940. * Clockwise
  78941. */
  78942. CW = 0,
  78943. /** Counter clockwise */
  78944. CCW = 1
  78945. }
  78946. /** Class used to represent a Bezier curve */
  78947. export class BezierCurve {
  78948. /**
  78949. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78950. * @param t defines the time
  78951. * @param x1 defines the left coordinate on X axis
  78952. * @param y1 defines the left coordinate on Y axis
  78953. * @param x2 defines the right coordinate on X axis
  78954. * @param y2 defines the right coordinate on Y axis
  78955. * @returns the interpolated value
  78956. */
  78957. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78958. }
  78959. /**
  78960. * Defines angle representation
  78961. */
  78962. export class Angle {
  78963. private _radians;
  78964. /**
  78965. * Creates an Angle object of "radians" radians (float).
  78966. * @param radians the angle in radians
  78967. */
  78968. constructor(radians: number);
  78969. /**
  78970. * Get value in degrees
  78971. * @returns the Angle value in degrees (float)
  78972. */
  78973. degrees(): number;
  78974. /**
  78975. * Get value in radians
  78976. * @returns the Angle value in radians (float)
  78977. */
  78978. radians(): number;
  78979. /**
  78980. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78981. * @param a defines first vector
  78982. * @param b defines second vector
  78983. * @returns a new Angle
  78984. */
  78985. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78986. /**
  78987. * Gets a new Angle object from the given float in radians
  78988. * @param radians defines the angle value in radians
  78989. * @returns a new Angle
  78990. */
  78991. static FromRadians(radians: number): Angle;
  78992. /**
  78993. * Gets a new Angle object from the given float in degrees
  78994. * @param degrees defines the angle value in degrees
  78995. * @returns a new Angle
  78996. */
  78997. static FromDegrees(degrees: number): Angle;
  78998. }
  78999. /**
  79000. * This represents an arc in a 2d space.
  79001. */
  79002. export class Arc2 {
  79003. /** Defines the start point of the arc */
  79004. startPoint: Vector2;
  79005. /** Defines the mid point of the arc */
  79006. midPoint: Vector2;
  79007. /** Defines the end point of the arc */
  79008. endPoint: Vector2;
  79009. /**
  79010. * Defines the center point of the arc.
  79011. */
  79012. centerPoint: Vector2;
  79013. /**
  79014. * Defines the radius of the arc.
  79015. */
  79016. radius: number;
  79017. /**
  79018. * Defines the angle of the arc (from mid point to end point).
  79019. */
  79020. angle: Angle;
  79021. /**
  79022. * Defines the start angle of the arc (from start point to middle point).
  79023. */
  79024. startAngle: Angle;
  79025. /**
  79026. * Defines the orientation of the arc (clock wise/counter clock wise).
  79027. */
  79028. orientation: Orientation;
  79029. /**
  79030. * Creates an Arc object from the three given points : start, middle and end.
  79031. * @param startPoint Defines the start point of the arc
  79032. * @param midPoint Defines the midlle point of the arc
  79033. * @param endPoint Defines the end point of the arc
  79034. */
  79035. constructor(
  79036. /** Defines the start point of the arc */
  79037. startPoint: Vector2,
  79038. /** Defines the mid point of the arc */
  79039. midPoint: Vector2,
  79040. /** Defines the end point of the arc */
  79041. endPoint: Vector2);
  79042. }
  79043. /**
  79044. * Represents a 2D path made up of multiple 2D points
  79045. */
  79046. export class Path2 {
  79047. private _points;
  79048. private _length;
  79049. /**
  79050. * If the path start and end point are the same
  79051. */
  79052. closed: boolean;
  79053. /**
  79054. * Creates a Path2 object from the starting 2D coordinates x and y.
  79055. * @param x the starting points x value
  79056. * @param y the starting points y value
  79057. */
  79058. constructor(x: number, y: number);
  79059. /**
  79060. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79061. * @param x the added points x value
  79062. * @param y the added points y value
  79063. * @returns the updated Path2.
  79064. */
  79065. addLineTo(x: number, y: number): Path2;
  79066. /**
  79067. * 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.
  79068. * @param midX middle point x value
  79069. * @param midY middle point y value
  79070. * @param endX end point x value
  79071. * @param endY end point y value
  79072. * @param numberOfSegments (default: 36)
  79073. * @returns the updated Path2.
  79074. */
  79075. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79076. /**
  79077. * Closes the Path2.
  79078. * @returns the Path2.
  79079. */
  79080. close(): Path2;
  79081. /**
  79082. * Gets the sum of the distance between each sequential point in the path
  79083. * @returns the Path2 total length (float).
  79084. */
  79085. length(): number;
  79086. /**
  79087. * Gets the points which construct the path
  79088. * @returns the Path2 internal array of points.
  79089. */
  79090. getPoints(): Vector2[];
  79091. /**
  79092. * Retreives the point at the distance aways from the starting point
  79093. * @param normalizedLengthPosition the length along the path to retreive the point from
  79094. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79095. */
  79096. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79097. /**
  79098. * Creates a new path starting from an x and y position
  79099. * @param x starting x value
  79100. * @param y starting y value
  79101. * @returns a new Path2 starting at the coordinates (x, y).
  79102. */
  79103. static StartingAt(x: number, y: number): Path2;
  79104. }
  79105. /**
  79106. * Represents a 3D path made up of multiple 3D points
  79107. */
  79108. export class Path3D {
  79109. /**
  79110. * an array of Vector3, the curve axis of the Path3D
  79111. */
  79112. path: Vector3[];
  79113. private _curve;
  79114. private _distances;
  79115. private _tangents;
  79116. private _normals;
  79117. private _binormals;
  79118. private _raw;
  79119. private _alignTangentsWithPath;
  79120. private readonly _pointAtData;
  79121. /**
  79122. * new Path3D(path, normal, raw)
  79123. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79124. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79125. * @param path an array of Vector3, the curve axis of the Path3D
  79126. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79127. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79129. */
  79130. constructor(
  79131. /**
  79132. * an array of Vector3, the curve axis of the Path3D
  79133. */
  79134. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79135. /**
  79136. * Returns the Path3D array of successive Vector3 designing its curve.
  79137. * @returns the Path3D array of successive Vector3 designing its curve.
  79138. */
  79139. getCurve(): Vector3[];
  79140. /**
  79141. * Returns the Path3D array of successive Vector3 designing its curve.
  79142. * @returns the Path3D array of successive Vector3 designing its curve.
  79143. */
  79144. getPoints(): Vector3[];
  79145. /**
  79146. * @returns the computed length (float) of the path.
  79147. */
  79148. length(): number;
  79149. /**
  79150. * Returns an array populated with tangent vectors on each Path3D curve point.
  79151. * @returns an array populated with tangent vectors on each Path3D curve point.
  79152. */
  79153. getTangents(): Vector3[];
  79154. /**
  79155. * Returns an array populated with normal vectors on each Path3D curve point.
  79156. * @returns an array populated with normal vectors on each Path3D curve point.
  79157. */
  79158. getNormals(): Vector3[];
  79159. /**
  79160. * Returns an array populated with binormal vectors on each Path3D curve point.
  79161. * @returns an array populated with binormal vectors on each Path3D curve point.
  79162. */
  79163. getBinormals(): Vector3[];
  79164. /**
  79165. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79166. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79167. */
  79168. getDistances(): number[];
  79169. /**
  79170. * Returns an interpolated point along this path
  79171. * @param position the position of the point along this path, from 0.0 to 1.0
  79172. * @returns a new Vector3 as the point
  79173. */
  79174. getPointAt(position: number): Vector3;
  79175. /**
  79176. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79177. * @param position the position of the point along this path, from 0.0 to 1.0
  79178. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79179. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79180. */
  79181. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79182. /**
  79183. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79184. * @param position the position of the point along this path, from 0.0 to 1.0
  79185. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79186. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79187. */
  79188. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79189. /**
  79190. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  79191. * @param position the position of the point along this path, from 0.0 to 1.0
  79192. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  79193. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79194. */
  79195. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79196. /**
  79197. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  79198. * @param position the position of the point along this path, from 0.0 to 1.0
  79199. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79200. */
  79201. getDistanceAt(position: number): number;
  79202. /**
  79203. * Returns the array index of the previous point of an interpolated point along this path
  79204. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79205. * @returns the array index
  79206. */
  79207. getPreviousPointIndexAt(position: number): number;
  79208. /**
  79209. * 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)
  79210. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79211. * @returns the sub position
  79212. */
  79213. getSubPositionAt(position: number): number;
  79214. /**
  79215. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79216. * @param target the vector of which to get the closest position to
  79217. * @returns the position of the closest virtual point on this path to the target vector
  79218. */
  79219. getClosestPositionTo(target: Vector3): number;
  79220. /**
  79221. * Returns a sub path (slice) of this path
  79222. * @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
  79223. * @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
  79224. * @returns a sub path (slice) of this path
  79225. */
  79226. slice(start?: number, end?: number): Path3D;
  79227. /**
  79228. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79229. * @param path path which all values are copied into the curves points
  79230. * @param firstNormal which should be projected onto the curve
  79231. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79232. * @returns the same object updated.
  79233. */
  79234. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79235. private _compute;
  79236. private _getFirstNonNullVector;
  79237. private _getLastNonNullVector;
  79238. private _normalVector;
  79239. /**
  79240. * Updates the point at data for an interpolated point along this curve
  79241. * @param position the position of the point along this curve, from 0.0 to 1.0
  79242. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79243. * @returns the (updated) point at data
  79244. */
  79245. private _updatePointAtData;
  79246. /**
  79247. * Updates the point at data from the specified parameters
  79248. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79249. * @param point the interpolated point
  79250. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79251. */
  79252. private _setPointAtData;
  79253. /**
  79254. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79255. */
  79256. private _updateInterpolationMatrix;
  79257. }
  79258. /**
  79259. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79260. * A Curve3 is designed from a series of successive Vector3.
  79261. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79262. */
  79263. export class Curve3 {
  79264. private _points;
  79265. private _length;
  79266. /**
  79267. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79268. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79269. * @param v1 (Vector3) the control point
  79270. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79271. * @param nbPoints (integer) the wanted number of points in the curve
  79272. * @returns the created Curve3
  79273. */
  79274. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79275. /**
  79276. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79277. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79278. * @param v1 (Vector3) the first control point
  79279. * @param v2 (Vector3) the second control point
  79280. * @param v3 (Vector3) the end point of the Cubic Bezier
  79281. * @param nbPoints (integer) the wanted number of points in the curve
  79282. * @returns the created Curve3
  79283. */
  79284. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79285. /**
  79286. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79287. * @param p1 (Vector3) the origin point of the Hermite Spline
  79288. * @param t1 (Vector3) the tangent vector at the origin point
  79289. * @param p2 (Vector3) the end point of the Hermite Spline
  79290. * @param t2 (Vector3) the tangent vector at the end point
  79291. * @param nbPoints (integer) the wanted number of points in the curve
  79292. * @returns the created Curve3
  79293. */
  79294. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79295. /**
  79296. * Returns a Curve3 object along a CatmullRom Spline curve :
  79297. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79298. * @param nbPoints (integer) the wanted number of points between each curve control points
  79299. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79300. * @returns the created Curve3
  79301. */
  79302. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79303. /**
  79304. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79305. * A Curve3 is designed from a series of successive Vector3.
  79306. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79307. * @param points points which make up the curve
  79308. */
  79309. constructor(points: Vector3[]);
  79310. /**
  79311. * @returns the Curve3 stored array of successive Vector3
  79312. */
  79313. getPoints(): Vector3[];
  79314. /**
  79315. * @returns the computed length (float) of the curve.
  79316. */
  79317. length(): number;
  79318. /**
  79319. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79320. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79321. * curveA and curveB keep unchanged.
  79322. * @param curve the curve to continue from this curve
  79323. * @returns the newly constructed curve
  79324. */
  79325. continue(curve: DeepImmutable<Curve3>): Curve3;
  79326. private _computeLength;
  79327. }
  79328. }
  79329. declare module BABYLON {
  79330. /**
  79331. * This represents the main contract an easing function should follow.
  79332. * Easing functions are used throughout the animation system.
  79333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79334. */
  79335. export interface IEasingFunction {
  79336. /**
  79337. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79338. * of the easing function.
  79339. * The link below provides some of the most common examples of easing functions.
  79340. * @see https://easings.net/
  79341. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79342. * @returns the corresponding value on the curve defined by the easing function
  79343. */
  79344. ease(gradient: number): number;
  79345. }
  79346. /**
  79347. * Base class used for every default easing function.
  79348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79349. */
  79350. export class EasingFunction implements IEasingFunction {
  79351. /**
  79352. * Interpolation follows the mathematical formula associated with the easing function.
  79353. */
  79354. static readonly EASINGMODE_EASEIN: number;
  79355. /**
  79356. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79357. */
  79358. static readonly EASINGMODE_EASEOUT: number;
  79359. /**
  79360. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79361. */
  79362. static readonly EASINGMODE_EASEINOUT: number;
  79363. private _easingMode;
  79364. /**
  79365. * Sets the easing mode of the current function.
  79366. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79367. */
  79368. setEasingMode(easingMode: number): void;
  79369. /**
  79370. * Gets the current easing mode.
  79371. * @returns the easing mode
  79372. */
  79373. getEasingMode(): number;
  79374. /**
  79375. * @hidden
  79376. */
  79377. easeInCore(gradient: number): number;
  79378. /**
  79379. * Given an input gradient between 0 and 1, this returns the corresponding value
  79380. * of the easing function.
  79381. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79382. * @returns the corresponding value on the curve defined by the easing function
  79383. */
  79384. ease(gradient: number): number;
  79385. }
  79386. /**
  79387. * Easing function with a circle shape (see link below).
  79388. * @see https://easings.net/#easeInCirc
  79389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79390. */
  79391. export class CircleEase extends EasingFunction implements IEasingFunction {
  79392. /** @hidden */
  79393. easeInCore(gradient: number): number;
  79394. }
  79395. /**
  79396. * Easing function with a ease back shape (see link below).
  79397. * @see https://easings.net/#easeInBack
  79398. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79399. */
  79400. export class BackEase extends EasingFunction implements IEasingFunction {
  79401. /** Defines the amplitude of the function */
  79402. amplitude: number;
  79403. /**
  79404. * Instantiates a back ease easing
  79405. * @see https://easings.net/#easeInBack
  79406. * @param amplitude Defines the amplitude of the function
  79407. */
  79408. constructor(
  79409. /** Defines the amplitude of the function */
  79410. amplitude?: number);
  79411. /** @hidden */
  79412. easeInCore(gradient: number): number;
  79413. }
  79414. /**
  79415. * Easing function with a bouncing shape (see link below).
  79416. * @see https://easings.net/#easeInBounce
  79417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79418. */
  79419. export class BounceEase extends EasingFunction implements IEasingFunction {
  79420. /** Defines the number of bounces */
  79421. bounces: number;
  79422. /** Defines the amplitude of the bounce */
  79423. bounciness: number;
  79424. /**
  79425. * Instantiates a bounce easing
  79426. * @see https://easings.net/#easeInBounce
  79427. * @param bounces Defines the number of bounces
  79428. * @param bounciness Defines the amplitude of the bounce
  79429. */
  79430. constructor(
  79431. /** Defines the number of bounces */
  79432. bounces?: number,
  79433. /** Defines the amplitude of the bounce */
  79434. bounciness?: number);
  79435. /** @hidden */
  79436. easeInCore(gradient: number): number;
  79437. }
  79438. /**
  79439. * Easing function with a power of 3 shape (see link below).
  79440. * @see https://easings.net/#easeInCubic
  79441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79442. */
  79443. export class CubicEase extends EasingFunction implements IEasingFunction {
  79444. /** @hidden */
  79445. easeInCore(gradient: number): number;
  79446. }
  79447. /**
  79448. * Easing function with an elastic shape (see link below).
  79449. * @see https://easings.net/#easeInElastic
  79450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79451. */
  79452. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79453. /** Defines the number of oscillations*/
  79454. oscillations: number;
  79455. /** Defines the amplitude of the oscillations*/
  79456. springiness: number;
  79457. /**
  79458. * Instantiates an elastic easing function
  79459. * @see https://easings.net/#easeInElastic
  79460. * @param oscillations Defines the number of oscillations
  79461. * @param springiness Defines the amplitude of the oscillations
  79462. */
  79463. constructor(
  79464. /** Defines the number of oscillations*/
  79465. oscillations?: number,
  79466. /** Defines the amplitude of the oscillations*/
  79467. springiness?: number);
  79468. /** @hidden */
  79469. easeInCore(gradient: number): number;
  79470. }
  79471. /**
  79472. * Easing function with an exponential shape (see link below).
  79473. * @see https://easings.net/#easeInExpo
  79474. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79475. */
  79476. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79477. /** Defines the exponent of the function */
  79478. exponent: number;
  79479. /**
  79480. * Instantiates an exponential easing function
  79481. * @see https://easings.net/#easeInExpo
  79482. * @param exponent Defines the exponent of the function
  79483. */
  79484. constructor(
  79485. /** Defines the exponent of the function */
  79486. exponent?: number);
  79487. /** @hidden */
  79488. easeInCore(gradient: number): number;
  79489. }
  79490. /**
  79491. * Easing function with a power shape (see link below).
  79492. * @see https://easings.net/#easeInQuad
  79493. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79494. */
  79495. export class PowerEase extends EasingFunction implements IEasingFunction {
  79496. /** Defines the power of the function */
  79497. power: number;
  79498. /**
  79499. * Instantiates an power base easing function
  79500. * @see https://easings.net/#easeInQuad
  79501. * @param power Defines the power of the function
  79502. */
  79503. constructor(
  79504. /** Defines the power of the function */
  79505. power?: number);
  79506. /** @hidden */
  79507. easeInCore(gradient: number): number;
  79508. }
  79509. /**
  79510. * Easing function with a power of 2 shape (see link below).
  79511. * @see https://easings.net/#easeInQuad
  79512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79513. */
  79514. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79515. /** @hidden */
  79516. easeInCore(gradient: number): number;
  79517. }
  79518. /**
  79519. * Easing function with a power of 4 shape (see link below).
  79520. * @see https://easings.net/#easeInQuart
  79521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79522. */
  79523. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79524. /** @hidden */
  79525. easeInCore(gradient: number): number;
  79526. }
  79527. /**
  79528. * Easing function with a power of 5 shape (see link below).
  79529. * @see https://easings.net/#easeInQuint
  79530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79531. */
  79532. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79533. /** @hidden */
  79534. easeInCore(gradient: number): number;
  79535. }
  79536. /**
  79537. * Easing function with a sin shape (see link below).
  79538. * @see https://easings.net/#easeInSine
  79539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79540. */
  79541. export class SineEase extends EasingFunction implements IEasingFunction {
  79542. /** @hidden */
  79543. easeInCore(gradient: number): number;
  79544. }
  79545. /**
  79546. * Easing function with a bezier shape (see link below).
  79547. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79549. */
  79550. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79551. /** Defines the x component of the start tangent in the bezier curve */
  79552. x1: number;
  79553. /** Defines the y component of the start tangent in the bezier curve */
  79554. y1: number;
  79555. /** Defines the x component of the end tangent in the bezier curve */
  79556. x2: number;
  79557. /** Defines the y component of the end tangent in the bezier curve */
  79558. y2: number;
  79559. /**
  79560. * Instantiates a bezier function
  79561. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79562. * @param x1 Defines the x component of the start tangent in the bezier curve
  79563. * @param y1 Defines the y component of the start tangent in the bezier curve
  79564. * @param x2 Defines the x component of the end tangent in the bezier curve
  79565. * @param y2 Defines the y component of the end tangent in the bezier curve
  79566. */
  79567. constructor(
  79568. /** Defines the x component of the start tangent in the bezier curve */
  79569. x1?: number,
  79570. /** Defines the y component of the start tangent in the bezier curve */
  79571. y1?: number,
  79572. /** Defines the x component of the end tangent in the bezier curve */
  79573. x2?: number,
  79574. /** Defines the y component of the end tangent in the bezier curve */
  79575. y2?: number);
  79576. /** @hidden */
  79577. easeInCore(gradient: number): number;
  79578. }
  79579. }
  79580. declare module BABYLON {
  79581. /**
  79582. * Class used to hold a RBG color
  79583. */
  79584. export class Color3 {
  79585. /**
  79586. * Defines the red component (between 0 and 1, default is 0)
  79587. */
  79588. r: number;
  79589. /**
  79590. * Defines the green component (between 0 and 1, default is 0)
  79591. */
  79592. g: number;
  79593. /**
  79594. * Defines the blue component (between 0 and 1, default is 0)
  79595. */
  79596. b: number;
  79597. /**
  79598. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79599. * @param r defines the red component (between 0 and 1, default is 0)
  79600. * @param g defines the green component (between 0 and 1, default is 0)
  79601. * @param b defines the blue component (between 0 and 1, default is 0)
  79602. */
  79603. constructor(
  79604. /**
  79605. * Defines the red component (between 0 and 1, default is 0)
  79606. */
  79607. r?: number,
  79608. /**
  79609. * Defines the green component (between 0 and 1, default is 0)
  79610. */
  79611. g?: number,
  79612. /**
  79613. * Defines the blue component (between 0 and 1, default is 0)
  79614. */
  79615. b?: number);
  79616. /**
  79617. * Creates a string with the Color3 current values
  79618. * @returns the string representation of the Color3 object
  79619. */
  79620. toString(): string;
  79621. /**
  79622. * Returns the string "Color3"
  79623. * @returns "Color3"
  79624. */
  79625. getClassName(): string;
  79626. /**
  79627. * Compute the Color3 hash code
  79628. * @returns an unique number that can be used to hash Color3 objects
  79629. */
  79630. getHashCode(): number;
  79631. /**
  79632. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79633. * @param array defines the array where to store the r,g,b components
  79634. * @param index defines an optional index in the target array to define where to start storing values
  79635. * @returns the current Color3 object
  79636. */
  79637. toArray(array: FloatArray, index?: number): Color3;
  79638. /**
  79639. * Returns a new Color4 object from the current Color3 and the given alpha
  79640. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79641. * @returns a new Color4 object
  79642. */
  79643. toColor4(alpha?: number): Color4;
  79644. /**
  79645. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79646. * @returns the new array
  79647. */
  79648. asArray(): number[];
  79649. /**
  79650. * Returns the luminance value
  79651. * @returns a float value
  79652. */
  79653. toLuminance(): number;
  79654. /**
  79655. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79656. * @param otherColor defines the second operand
  79657. * @returns the new Color3 object
  79658. */
  79659. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79660. /**
  79661. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79662. * @param otherColor defines the second operand
  79663. * @param result defines the Color3 object where to store the result
  79664. * @returns the current Color3
  79665. */
  79666. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79667. /**
  79668. * Determines equality between Color3 objects
  79669. * @param otherColor defines the second operand
  79670. * @returns true if the rgb values are equal to the given ones
  79671. */
  79672. equals(otherColor: DeepImmutable<Color3>): boolean;
  79673. /**
  79674. * Determines equality between the current Color3 object and a set of r,b,g values
  79675. * @param r defines the red component to check
  79676. * @param g defines the green component to check
  79677. * @param b defines the blue component to check
  79678. * @returns true if the rgb values are equal to the given ones
  79679. */
  79680. equalsFloats(r: number, g: number, b: number): boolean;
  79681. /**
  79682. * Multiplies in place each rgb value by scale
  79683. * @param scale defines the scaling factor
  79684. * @returns the updated Color3
  79685. */
  79686. scale(scale: number): Color3;
  79687. /**
  79688. * Multiplies the rgb values by scale and stores the result into "result"
  79689. * @param scale defines the scaling factor
  79690. * @param result defines the Color3 object where to store the result
  79691. * @returns the unmodified current Color3
  79692. */
  79693. scaleToRef(scale: number, result: Color3): Color3;
  79694. /**
  79695. * Scale the current Color3 values by a factor and add the result to a given Color3
  79696. * @param scale defines the scale factor
  79697. * @param result defines color to store the result into
  79698. * @returns the unmodified current Color3
  79699. */
  79700. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79701. /**
  79702. * Clamps the rgb values by the min and max values and stores the result into "result"
  79703. * @param min defines minimum clamping value (default is 0)
  79704. * @param max defines maximum clamping value (default is 1)
  79705. * @param result defines color to store the result into
  79706. * @returns the original Color3
  79707. */
  79708. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79709. /**
  79710. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79711. * @param otherColor defines the second operand
  79712. * @returns the new Color3
  79713. */
  79714. add(otherColor: DeepImmutable<Color3>): Color3;
  79715. /**
  79716. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79717. * @param otherColor defines the second operand
  79718. * @param result defines Color3 object to store the result into
  79719. * @returns the unmodified current Color3
  79720. */
  79721. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79722. /**
  79723. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79724. * @param otherColor defines the second operand
  79725. * @returns the new Color3
  79726. */
  79727. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79728. /**
  79729. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79730. * @param otherColor defines the second operand
  79731. * @param result defines Color3 object to store the result into
  79732. * @returns the unmodified current Color3
  79733. */
  79734. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79735. /**
  79736. * Copy the current object
  79737. * @returns a new Color3 copied the current one
  79738. */
  79739. clone(): Color3;
  79740. /**
  79741. * Copies the rgb values from the source in the current Color3
  79742. * @param source defines the source Color3 object
  79743. * @returns the updated Color3 object
  79744. */
  79745. copyFrom(source: DeepImmutable<Color3>): Color3;
  79746. /**
  79747. * Updates the Color3 rgb values from the given floats
  79748. * @param r defines the red component to read from
  79749. * @param g defines the green component to read from
  79750. * @param b defines the blue component to read from
  79751. * @returns the current Color3 object
  79752. */
  79753. copyFromFloats(r: number, g: number, b: number): Color3;
  79754. /**
  79755. * Updates the Color3 rgb values from the given floats
  79756. * @param r defines the red component to read from
  79757. * @param g defines the green component to read from
  79758. * @param b defines the blue component to read from
  79759. * @returns the current Color3 object
  79760. */
  79761. set(r: number, g: number, b: number): Color3;
  79762. /**
  79763. * Compute the Color3 hexadecimal code as a string
  79764. * @returns a string containing the hexadecimal representation of the Color3 object
  79765. */
  79766. toHexString(): string;
  79767. /**
  79768. * Computes a new Color3 converted from the current one to linear space
  79769. * @returns a new Color3 object
  79770. */
  79771. toLinearSpace(): Color3;
  79772. /**
  79773. * Converts current color in rgb space to HSV values
  79774. * @returns a new color3 representing the HSV values
  79775. */
  79776. toHSV(): Color3;
  79777. /**
  79778. * Converts current color in rgb space to HSV values
  79779. * @param result defines the Color3 where to store the HSV values
  79780. */
  79781. toHSVToRef(result: Color3): void;
  79782. /**
  79783. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79784. * @param convertedColor defines the Color3 object where to store the linear space version
  79785. * @returns the unmodified Color3
  79786. */
  79787. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79788. /**
  79789. * Computes a new Color3 converted from the current one to gamma space
  79790. * @returns a new Color3 object
  79791. */
  79792. toGammaSpace(): Color3;
  79793. /**
  79794. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79795. * @param convertedColor defines the Color3 object where to store the gamma space version
  79796. * @returns the unmodified Color3
  79797. */
  79798. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79799. private static _BlackReadOnly;
  79800. /**
  79801. * Convert Hue, saturation and value to a Color3 (RGB)
  79802. * @param hue defines the hue
  79803. * @param saturation defines the saturation
  79804. * @param value defines the value
  79805. * @param result defines the Color3 where to store the RGB values
  79806. */
  79807. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79808. /**
  79809. * Creates a new Color3 from the string containing valid hexadecimal values
  79810. * @param hex defines a string containing valid hexadecimal values
  79811. * @returns a new Color3 object
  79812. */
  79813. static FromHexString(hex: string): Color3;
  79814. /**
  79815. * Creates a new Color3 from the starting index of the given array
  79816. * @param array defines the source array
  79817. * @param offset defines an offset in the source array
  79818. * @returns a new Color3 object
  79819. */
  79820. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79821. /**
  79822. * Creates a new Color3 from integer values (< 256)
  79823. * @param r defines the red component to read from (value between 0 and 255)
  79824. * @param g defines the green component to read from (value between 0 and 255)
  79825. * @param b defines the blue component to read from (value between 0 and 255)
  79826. * @returns a new Color3 object
  79827. */
  79828. static FromInts(r: number, g: number, b: number): Color3;
  79829. /**
  79830. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79831. * @param start defines the start Color3 value
  79832. * @param end defines the end Color3 value
  79833. * @param amount defines the gradient value between start and end
  79834. * @returns a new Color3 object
  79835. */
  79836. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79837. /**
  79838. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79839. * @param left defines the start value
  79840. * @param right defines the end value
  79841. * @param amount defines the gradient factor
  79842. * @param result defines the Color3 object where to store the result
  79843. */
  79844. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79845. /**
  79846. * Returns a Color3 value containing a red color
  79847. * @returns a new Color3 object
  79848. */
  79849. static Red(): Color3;
  79850. /**
  79851. * Returns a Color3 value containing a green color
  79852. * @returns a new Color3 object
  79853. */
  79854. static Green(): Color3;
  79855. /**
  79856. * Returns a Color3 value containing a blue color
  79857. * @returns a new Color3 object
  79858. */
  79859. static Blue(): Color3;
  79860. /**
  79861. * Returns a Color3 value containing a black color
  79862. * @returns a new Color3 object
  79863. */
  79864. static Black(): Color3;
  79865. /**
  79866. * Gets a Color3 value containing a black color that must not be updated
  79867. */
  79868. static get BlackReadOnly(): DeepImmutable<Color3>;
  79869. /**
  79870. * Returns a Color3 value containing a white color
  79871. * @returns a new Color3 object
  79872. */
  79873. static White(): Color3;
  79874. /**
  79875. * Returns a Color3 value containing a purple color
  79876. * @returns a new Color3 object
  79877. */
  79878. static Purple(): Color3;
  79879. /**
  79880. * Returns a Color3 value containing a magenta color
  79881. * @returns a new Color3 object
  79882. */
  79883. static Magenta(): Color3;
  79884. /**
  79885. * Returns a Color3 value containing a yellow color
  79886. * @returns a new Color3 object
  79887. */
  79888. static Yellow(): Color3;
  79889. /**
  79890. * Returns a Color3 value containing a gray color
  79891. * @returns a new Color3 object
  79892. */
  79893. static Gray(): Color3;
  79894. /**
  79895. * Returns a Color3 value containing a teal color
  79896. * @returns a new Color3 object
  79897. */
  79898. static Teal(): Color3;
  79899. /**
  79900. * Returns a Color3 value containing a random color
  79901. * @returns a new Color3 object
  79902. */
  79903. static Random(): Color3;
  79904. }
  79905. /**
  79906. * Class used to hold a RBGA color
  79907. */
  79908. export class Color4 {
  79909. /**
  79910. * Defines the red component (between 0 and 1, default is 0)
  79911. */
  79912. r: number;
  79913. /**
  79914. * Defines the green component (between 0 and 1, default is 0)
  79915. */
  79916. g: number;
  79917. /**
  79918. * Defines the blue component (between 0 and 1, default is 0)
  79919. */
  79920. b: number;
  79921. /**
  79922. * Defines the alpha component (between 0 and 1, default is 1)
  79923. */
  79924. a: number;
  79925. /**
  79926. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79927. * @param r defines the red component (between 0 and 1, default is 0)
  79928. * @param g defines the green component (between 0 and 1, default is 0)
  79929. * @param b defines the blue component (between 0 and 1, default is 0)
  79930. * @param a defines the alpha component (between 0 and 1, default is 1)
  79931. */
  79932. constructor(
  79933. /**
  79934. * Defines the red component (between 0 and 1, default is 0)
  79935. */
  79936. r?: number,
  79937. /**
  79938. * Defines the green component (between 0 and 1, default is 0)
  79939. */
  79940. g?: number,
  79941. /**
  79942. * Defines the blue component (between 0 and 1, default is 0)
  79943. */
  79944. b?: number,
  79945. /**
  79946. * Defines the alpha component (between 0 and 1, default is 1)
  79947. */
  79948. a?: number);
  79949. /**
  79950. * Adds in place the given Color4 values to the current Color4 object
  79951. * @param right defines the second operand
  79952. * @returns the current updated Color4 object
  79953. */
  79954. addInPlace(right: DeepImmutable<Color4>): Color4;
  79955. /**
  79956. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79957. * @returns the new array
  79958. */
  79959. asArray(): number[];
  79960. /**
  79961. * Stores from the starting index in the given array the Color4 successive values
  79962. * @param array defines the array where to store the r,g,b components
  79963. * @param index defines an optional index in the target array to define where to start storing values
  79964. * @returns the current Color4 object
  79965. */
  79966. toArray(array: number[], index?: number): Color4;
  79967. /**
  79968. * Determines equality between Color4 objects
  79969. * @param otherColor defines the second operand
  79970. * @returns true if the rgba values are equal to the given ones
  79971. */
  79972. equals(otherColor: DeepImmutable<Color4>): boolean;
  79973. /**
  79974. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79975. * @param right defines the second operand
  79976. * @returns a new Color4 object
  79977. */
  79978. add(right: DeepImmutable<Color4>): Color4;
  79979. /**
  79980. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79981. * @param right defines the second operand
  79982. * @returns a new Color4 object
  79983. */
  79984. subtract(right: DeepImmutable<Color4>): Color4;
  79985. /**
  79986. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79987. * @param right defines the second operand
  79988. * @param result defines the Color4 object where to store the result
  79989. * @returns the current Color4 object
  79990. */
  79991. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79992. /**
  79993. * Creates a new Color4 with the current Color4 values multiplied by scale
  79994. * @param scale defines the scaling factor to apply
  79995. * @returns a new Color4 object
  79996. */
  79997. scale(scale: number): Color4;
  79998. /**
  79999. * Multiplies the current Color4 values by scale and stores the result in "result"
  80000. * @param scale defines the scaling factor to apply
  80001. * @param result defines the Color4 object where to store the result
  80002. * @returns the current unmodified Color4
  80003. */
  80004. scaleToRef(scale: number, result: Color4): Color4;
  80005. /**
  80006. * Scale the current Color4 values by a factor and add the result to a given Color4
  80007. * @param scale defines the scale factor
  80008. * @param result defines the Color4 object where to store the result
  80009. * @returns the unmodified current Color4
  80010. */
  80011. scaleAndAddToRef(scale: number, result: Color4): Color4;
  80012. /**
  80013. * Clamps the rgb values by the min and max values and stores the result into "result"
  80014. * @param min defines minimum clamping value (default is 0)
  80015. * @param max defines maximum clamping value (default is 1)
  80016. * @param result defines color to store the result into.
  80017. * @returns the cuurent Color4
  80018. */
  80019. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  80020. /**
  80021. * Multipy an Color4 value by another and return a new Color4 object
  80022. * @param color defines the Color4 value to multiply by
  80023. * @returns a new Color4 object
  80024. */
  80025. multiply(color: Color4): Color4;
  80026. /**
  80027. * Multipy a Color4 value by another and push the result in a reference value
  80028. * @param color defines the Color4 value to multiply by
  80029. * @param result defines the Color4 to fill the result in
  80030. * @returns the result Color4
  80031. */
  80032. multiplyToRef(color: Color4, result: Color4): Color4;
  80033. /**
  80034. * Creates a string with the Color4 current values
  80035. * @returns the string representation of the Color4 object
  80036. */
  80037. toString(): string;
  80038. /**
  80039. * Returns the string "Color4"
  80040. * @returns "Color4"
  80041. */
  80042. getClassName(): string;
  80043. /**
  80044. * Compute the Color4 hash code
  80045. * @returns an unique number that can be used to hash Color4 objects
  80046. */
  80047. getHashCode(): number;
  80048. /**
  80049. * Creates a new Color4 copied from the current one
  80050. * @returns a new Color4 object
  80051. */
  80052. clone(): Color4;
  80053. /**
  80054. * Copies the given Color4 values into the current one
  80055. * @param source defines the source Color4 object
  80056. * @returns the current updated Color4 object
  80057. */
  80058. copyFrom(source: Color4): Color4;
  80059. /**
  80060. * Copies the given float values into the current one
  80061. * @param r defines the red component to read from
  80062. * @param g defines the green component to read from
  80063. * @param b defines the blue component to read from
  80064. * @param a defines the alpha component to read from
  80065. * @returns the current updated Color4 object
  80066. */
  80067. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80068. /**
  80069. * Copies the given float values into the current one
  80070. * @param r defines the red component to read from
  80071. * @param g defines the green component to read from
  80072. * @param b defines the blue component to read from
  80073. * @param a defines the alpha component to read from
  80074. * @returns the current updated Color4 object
  80075. */
  80076. set(r: number, g: number, b: number, a: number): Color4;
  80077. /**
  80078. * Compute the Color4 hexadecimal code as a string
  80079. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80080. * @returns a string containing the hexadecimal representation of the Color4 object
  80081. */
  80082. toHexString(returnAsColor3?: boolean): string;
  80083. /**
  80084. * Computes a new Color4 converted from the current one to linear space
  80085. * @returns a new Color4 object
  80086. */
  80087. toLinearSpace(): Color4;
  80088. /**
  80089. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80090. * @param convertedColor defines the Color4 object where to store the linear space version
  80091. * @returns the unmodified Color4
  80092. */
  80093. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80094. /**
  80095. * Computes a new Color4 converted from the current one to gamma space
  80096. * @returns a new Color4 object
  80097. */
  80098. toGammaSpace(): Color4;
  80099. /**
  80100. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80101. * @param convertedColor defines the Color4 object where to store the gamma space version
  80102. * @returns the unmodified Color4
  80103. */
  80104. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80105. /**
  80106. * Creates a new Color4 from the string containing valid hexadecimal values
  80107. * @param hex defines a string containing valid hexadecimal values
  80108. * @returns a new Color4 object
  80109. */
  80110. static FromHexString(hex: string): Color4;
  80111. /**
  80112. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80113. * @param left defines the start value
  80114. * @param right defines the end value
  80115. * @param amount defines the gradient factor
  80116. * @returns a new Color4 object
  80117. */
  80118. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80119. /**
  80120. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80121. * @param left defines the start value
  80122. * @param right defines the end value
  80123. * @param amount defines the gradient factor
  80124. * @param result defines the Color4 object where to store data
  80125. */
  80126. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80127. /**
  80128. * Creates a new Color4 from a Color3 and an alpha value
  80129. * @param color3 defines the source Color3 to read from
  80130. * @param alpha defines the alpha component (1.0 by default)
  80131. * @returns a new Color4 object
  80132. */
  80133. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80134. /**
  80135. * Creates a new Color4 from the starting index element of the given array
  80136. * @param array defines the source array to read from
  80137. * @param offset defines the offset in the source array
  80138. * @returns a new Color4 object
  80139. */
  80140. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80141. /**
  80142. * Creates a new Color3 from integer values (< 256)
  80143. * @param r defines the red component to read from (value between 0 and 255)
  80144. * @param g defines the green component to read from (value between 0 and 255)
  80145. * @param b defines the blue component to read from (value between 0 and 255)
  80146. * @param a defines the alpha component to read from (value between 0 and 255)
  80147. * @returns a new Color3 object
  80148. */
  80149. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80150. /**
  80151. * Check the content of a given array and convert it to an array containing RGBA data
  80152. * If the original array was already containing count * 4 values then it is returned directly
  80153. * @param colors defines the array to check
  80154. * @param count defines the number of RGBA data to expect
  80155. * @returns an array containing count * 4 values (RGBA)
  80156. */
  80157. static CheckColors4(colors: number[], count: number): number[];
  80158. }
  80159. /**
  80160. * @hidden
  80161. */
  80162. export class TmpColors {
  80163. static Color3: Color3[];
  80164. static Color4: Color4[];
  80165. }
  80166. }
  80167. declare module BABYLON {
  80168. /**
  80169. * Defines an interface which represents an animation key frame
  80170. */
  80171. export interface IAnimationKey {
  80172. /**
  80173. * Frame of the key frame
  80174. */
  80175. frame: number;
  80176. /**
  80177. * Value at the specifies key frame
  80178. */
  80179. value: any;
  80180. /**
  80181. * The input tangent for the cubic hermite spline
  80182. */
  80183. inTangent?: any;
  80184. /**
  80185. * The output tangent for the cubic hermite spline
  80186. */
  80187. outTangent?: any;
  80188. /**
  80189. * The animation interpolation type
  80190. */
  80191. interpolation?: AnimationKeyInterpolation;
  80192. }
  80193. /**
  80194. * Enum for the animation key frame interpolation type
  80195. */
  80196. export enum AnimationKeyInterpolation {
  80197. /**
  80198. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80199. */
  80200. STEP = 1
  80201. }
  80202. }
  80203. declare module BABYLON {
  80204. /**
  80205. * Represents the range of an animation
  80206. */
  80207. export class AnimationRange {
  80208. /**The name of the animation range**/
  80209. name: string;
  80210. /**The starting frame of the animation */
  80211. from: number;
  80212. /**The ending frame of the animation*/
  80213. to: number;
  80214. /**
  80215. * Initializes the range of an animation
  80216. * @param name The name of the animation range
  80217. * @param from The starting frame of the animation
  80218. * @param to The ending frame of the animation
  80219. */
  80220. constructor(
  80221. /**The name of the animation range**/
  80222. name: string,
  80223. /**The starting frame of the animation */
  80224. from: number,
  80225. /**The ending frame of the animation*/
  80226. to: number);
  80227. /**
  80228. * Makes a copy of the animation range
  80229. * @returns A copy of the animation range
  80230. */
  80231. clone(): AnimationRange;
  80232. }
  80233. }
  80234. declare module BABYLON {
  80235. /**
  80236. * Composed of a frame, and an action function
  80237. */
  80238. export class AnimationEvent {
  80239. /** The frame for which the event is triggered **/
  80240. frame: number;
  80241. /** The event to perform when triggered **/
  80242. action: (currentFrame: number) => void;
  80243. /** Specifies if the event should be triggered only once**/
  80244. onlyOnce?: boolean | undefined;
  80245. /**
  80246. * Specifies if the animation event is done
  80247. */
  80248. isDone: boolean;
  80249. /**
  80250. * Initializes the animation event
  80251. * @param frame The frame for which the event is triggered
  80252. * @param action The event to perform when triggered
  80253. * @param onlyOnce Specifies if the event should be triggered only once
  80254. */
  80255. constructor(
  80256. /** The frame for which the event is triggered **/
  80257. frame: number,
  80258. /** The event to perform when triggered **/
  80259. action: (currentFrame: number) => void,
  80260. /** Specifies if the event should be triggered only once**/
  80261. onlyOnce?: boolean | undefined);
  80262. /** @hidden */
  80263. _clone(): AnimationEvent;
  80264. }
  80265. }
  80266. declare module BABYLON {
  80267. /**
  80268. * Interface used to define a behavior
  80269. */
  80270. export interface Behavior<T> {
  80271. /** gets or sets behavior's name */
  80272. name: string;
  80273. /**
  80274. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80275. */
  80276. init(): void;
  80277. /**
  80278. * Called when the behavior is attached to a target
  80279. * @param target defines the target where the behavior is attached to
  80280. */
  80281. attach(target: T): void;
  80282. /**
  80283. * Called when the behavior is detached from its target
  80284. */
  80285. detach(): void;
  80286. }
  80287. /**
  80288. * Interface implemented by classes supporting behaviors
  80289. */
  80290. export interface IBehaviorAware<T> {
  80291. /**
  80292. * Attach a behavior
  80293. * @param behavior defines the behavior to attach
  80294. * @returns the current host
  80295. */
  80296. addBehavior(behavior: Behavior<T>): T;
  80297. /**
  80298. * Remove a behavior from the current object
  80299. * @param behavior defines the behavior to detach
  80300. * @returns the current host
  80301. */
  80302. removeBehavior(behavior: Behavior<T>): T;
  80303. /**
  80304. * Gets a behavior using its name to search
  80305. * @param name defines the name to search
  80306. * @returns the behavior or null if not found
  80307. */
  80308. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80309. }
  80310. }
  80311. declare module BABYLON {
  80312. /**
  80313. * Defines an array and its length.
  80314. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80315. */
  80316. export interface ISmartArrayLike<T> {
  80317. /**
  80318. * The data of the array.
  80319. */
  80320. data: Array<T>;
  80321. /**
  80322. * The active length of the array.
  80323. */
  80324. length: number;
  80325. }
  80326. /**
  80327. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80328. */
  80329. export class SmartArray<T> implements ISmartArrayLike<T> {
  80330. /**
  80331. * The full set of data from the array.
  80332. */
  80333. data: Array<T>;
  80334. /**
  80335. * The active length of the array.
  80336. */
  80337. length: number;
  80338. protected _id: number;
  80339. /**
  80340. * Instantiates a Smart Array.
  80341. * @param capacity defines the default capacity of the array.
  80342. */
  80343. constructor(capacity: number);
  80344. /**
  80345. * Pushes a value at the end of the active data.
  80346. * @param value defines the object to push in the array.
  80347. */
  80348. push(value: T): void;
  80349. /**
  80350. * Iterates over the active data and apply the lambda to them.
  80351. * @param func defines the action to apply on each value.
  80352. */
  80353. forEach(func: (content: T) => void): void;
  80354. /**
  80355. * Sorts the full sets of data.
  80356. * @param compareFn defines the comparison function to apply.
  80357. */
  80358. sort(compareFn: (a: T, b: T) => number): void;
  80359. /**
  80360. * Resets the active data to an empty array.
  80361. */
  80362. reset(): void;
  80363. /**
  80364. * Releases all the data from the array as well as the array.
  80365. */
  80366. dispose(): void;
  80367. /**
  80368. * Concats the active data with a given array.
  80369. * @param array defines the data to concatenate with.
  80370. */
  80371. concat(array: any): void;
  80372. /**
  80373. * Returns the position of a value in the active data.
  80374. * @param value defines the value to find the index for
  80375. * @returns the index if found in the active data otherwise -1
  80376. */
  80377. indexOf(value: T): number;
  80378. /**
  80379. * Returns whether an element is part of the active data.
  80380. * @param value defines the value to look for
  80381. * @returns true if found in the active data otherwise false
  80382. */
  80383. contains(value: T): boolean;
  80384. private static _GlobalId;
  80385. }
  80386. /**
  80387. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80388. * The data in this array can only be present once
  80389. */
  80390. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80391. private _duplicateId;
  80392. /**
  80393. * Pushes a value at the end of the active data.
  80394. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80395. * @param value defines the object to push in the array.
  80396. */
  80397. push(value: T): void;
  80398. /**
  80399. * Pushes a value at the end of the active data.
  80400. * If the data is already present, it won t be added again
  80401. * @param value defines the object to push in the array.
  80402. * @returns true if added false if it was already present
  80403. */
  80404. pushNoDuplicate(value: T): boolean;
  80405. /**
  80406. * Resets the active data to an empty array.
  80407. */
  80408. reset(): void;
  80409. /**
  80410. * Concats the active data with a given array.
  80411. * This ensures no dupplicate will be present in the result.
  80412. * @param array defines the data to concatenate with.
  80413. */
  80414. concatWithNoDuplicate(array: any): void;
  80415. }
  80416. }
  80417. declare module BABYLON {
  80418. /**
  80419. * @ignore
  80420. * This is a list of all the different input types that are available in the application.
  80421. * Fo instance: ArcRotateCameraGamepadInput...
  80422. */
  80423. export var CameraInputTypes: {};
  80424. /**
  80425. * This is the contract to implement in order to create a new input class.
  80426. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80427. */
  80428. export interface ICameraInput<TCamera extends Camera> {
  80429. /**
  80430. * Defines the camera the input is attached to.
  80431. */
  80432. camera: Nullable<TCamera>;
  80433. /**
  80434. * Gets the class name of the current intput.
  80435. * @returns the class name
  80436. */
  80437. getClassName(): string;
  80438. /**
  80439. * Get the friendly name associated with the input class.
  80440. * @returns the input friendly name
  80441. */
  80442. getSimpleName(): string;
  80443. /**
  80444. * Attach the input controls to a specific dom element to get the input from.
  80445. * @param element Defines the element the controls should be listened from
  80446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80447. */
  80448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80449. /**
  80450. * Detach the current controls from the specified dom element.
  80451. * @param element Defines the element to stop listening the inputs from
  80452. */
  80453. detachControl(element: Nullable<HTMLElement>): void;
  80454. /**
  80455. * Update the current camera state depending on the inputs that have been used this frame.
  80456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80457. */
  80458. checkInputs?: () => void;
  80459. }
  80460. /**
  80461. * Represents a map of input types to input instance or input index to input instance.
  80462. */
  80463. export interface CameraInputsMap<TCamera extends Camera> {
  80464. /**
  80465. * Accessor to the input by input type.
  80466. */
  80467. [name: string]: ICameraInput<TCamera>;
  80468. /**
  80469. * Accessor to the input by input index.
  80470. */
  80471. [idx: number]: ICameraInput<TCamera>;
  80472. }
  80473. /**
  80474. * This represents the input manager used within a camera.
  80475. * It helps dealing with all the different kind of input attached to a camera.
  80476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80477. */
  80478. export class CameraInputsManager<TCamera extends Camera> {
  80479. /**
  80480. * Defines the list of inputs attahed to the camera.
  80481. */
  80482. attached: CameraInputsMap<TCamera>;
  80483. /**
  80484. * Defines the dom element the camera is collecting inputs from.
  80485. * This is null if the controls have not been attached.
  80486. */
  80487. attachedElement: Nullable<HTMLElement>;
  80488. /**
  80489. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80490. */
  80491. noPreventDefault: boolean;
  80492. /**
  80493. * Defined the camera the input manager belongs to.
  80494. */
  80495. camera: TCamera;
  80496. /**
  80497. * Update the current camera state depending on the inputs that have been used this frame.
  80498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80499. */
  80500. checkInputs: () => void;
  80501. /**
  80502. * Instantiate a new Camera Input Manager.
  80503. * @param camera Defines the camera the input manager blongs to
  80504. */
  80505. constructor(camera: TCamera);
  80506. /**
  80507. * Add an input method to a camera
  80508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80509. * @param input camera input method
  80510. */
  80511. add(input: ICameraInput<TCamera>): void;
  80512. /**
  80513. * Remove a specific input method from a camera
  80514. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80515. * @param inputToRemove camera input method
  80516. */
  80517. remove(inputToRemove: ICameraInput<TCamera>): void;
  80518. /**
  80519. * Remove a specific input type from a camera
  80520. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80521. * @param inputType the type of the input to remove
  80522. */
  80523. removeByType(inputType: string): void;
  80524. private _addCheckInputs;
  80525. /**
  80526. * Attach the input controls to the currently attached dom element to listen the events from.
  80527. * @param input Defines the input to attach
  80528. */
  80529. attachInput(input: ICameraInput<TCamera>): void;
  80530. /**
  80531. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80532. * @param element Defines the dom element to collect the events from
  80533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80534. */
  80535. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80536. /**
  80537. * Detach the current manager inputs controls from a specific dom element.
  80538. * @param element Defines the dom element to collect the events from
  80539. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80540. */
  80541. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80542. /**
  80543. * Rebuild the dynamic inputCheck function from the current list of
  80544. * defined inputs in the manager.
  80545. */
  80546. rebuildInputCheck(): void;
  80547. /**
  80548. * Remove all attached input methods from a camera
  80549. */
  80550. clear(): void;
  80551. /**
  80552. * Serialize the current input manager attached to a camera.
  80553. * This ensures than once parsed,
  80554. * the input associated to the camera will be identical to the current ones
  80555. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80556. */
  80557. serialize(serializedCamera: any): void;
  80558. /**
  80559. * Parses an input manager serialized JSON to restore the previous list of inputs
  80560. * and states associated to a camera.
  80561. * @param parsedCamera Defines the JSON to parse
  80562. */
  80563. parse(parsedCamera: any): void;
  80564. }
  80565. }
  80566. declare module BABYLON {
  80567. /**
  80568. * Class used to store data that will be store in GPU memory
  80569. */
  80570. export class Buffer {
  80571. private _engine;
  80572. private _buffer;
  80573. /** @hidden */
  80574. _data: Nullable<DataArray>;
  80575. private _updatable;
  80576. private _instanced;
  80577. private _divisor;
  80578. /**
  80579. * Gets the byte stride.
  80580. */
  80581. readonly byteStride: number;
  80582. /**
  80583. * Constructor
  80584. * @param engine the engine
  80585. * @param data the data to use for this buffer
  80586. * @param updatable whether the data is updatable
  80587. * @param stride the stride (optional)
  80588. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80589. * @param instanced whether the buffer is instanced (optional)
  80590. * @param useBytes set to true if the stride in in bytes (optional)
  80591. * @param divisor sets an optional divisor for instances (1 by default)
  80592. */
  80593. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80594. /**
  80595. * Create a new VertexBuffer based on the current buffer
  80596. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80597. * @param offset defines offset in the buffer (0 by default)
  80598. * @param size defines the size in floats of attributes (position is 3 for instance)
  80599. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80600. * @param instanced defines if the vertex buffer contains indexed data
  80601. * @param useBytes defines if the offset and stride are in bytes *
  80602. * @param divisor sets an optional divisor for instances (1 by default)
  80603. * @returns the new vertex buffer
  80604. */
  80605. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80606. /**
  80607. * Gets a boolean indicating if the Buffer is updatable?
  80608. * @returns true if the buffer is updatable
  80609. */
  80610. isUpdatable(): boolean;
  80611. /**
  80612. * Gets current buffer's data
  80613. * @returns a DataArray or null
  80614. */
  80615. getData(): Nullable<DataArray>;
  80616. /**
  80617. * Gets underlying native buffer
  80618. * @returns underlying native buffer
  80619. */
  80620. getBuffer(): Nullable<DataBuffer>;
  80621. /**
  80622. * Gets the stride in float32 units (i.e. byte stride / 4).
  80623. * May not be an integer if the byte stride is not divisible by 4.
  80624. * @returns the stride in float32 units
  80625. * @deprecated Please use byteStride instead.
  80626. */
  80627. getStrideSize(): number;
  80628. /**
  80629. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80630. * @param data defines the data to store
  80631. */
  80632. create(data?: Nullable<DataArray>): void;
  80633. /** @hidden */
  80634. _rebuild(): void;
  80635. /**
  80636. * Update current buffer data
  80637. * @param data defines the data to store
  80638. */
  80639. update(data: DataArray): void;
  80640. /**
  80641. * Updates the data directly.
  80642. * @param data the new data
  80643. * @param offset the new offset
  80644. * @param vertexCount the vertex count (optional)
  80645. * @param useBytes set to true if the offset is in bytes
  80646. */
  80647. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80648. /**
  80649. * Release all resources
  80650. */
  80651. dispose(): void;
  80652. }
  80653. /**
  80654. * Specialized buffer used to store vertex data
  80655. */
  80656. export class VertexBuffer {
  80657. /** @hidden */
  80658. _buffer: Buffer;
  80659. private _kind;
  80660. private _size;
  80661. private _ownsBuffer;
  80662. private _instanced;
  80663. private _instanceDivisor;
  80664. /**
  80665. * The byte type.
  80666. */
  80667. static readonly BYTE: number;
  80668. /**
  80669. * The unsigned byte type.
  80670. */
  80671. static readonly UNSIGNED_BYTE: number;
  80672. /**
  80673. * The short type.
  80674. */
  80675. static readonly SHORT: number;
  80676. /**
  80677. * The unsigned short type.
  80678. */
  80679. static readonly UNSIGNED_SHORT: number;
  80680. /**
  80681. * The integer type.
  80682. */
  80683. static readonly INT: number;
  80684. /**
  80685. * The unsigned integer type.
  80686. */
  80687. static readonly UNSIGNED_INT: number;
  80688. /**
  80689. * The float type.
  80690. */
  80691. static readonly FLOAT: number;
  80692. /**
  80693. * Gets or sets the instance divisor when in instanced mode
  80694. */
  80695. get instanceDivisor(): number;
  80696. set instanceDivisor(value: number);
  80697. /**
  80698. * Gets the byte stride.
  80699. */
  80700. readonly byteStride: number;
  80701. /**
  80702. * Gets the byte offset.
  80703. */
  80704. readonly byteOffset: number;
  80705. /**
  80706. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80707. */
  80708. readonly normalized: boolean;
  80709. /**
  80710. * Gets the data type of each component in the array.
  80711. */
  80712. readonly type: number;
  80713. /**
  80714. * Constructor
  80715. * @param engine the engine
  80716. * @param data the data to use for this vertex buffer
  80717. * @param kind the vertex buffer kind
  80718. * @param updatable whether the data is updatable
  80719. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80720. * @param stride the stride (optional)
  80721. * @param instanced whether the buffer is instanced (optional)
  80722. * @param offset the offset of the data (optional)
  80723. * @param size the number of components (optional)
  80724. * @param type the type of the component (optional)
  80725. * @param normalized whether the data contains normalized data (optional)
  80726. * @param useBytes set to true if stride and offset are in bytes (optional)
  80727. * @param divisor defines the instance divisor to use (1 by default)
  80728. */
  80729. 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);
  80730. /** @hidden */
  80731. _rebuild(): void;
  80732. /**
  80733. * Returns the kind of the VertexBuffer (string)
  80734. * @returns a string
  80735. */
  80736. getKind(): string;
  80737. /**
  80738. * Gets a boolean indicating if the VertexBuffer is updatable?
  80739. * @returns true if the buffer is updatable
  80740. */
  80741. isUpdatable(): boolean;
  80742. /**
  80743. * Gets current buffer's data
  80744. * @returns a DataArray or null
  80745. */
  80746. getData(): Nullable<DataArray>;
  80747. /**
  80748. * Gets underlying native buffer
  80749. * @returns underlying native buffer
  80750. */
  80751. getBuffer(): Nullable<DataBuffer>;
  80752. /**
  80753. * Gets the stride in float32 units (i.e. byte stride / 4).
  80754. * May not be an integer if the byte stride is not divisible by 4.
  80755. * @returns the stride in float32 units
  80756. * @deprecated Please use byteStride instead.
  80757. */
  80758. getStrideSize(): number;
  80759. /**
  80760. * Returns the offset as a multiple of the type byte length.
  80761. * @returns the offset in bytes
  80762. * @deprecated Please use byteOffset instead.
  80763. */
  80764. getOffset(): number;
  80765. /**
  80766. * Returns the number of components per vertex attribute (integer)
  80767. * @returns the size in float
  80768. */
  80769. getSize(): number;
  80770. /**
  80771. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80772. * @returns true if this buffer is instanced
  80773. */
  80774. getIsInstanced(): boolean;
  80775. /**
  80776. * Returns the instancing divisor, zero for non-instanced (integer).
  80777. * @returns a number
  80778. */
  80779. getInstanceDivisor(): number;
  80780. /**
  80781. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80782. * @param data defines the data to store
  80783. */
  80784. create(data?: DataArray): void;
  80785. /**
  80786. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80787. * This function will create a new buffer if the current one is not updatable
  80788. * @param data defines the data to store
  80789. */
  80790. update(data: DataArray): void;
  80791. /**
  80792. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80793. * Returns the directly updated WebGLBuffer.
  80794. * @param data the new data
  80795. * @param offset the new offset
  80796. * @param useBytes set to true if the offset is in bytes
  80797. */
  80798. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80799. /**
  80800. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80801. */
  80802. dispose(): void;
  80803. /**
  80804. * Enumerates each value of this vertex buffer as numbers.
  80805. * @param count the number of values to enumerate
  80806. * @param callback the callback function called for each value
  80807. */
  80808. forEach(count: number, callback: (value: number, index: number) => void): void;
  80809. /**
  80810. * Positions
  80811. */
  80812. static readonly PositionKind: string;
  80813. /**
  80814. * Normals
  80815. */
  80816. static readonly NormalKind: string;
  80817. /**
  80818. * Tangents
  80819. */
  80820. static readonly TangentKind: string;
  80821. /**
  80822. * Texture coordinates
  80823. */
  80824. static readonly UVKind: string;
  80825. /**
  80826. * Texture coordinates 2
  80827. */
  80828. static readonly UV2Kind: string;
  80829. /**
  80830. * Texture coordinates 3
  80831. */
  80832. static readonly UV3Kind: string;
  80833. /**
  80834. * Texture coordinates 4
  80835. */
  80836. static readonly UV4Kind: string;
  80837. /**
  80838. * Texture coordinates 5
  80839. */
  80840. static readonly UV5Kind: string;
  80841. /**
  80842. * Texture coordinates 6
  80843. */
  80844. static readonly UV6Kind: string;
  80845. /**
  80846. * Colors
  80847. */
  80848. static readonly ColorKind: string;
  80849. /**
  80850. * Matrix indices (for bones)
  80851. */
  80852. static readonly MatricesIndicesKind: string;
  80853. /**
  80854. * Matrix weights (for bones)
  80855. */
  80856. static readonly MatricesWeightsKind: string;
  80857. /**
  80858. * Additional matrix indices (for bones)
  80859. */
  80860. static readonly MatricesIndicesExtraKind: string;
  80861. /**
  80862. * Additional matrix weights (for bones)
  80863. */
  80864. static readonly MatricesWeightsExtraKind: string;
  80865. /**
  80866. * Deduces the stride given a kind.
  80867. * @param kind The kind string to deduce
  80868. * @returns The deduced stride
  80869. */
  80870. static DeduceStride(kind: string): number;
  80871. /**
  80872. * Gets the byte length of the given type.
  80873. * @param type the type
  80874. * @returns the number of bytes
  80875. */
  80876. static GetTypeByteLength(type: number): number;
  80877. /**
  80878. * Enumerates each value of the given parameters as numbers.
  80879. * @param data the data to enumerate
  80880. * @param byteOffset the byte offset of the data
  80881. * @param byteStride the byte stride of the data
  80882. * @param componentCount the number of components per element
  80883. * @param componentType the type of the component
  80884. * @param count the number of values to enumerate
  80885. * @param normalized whether the data is normalized
  80886. * @param callback the callback function called for each value
  80887. */
  80888. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80889. private static _GetFloatValue;
  80890. }
  80891. }
  80892. declare module BABYLON {
  80893. /**
  80894. * @hidden
  80895. */
  80896. export class IntersectionInfo {
  80897. bu: Nullable<number>;
  80898. bv: Nullable<number>;
  80899. distance: number;
  80900. faceId: number;
  80901. subMeshId: number;
  80902. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80903. }
  80904. }
  80905. declare module BABYLON {
  80906. /**
  80907. * Represens a plane by the equation ax + by + cz + d = 0
  80908. */
  80909. export class Plane {
  80910. private static _TmpMatrix;
  80911. /**
  80912. * Normal of the plane (a,b,c)
  80913. */
  80914. normal: Vector3;
  80915. /**
  80916. * d component of the plane
  80917. */
  80918. d: number;
  80919. /**
  80920. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80921. * @param a a component of the plane
  80922. * @param b b component of the plane
  80923. * @param c c component of the plane
  80924. * @param d d component of the plane
  80925. */
  80926. constructor(a: number, b: number, c: number, d: number);
  80927. /**
  80928. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80929. */
  80930. asArray(): number[];
  80931. /**
  80932. * @returns a new plane copied from the current Plane.
  80933. */
  80934. clone(): Plane;
  80935. /**
  80936. * @returns the string "Plane".
  80937. */
  80938. getClassName(): string;
  80939. /**
  80940. * @returns the Plane hash code.
  80941. */
  80942. getHashCode(): number;
  80943. /**
  80944. * Normalize the current Plane in place.
  80945. * @returns the updated Plane.
  80946. */
  80947. normalize(): Plane;
  80948. /**
  80949. * Applies a transformation the plane and returns the result
  80950. * @param transformation the transformation matrix to be applied to the plane
  80951. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80952. */
  80953. transform(transformation: DeepImmutable<Matrix>): Plane;
  80954. /**
  80955. * Calcualtte the dot product between the point and the plane normal
  80956. * @param point point to calculate the dot product with
  80957. * @returns the dot product (float) of the point coordinates and the plane normal.
  80958. */
  80959. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80960. /**
  80961. * Updates the current Plane from the plane defined by the three given points.
  80962. * @param point1 one of the points used to contruct the plane
  80963. * @param point2 one of the points used to contruct the plane
  80964. * @param point3 one of the points used to contruct the plane
  80965. * @returns the updated Plane.
  80966. */
  80967. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80968. /**
  80969. * Checks if the plane is facing a given direction
  80970. * @param direction the direction to check if the plane is facing
  80971. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80972. * @returns True is the vector "direction" is the same side than the plane normal.
  80973. */
  80974. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80975. /**
  80976. * Calculates the distance to a point
  80977. * @param point point to calculate distance to
  80978. * @returns the signed distance (float) from the given point to the Plane.
  80979. */
  80980. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80981. /**
  80982. * Creates a plane from an array
  80983. * @param array the array to create a plane from
  80984. * @returns a new Plane from the given array.
  80985. */
  80986. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80987. /**
  80988. * Creates a plane from three points
  80989. * @param point1 point used to create the plane
  80990. * @param point2 point used to create the plane
  80991. * @param point3 point used to create the plane
  80992. * @returns a new Plane defined by the three given points.
  80993. */
  80994. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80995. /**
  80996. * Creates a plane from an origin point and a normal
  80997. * @param origin origin of the plane to be constructed
  80998. * @param normal normal of the plane to be constructed
  80999. * @returns a new Plane the normal vector to this plane at the given origin point.
  81000. * Note : the vector "normal" is updated because normalized.
  81001. */
  81002. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  81003. /**
  81004. * Calculates the distance from a plane and a point
  81005. * @param origin origin of the plane to be constructed
  81006. * @param normal normal of the plane to be constructed
  81007. * @param point point to calculate distance to
  81008. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81009. */
  81010. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81011. }
  81012. }
  81013. declare module BABYLON {
  81014. /**
  81015. * Class used to store bounding sphere information
  81016. */
  81017. export class BoundingSphere {
  81018. /**
  81019. * Gets the center of the bounding sphere in local space
  81020. */
  81021. readonly center: Vector3;
  81022. /**
  81023. * Radius of the bounding sphere in local space
  81024. */
  81025. radius: number;
  81026. /**
  81027. * Gets the center of the bounding sphere in world space
  81028. */
  81029. readonly centerWorld: Vector3;
  81030. /**
  81031. * Radius of the bounding sphere in world space
  81032. */
  81033. radiusWorld: number;
  81034. /**
  81035. * Gets the minimum vector in local space
  81036. */
  81037. readonly minimum: Vector3;
  81038. /**
  81039. * Gets the maximum vector in local space
  81040. */
  81041. readonly maximum: Vector3;
  81042. private _worldMatrix;
  81043. private static readonly TmpVector3;
  81044. /**
  81045. * Creates a new bounding sphere
  81046. * @param min defines the minimum vector (in local space)
  81047. * @param max defines the maximum vector (in local space)
  81048. * @param worldMatrix defines the new world matrix
  81049. */
  81050. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81051. /**
  81052. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81053. * @param min defines the new minimum vector (in local space)
  81054. * @param max defines the new maximum vector (in local space)
  81055. * @param worldMatrix defines the new world matrix
  81056. */
  81057. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81058. /**
  81059. * Scale the current bounding sphere by applying a scale factor
  81060. * @param factor defines the scale factor to apply
  81061. * @returns the current bounding box
  81062. */
  81063. scale(factor: number): BoundingSphere;
  81064. /**
  81065. * Gets the world matrix of the bounding box
  81066. * @returns a matrix
  81067. */
  81068. getWorldMatrix(): DeepImmutable<Matrix>;
  81069. /** @hidden */
  81070. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81071. /**
  81072. * Tests if the bounding sphere is intersecting the frustum planes
  81073. * @param frustumPlanes defines the frustum planes to test
  81074. * @returns true if there is an intersection
  81075. */
  81076. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81077. /**
  81078. * Tests if the bounding sphere center is in between the frustum planes.
  81079. * Used for optimistic fast inclusion.
  81080. * @param frustumPlanes defines the frustum planes to test
  81081. * @returns true if the sphere center is in between the frustum planes
  81082. */
  81083. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81084. /**
  81085. * Tests if a point is inside the bounding sphere
  81086. * @param point defines the point to test
  81087. * @returns true if the point is inside the bounding sphere
  81088. */
  81089. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81090. /**
  81091. * Checks if two sphere intersct
  81092. * @param sphere0 sphere 0
  81093. * @param sphere1 sphere 1
  81094. * @returns true if the speres intersect
  81095. */
  81096. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81097. }
  81098. }
  81099. declare module BABYLON {
  81100. /**
  81101. * Class used to store bounding box information
  81102. */
  81103. export class BoundingBox implements ICullable {
  81104. /**
  81105. * Gets the 8 vectors representing the bounding box in local space
  81106. */
  81107. readonly vectors: Vector3[];
  81108. /**
  81109. * Gets the center of the bounding box in local space
  81110. */
  81111. readonly center: Vector3;
  81112. /**
  81113. * Gets the center of the bounding box in world space
  81114. */
  81115. readonly centerWorld: Vector3;
  81116. /**
  81117. * Gets the extend size in local space
  81118. */
  81119. readonly extendSize: Vector3;
  81120. /**
  81121. * Gets the extend size in world space
  81122. */
  81123. readonly extendSizeWorld: Vector3;
  81124. /**
  81125. * Gets the OBB (object bounding box) directions
  81126. */
  81127. readonly directions: Vector3[];
  81128. /**
  81129. * Gets the 8 vectors representing the bounding box in world space
  81130. */
  81131. readonly vectorsWorld: Vector3[];
  81132. /**
  81133. * Gets the minimum vector in world space
  81134. */
  81135. readonly minimumWorld: Vector3;
  81136. /**
  81137. * Gets the maximum vector in world space
  81138. */
  81139. readonly maximumWorld: Vector3;
  81140. /**
  81141. * Gets the minimum vector in local space
  81142. */
  81143. readonly minimum: Vector3;
  81144. /**
  81145. * Gets the maximum vector in local space
  81146. */
  81147. readonly maximum: Vector3;
  81148. private _worldMatrix;
  81149. private static readonly TmpVector3;
  81150. /**
  81151. * @hidden
  81152. */
  81153. _tag: number;
  81154. /**
  81155. * Creates a new bounding box
  81156. * @param min defines the minimum vector (in local space)
  81157. * @param max defines the maximum vector (in local space)
  81158. * @param worldMatrix defines the new world matrix
  81159. */
  81160. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81161. /**
  81162. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81163. * @param min defines the new minimum vector (in local space)
  81164. * @param max defines the new maximum vector (in local space)
  81165. * @param worldMatrix defines the new world matrix
  81166. */
  81167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81168. /**
  81169. * Scale the current bounding box by applying a scale factor
  81170. * @param factor defines the scale factor to apply
  81171. * @returns the current bounding box
  81172. */
  81173. scale(factor: number): BoundingBox;
  81174. /**
  81175. * Gets the world matrix of the bounding box
  81176. * @returns a matrix
  81177. */
  81178. getWorldMatrix(): DeepImmutable<Matrix>;
  81179. /** @hidden */
  81180. _update(world: DeepImmutable<Matrix>): void;
  81181. /**
  81182. * Tests if the bounding box is intersecting the frustum planes
  81183. * @param frustumPlanes defines the frustum planes to test
  81184. * @returns true if there is an intersection
  81185. */
  81186. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81187. /**
  81188. * Tests if the bounding box is entirely inside the frustum planes
  81189. * @param frustumPlanes defines the frustum planes to test
  81190. * @returns true if there is an inclusion
  81191. */
  81192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81193. /**
  81194. * Tests if a point is inside the bounding box
  81195. * @param point defines the point to test
  81196. * @returns true if the point is inside the bounding box
  81197. */
  81198. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81199. /**
  81200. * Tests if the bounding box intersects with a bounding sphere
  81201. * @param sphere defines the sphere to test
  81202. * @returns true if there is an intersection
  81203. */
  81204. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81205. /**
  81206. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81207. * @param min defines the min vector to use
  81208. * @param max defines the max vector to use
  81209. * @returns true if there is an intersection
  81210. */
  81211. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81212. /**
  81213. * Tests if two bounding boxes are intersections
  81214. * @param box0 defines the first box to test
  81215. * @param box1 defines the second box to test
  81216. * @returns true if there is an intersection
  81217. */
  81218. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81219. /**
  81220. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81221. * @param minPoint defines the minimum vector of the bounding box
  81222. * @param maxPoint defines the maximum vector of the bounding box
  81223. * @param sphereCenter defines the sphere center
  81224. * @param sphereRadius defines the sphere radius
  81225. * @returns true if there is an intersection
  81226. */
  81227. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81228. /**
  81229. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81230. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81231. * @param frustumPlanes defines the frustum planes to test
  81232. * @return true if there is an inclusion
  81233. */
  81234. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81235. /**
  81236. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81237. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81238. * @param frustumPlanes defines the frustum planes to test
  81239. * @return true if there is an intersection
  81240. */
  81241. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81242. }
  81243. }
  81244. declare module BABYLON {
  81245. /** @hidden */
  81246. export class Collider {
  81247. /** Define if a collision was found */
  81248. collisionFound: boolean;
  81249. /**
  81250. * Define last intersection point in local space
  81251. */
  81252. intersectionPoint: Vector3;
  81253. /**
  81254. * Define last collided mesh
  81255. */
  81256. collidedMesh: Nullable<AbstractMesh>;
  81257. private _collisionPoint;
  81258. private _planeIntersectionPoint;
  81259. private _tempVector;
  81260. private _tempVector2;
  81261. private _tempVector3;
  81262. private _tempVector4;
  81263. private _edge;
  81264. private _baseToVertex;
  81265. private _destinationPoint;
  81266. private _slidePlaneNormal;
  81267. private _displacementVector;
  81268. /** @hidden */
  81269. _radius: Vector3;
  81270. /** @hidden */
  81271. _retry: number;
  81272. private _velocity;
  81273. private _basePoint;
  81274. private _epsilon;
  81275. /** @hidden */
  81276. _velocityWorldLength: number;
  81277. /** @hidden */
  81278. _basePointWorld: Vector3;
  81279. private _velocityWorld;
  81280. private _normalizedVelocity;
  81281. /** @hidden */
  81282. _initialVelocity: Vector3;
  81283. /** @hidden */
  81284. _initialPosition: Vector3;
  81285. private _nearestDistance;
  81286. private _collisionMask;
  81287. get collisionMask(): number;
  81288. set collisionMask(mask: number);
  81289. /**
  81290. * Gets the plane normal used to compute the sliding response (in local space)
  81291. */
  81292. get slidePlaneNormal(): Vector3;
  81293. /** @hidden */
  81294. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81295. /** @hidden */
  81296. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81297. /** @hidden */
  81298. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81299. /** @hidden */
  81300. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81301. /** @hidden */
  81302. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81303. /** @hidden */
  81304. _getResponse(pos: Vector3, vel: Vector3): void;
  81305. }
  81306. }
  81307. declare module BABYLON {
  81308. /**
  81309. * Interface for cullable objects
  81310. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81311. */
  81312. export interface ICullable {
  81313. /**
  81314. * Checks if the object or part of the object is in the frustum
  81315. * @param frustumPlanes Camera near/planes
  81316. * @returns true if the object is in frustum otherwise false
  81317. */
  81318. isInFrustum(frustumPlanes: Plane[]): boolean;
  81319. /**
  81320. * Checks if a cullable object (mesh...) is in the camera frustum
  81321. * Unlike isInFrustum this cheks the full bounding box
  81322. * @param frustumPlanes Camera near/planes
  81323. * @returns true if the object is in frustum otherwise false
  81324. */
  81325. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81326. }
  81327. /**
  81328. * Info for a bounding data of a mesh
  81329. */
  81330. export class BoundingInfo implements ICullable {
  81331. /**
  81332. * Bounding box for the mesh
  81333. */
  81334. readonly boundingBox: BoundingBox;
  81335. /**
  81336. * Bounding sphere for the mesh
  81337. */
  81338. readonly boundingSphere: BoundingSphere;
  81339. private _isLocked;
  81340. private static readonly TmpVector3;
  81341. /**
  81342. * Constructs bounding info
  81343. * @param minimum min vector of the bounding box/sphere
  81344. * @param maximum max vector of the bounding box/sphere
  81345. * @param worldMatrix defines the new world matrix
  81346. */
  81347. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81348. /**
  81349. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81350. * @param min defines the new minimum vector (in local space)
  81351. * @param max defines the new maximum vector (in local space)
  81352. * @param worldMatrix defines the new world matrix
  81353. */
  81354. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81355. /**
  81356. * min vector of the bounding box/sphere
  81357. */
  81358. get minimum(): Vector3;
  81359. /**
  81360. * max vector of the bounding box/sphere
  81361. */
  81362. get maximum(): Vector3;
  81363. /**
  81364. * If the info is locked and won't be updated to avoid perf overhead
  81365. */
  81366. get isLocked(): boolean;
  81367. set isLocked(value: boolean);
  81368. /**
  81369. * Updates the bounding sphere and box
  81370. * @param world world matrix to be used to update
  81371. */
  81372. update(world: DeepImmutable<Matrix>): void;
  81373. /**
  81374. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81375. * @param center New center of the bounding info
  81376. * @param extend New extend of the bounding info
  81377. * @returns the current bounding info
  81378. */
  81379. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81380. /**
  81381. * Scale the current bounding info by applying a scale factor
  81382. * @param factor defines the scale factor to apply
  81383. * @returns the current bounding info
  81384. */
  81385. scale(factor: number): BoundingInfo;
  81386. /**
  81387. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81388. * @param frustumPlanes defines the frustum to test
  81389. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81390. * @returns true if the bounding info is in the frustum planes
  81391. */
  81392. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81393. /**
  81394. * Gets the world distance between the min and max points of the bounding box
  81395. */
  81396. get diagonalLength(): number;
  81397. /**
  81398. * Checks if a cullable object (mesh...) is in the camera frustum
  81399. * Unlike isInFrustum this cheks the full bounding box
  81400. * @param frustumPlanes Camera near/planes
  81401. * @returns true if the object is in frustum otherwise false
  81402. */
  81403. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81404. /** @hidden */
  81405. _checkCollision(collider: Collider): boolean;
  81406. /**
  81407. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81408. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81409. * @param point the point to check intersection with
  81410. * @returns if the point intersects
  81411. */
  81412. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81413. /**
  81414. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81415. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81416. * @param boundingInfo the bounding info to check intersection with
  81417. * @param precise if the intersection should be done using OBB
  81418. * @returns if the bounding info intersects
  81419. */
  81420. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81421. }
  81422. }
  81423. declare module BABYLON {
  81424. /**
  81425. * Extracts minimum and maximum values from a list of indexed positions
  81426. * @param positions defines the positions to use
  81427. * @param indices defines the indices to the positions
  81428. * @param indexStart defines the start index
  81429. * @param indexCount defines the end index
  81430. * @param bias defines bias value to add to the result
  81431. * @return minimum and maximum values
  81432. */
  81433. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81434. minimum: Vector3;
  81435. maximum: Vector3;
  81436. };
  81437. /**
  81438. * Extracts minimum and maximum values from a list of positions
  81439. * @param positions defines the positions to use
  81440. * @param start defines the start index in the positions array
  81441. * @param count defines the number of positions to handle
  81442. * @param bias defines bias value to add to the result
  81443. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81444. * @return minimum and maximum values
  81445. */
  81446. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81447. minimum: Vector3;
  81448. maximum: Vector3;
  81449. };
  81450. }
  81451. declare module BABYLON {
  81452. /** @hidden */
  81453. export class WebGLDataBuffer extends DataBuffer {
  81454. private _buffer;
  81455. constructor(resource: WebGLBuffer);
  81456. get underlyingResource(): any;
  81457. }
  81458. }
  81459. declare module BABYLON {
  81460. /** @hidden */
  81461. export class WebGLPipelineContext implements IPipelineContext {
  81462. engine: ThinEngine;
  81463. program: Nullable<WebGLProgram>;
  81464. context?: WebGLRenderingContext;
  81465. vertexShader?: WebGLShader;
  81466. fragmentShader?: WebGLShader;
  81467. isParallelCompiled: boolean;
  81468. onCompiled?: () => void;
  81469. transformFeedback?: WebGLTransformFeedback | null;
  81470. vertexCompilationError: Nullable<string>;
  81471. fragmentCompilationError: Nullable<string>;
  81472. programLinkError: Nullable<string>;
  81473. programValidationError: Nullable<string>;
  81474. get isAsync(): boolean;
  81475. get isReady(): boolean;
  81476. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81477. _getVertexShaderCode(): string | null;
  81478. _getFragmentShaderCode(): string | null;
  81479. }
  81480. }
  81481. declare module BABYLON {
  81482. interface ThinEngine {
  81483. /**
  81484. * Create an uniform buffer
  81485. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81486. * @param elements defines the content of the uniform buffer
  81487. * @returns the webGL uniform buffer
  81488. */
  81489. createUniformBuffer(elements: FloatArray): DataBuffer;
  81490. /**
  81491. * Create a dynamic uniform buffer
  81492. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81493. * @param elements defines the content of the uniform buffer
  81494. * @returns the webGL uniform buffer
  81495. */
  81496. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81497. /**
  81498. * Update an existing uniform buffer
  81499. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81500. * @param uniformBuffer defines the target uniform buffer
  81501. * @param elements defines the content to update
  81502. * @param offset defines the offset in the uniform buffer where update should start
  81503. * @param count defines the size of the data to update
  81504. */
  81505. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81506. /**
  81507. * Bind an uniform buffer to the current webGL context
  81508. * @param buffer defines the buffer to bind
  81509. */
  81510. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81511. /**
  81512. * Bind a buffer to the current webGL context at a given location
  81513. * @param buffer defines the buffer to bind
  81514. * @param location defines the index where to bind the buffer
  81515. */
  81516. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81517. /**
  81518. * Bind a specific block at a given index in a specific shader program
  81519. * @param pipelineContext defines the pipeline context to use
  81520. * @param blockName defines the block name
  81521. * @param index defines the index where to bind the block
  81522. */
  81523. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81524. }
  81525. }
  81526. declare module BABYLON {
  81527. /**
  81528. * Uniform buffer objects.
  81529. *
  81530. * Handles blocks of uniform on the GPU.
  81531. *
  81532. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81533. *
  81534. * For more information, please refer to :
  81535. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81536. */
  81537. export class UniformBuffer {
  81538. private _engine;
  81539. private _buffer;
  81540. private _data;
  81541. private _bufferData;
  81542. private _dynamic?;
  81543. private _uniformLocations;
  81544. private _uniformSizes;
  81545. private _uniformLocationPointer;
  81546. private _needSync;
  81547. private _noUBO;
  81548. private _currentEffect;
  81549. /** @hidden */
  81550. _alreadyBound: boolean;
  81551. private static _MAX_UNIFORM_SIZE;
  81552. private static _tempBuffer;
  81553. /**
  81554. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81555. * This is dynamic to allow compat with webgl 1 and 2.
  81556. * You will need to pass the name of the uniform as well as the value.
  81557. */
  81558. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81559. /**
  81560. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81561. * This is dynamic to allow compat with webgl 1 and 2.
  81562. * You will need to pass the name of the uniform as well as the value.
  81563. */
  81564. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81565. /**
  81566. * Lambda to Update a single float in a uniform buffer.
  81567. * This is dynamic to allow compat with webgl 1 and 2.
  81568. * You will need to pass the name of the uniform as well as the value.
  81569. */
  81570. updateFloat: (name: string, x: number) => void;
  81571. /**
  81572. * Lambda to Update a vec2 of float in a uniform buffer.
  81573. * This is dynamic to allow compat with webgl 1 and 2.
  81574. * You will need to pass the name of the uniform as well as the value.
  81575. */
  81576. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81577. /**
  81578. * Lambda to Update a vec3 of float in a uniform buffer.
  81579. * This is dynamic to allow compat with webgl 1 and 2.
  81580. * You will need to pass the name of the uniform as well as the value.
  81581. */
  81582. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81583. /**
  81584. * Lambda to Update a vec4 of float in a uniform buffer.
  81585. * This is dynamic to allow compat with webgl 1 and 2.
  81586. * You will need to pass the name of the uniform as well as the value.
  81587. */
  81588. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81589. /**
  81590. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81591. * This is dynamic to allow compat with webgl 1 and 2.
  81592. * You will need to pass the name of the uniform as well as the value.
  81593. */
  81594. updateMatrix: (name: string, mat: Matrix) => void;
  81595. /**
  81596. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81597. * This is dynamic to allow compat with webgl 1 and 2.
  81598. * You will need to pass the name of the uniform as well as the value.
  81599. */
  81600. updateVector3: (name: string, vector: Vector3) => void;
  81601. /**
  81602. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81603. * This is dynamic to allow compat with webgl 1 and 2.
  81604. * You will need to pass the name of the uniform as well as the value.
  81605. */
  81606. updateVector4: (name: string, vector: Vector4) => void;
  81607. /**
  81608. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81609. * This is dynamic to allow compat with webgl 1 and 2.
  81610. * You will need to pass the name of the uniform as well as the value.
  81611. */
  81612. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81613. /**
  81614. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81615. * This is dynamic to allow compat with webgl 1 and 2.
  81616. * You will need to pass the name of the uniform as well as the value.
  81617. */
  81618. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81619. /**
  81620. * Instantiates a new Uniform buffer objects.
  81621. *
  81622. * Handles blocks of uniform on the GPU.
  81623. *
  81624. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81625. *
  81626. * For more information, please refer to :
  81627. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81628. * @param engine Define the engine the buffer is associated with
  81629. * @param data Define the data contained in the buffer
  81630. * @param dynamic Define if the buffer is updatable
  81631. */
  81632. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81633. /**
  81634. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81635. * or just falling back on setUniformXXX calls.
  81636. */
  81637. get useUbo(): boolean;
  81638. /**
  81639. * Indicates if the WebGL underlying uniform buffer is in sync
  81640. * with the javascript cache data.
  81641. */
  81642. get isSync(): boolean;
  81643. /**
  81644. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81645. * Also, a dynamic UniformBuffer will disable cache verification and always
  81646. * update the underlying WebGL uniform buffer to the GPU.
  81647. * @returns if Dynamic, otherwise false
  81648. */
  81649. isDynamic(): boolean;
  81650. /**
  81651. * The data cache on JS side.
  81652. * @returns the underlying data as a float array
  81653. */
  81654. getData(): Float32Array;
  81655. /**
  81656. * The underlying WebGL Uniform buffer.
  81657. * @returns the webgl buffer
  81658. */
  81659. getBuffer(): Nullable<DataBuffer>;
  81660. /**
  81661. * std140 layout specifies how to align data within an UBO structure.
  81662. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81663. * for specs.
  81664. */
  81665. private _fillAlignment;
  81666. /**
  81667. * Adds an uniform in the buffer.
  81668. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81669. * for the layout to be correct !
  81670. * @param name Name of the uniform, as used in the uniform block in the shader.
  81671. * @param size Data size, or data directly.
  81672. */
  81673. addUniform(name: string, size: number | number[]): void;
  81674. /**
  81675. * Adds a Matrix 4x4 to the uniform buffer.
  81676. * @param name Name of the uniform, as used in the uniform block in the shader.
  81677. * @param mat A 4x4 matrix.
  81678. */
  81679. addMatrix(name: string, mat: Matrix): void;
  81680. /**
  81681. * Adds a vec2 to the uniform buffer.
  81682. * @param name Name of the uniform, as used in the uniform block in the shader.
  81683. * @param x Define the x component value of the vec2
  81684. * @param y Define the y component value of the vec2
  81685. */
  81686. addFloat2(name: string, x: number, y: number): void;
  81687. /**
  81688. * Adds a vec3 to the uniform buffer.
  81689. * @param name Name of the uniform, as used in the uniform block in the shader.
  81690. * @param x Define the x component value of the vec3
  81691. * @param y Define the y component value of the vec3
  81692. * @param z Define the z component value of the vec3
  81693. */
  81694. addFloat3(name: string, x: number, y: number, z: number): void;
  81695. /**
  81696. * Adds a vec3 to the uniform buffer.
  81697. * @param name Name of the uniform, as used in the uniform block in the shader.
  81698. * @param color Define the vec3 from a Color
  81699. */
  81700. addColor3(name: string, color: Color3): void;
  81701. /**
  81702. * Adds a vec4 to the uniform buffer.
  81703. * @param name Name of the uniform, as used in the uniform block in the shader.
  81704. * @param color Define the rgb components from a Color
  81705. * @param alpha Define the a component of the vec4
  81706. */
  81707. addColor4(name: string, color: Color3, alpha: number): void;
  81708. /**
  81709. * Adds a vec3 to the uniform buffer.
  81710. * @param name Name of the uniform, as used in the uniform block in the shader.
  81711. * @param vector Define the vec3 components from a Vector
  81712. */
  81713. addVector3(name: string, vector: Vector3): void;
  81714. /**
  81715. * Adds a Matrix 3x3 to the uniform buffer.
  81716. * @param name Name of the uniform, as used in the uniform block in the shader.
  81717. */
  81718. addMatrix3x3(name: string): void;
  81719. /**
  81720. * Adds a Matrix 2x2 to the uniform buffer.
  81721. * @param name Name of the uniform, as used in the uniform block in the shader.
  81722. */
  81723. addMatrix2x2(name: string): void;
  81724. /**
  81725. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81726. */
  81727. create(): void;
  81728. /** @hidden */
  81729. _rebuild(): void;
  81730. /**
  81731. * Updates the WebGL Uniform Buffer on the GPU.
  81732. * If the `dynamic` flag is set to true, no cache comparison is done.
  81733. * Otherwise, the buffer will be updated only if the cache differs.
  81734. */
  81735. update(): void;
  81736. /**
  81737. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81739. * @param data Define the flattened data
  81740. * @param size Define the size of the data.
  81741. */
  81742. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81743. private _valueCache;
  81744. private _cacheMatrix;
  81745. private _updateMatrix3x3ForUniform;
  81746. private _updateMatrix3x3ForEffect;
  81747. private _updateMatrix2x2ForEffect;
  81748. private _updateMatrix2x2ForUniform;
  81749. private _updateFloatForEffect;
  81750. private _updateFloatForUniform;
  81751. private _updateFloat2ForEffect;
  81752. private _updateFloat2ForUniform;
  81753. private _updateFloat3ForEffect;
  81754. private _updateFloat3ForUniform;
  81755. private _updateFloat4ForEffect;
  81756. private _updateFloat4ForUniform;
  81757. private _updateMatrixForEffect;
  81758. private _updateMatrixForUniform;
  81759. private _updateVector3ForEffect;
  81760. private _updateVector3ForUniform;
  81761. private _updateVector4ForEffect;
  81762. private _updateVector4ForUniform;
  81763. private _updateColor3ForEffect;
  81764. private _updateColor3ForUniform;
  81765. private _updateColor4ForEffect;
  81766. private _updateColor4ForUniform;
  81767. /**
  81768. * Sets a sampler uniform on the effect.
  81769. * @param name Define the name of the sampler.
  81770. * @param texture Define the texture to set in the sampler
  81771. */
  81772. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81773. /**
  81774. * Directly updates the value of the uniform in the cache AND on the GPU.
  81775. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81776. * @param data Define the flattened data
  81777. */
  81778. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81779. /**
  81780. * Binds this uniform buffer to an effect.
  81781. * @param effect Define the effect to bind the buffer to
  81782. * @param name Name of the uniform block in the shader.
  81783. */
  81784. bindToEffect(effect: Effect, name: string): void;
  81785. /**
  81786. * Disposes the uniform buffer.
  81787. */
  81788. dispose(): void;
  81789. }
  81790. }
  81791. declare module BABYLON {
  81792. /**
  81793. * Enum that determines the text-wrapping mode to use.
  81794. */
  81795. export enum InspectableType {
  81796. /**
  81797. * Checkbox for booleans
  81798. */
  81799. Checkbox = 0,
  81800. /**
  81801. * Sliders for numbers
  81802. */
  81803. Slider = 1,
  81804. /**
  81805. * Vector3
  81806. */
  81807. Vector3 = 2,
  81808. /**
  81809. * Quaternions
  81810. */
  81811. Quaternion = 3,
  81812. /**
  81813. * Color3
  81814. */
  81815. Color3 = 4,
  81816. /**
  81817. * String
  81818. */
  81819. String = 5
  81820. }
  81821. /**
  81822. * Interface used to define custom inspectable properties.
  81823. * This interface is used by the inspector to display custom property grids
  81824. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81825. */
  81826. export interface IInspectable {
  81827. /**
  81828. * Gets the label to display
  81829. */
  81830. label: string;
  81831. /**
  81832. * Gets the name of the property to edit
  81833. */
  81834. propertyName: string;
  81835. /**
  81836. * Gets the type of the editor to use
  81837. */
  81838. type: InspectableType;
  81839. /**
  81840. * Gets the minimum value of the property when using in "slider" mode
  81841. */
  81842. min?: number;
  81843. /**
  81844. * Gets the maximum value of the property when using in "slider" mode
  81845. */
  81846. max?: number;
  81847. /**
  81848. * Gets the setp to use when using in "slider" mode
  81849. */
  81850. step?: number;
  81851. }
  81852. }
  81853. declare module BABYLON {
  81854. /**
  81855. * Class used to provide helper for timing
  81856. */
  81857. export class TimingTools {
  81858. /**
  81859. * Polyfill for setImmediate
  81860. * @param action defines the action to execute after the current execution block
  81861. */
  81862. static SetImmediate(action: () => void): void;
  81863. }
  81864. }
  81865. declare module BABYLON {
  81866. /**
  81867. * Class used to enable instatition of objects by class name
  81868. */
  81869. export class InstantiationTools {
  81870. /**
  81871. * Use this object to register external classes like custom textures or material
  81872. * to allow the laoders to instantiate them
  81873. */
  81874. static RegisteredExternalClasses: {
  81875. [key: string]: Object;
  81876. };
  81877. /**
  81878. * Tries to instantiate a new object from a given class name
  81879. * @param className defines the class name to instantiate
  81880. * @returns the new object or null if the system was not able to do the instantiation
  81881. */
  81882. static Instantiate(className: string): any;
  81883. }
  81884. }
  81885. declare module BABYLON {
  81886. /**
  81887. * Define options used to create a depth texture
  81888. */
  81889. export class DepthTextureCreationOptions {
  81890. /** Specifies whether or not a stencil should be allocated in the texture */
  81891. generateStencil?: boolean;
  81892. /** Specifies whether or not bilinear filtering is enable on the texture */
  81893. bilinearFiltering?: boolean;
  81894. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81895. comparisonFunction?: number;
  81896. /** Specifies if the created texture is a cube texture */
  81897. isCube?: boolean;
  81898. }
  81899. }
  81900. declare module BABYLON {
  81901. interface ThinEngine {
  81902. /**
  81903. * Creates a depth stencil cube texture.
  81904. * This is only available in WebGL 2.
  81905. * @param size The size of face edge in the cube texture.
  81906. * @param options The options defining the cube texture.
  81907. * @returns The cube texture
  81908. */
  81909. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81910. /**
  81911. * Creates a cube texture
  81912. * @param rootUrl defines the url where the files to load is located
  81913. * @param scene defines the current scene
  81914. * @param files defines the list of files to load (1 per face)
  81915. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81916. * @param onLoad defines an optional callback raised when the texture is loaded
  81917. * @param onError defines an optional callback raised if there is an issue to load the texture
  81918. * @param format defines the format of the data
  81919. * @param forcedExtension defines the extension to use to pick the right loader
  81920. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81921. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81922. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81923. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81924. * @returns the cube texture as an InternalTexture
  81925. */
  81926. 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;
  81927. /**
  81928. * Creates a cube texture
  81929. * @param rootUrl defines the url where the files to load is located
  81930. * @param scene defines the current scene
  81931. * @param files defines the list of files to load (1 per face)
  81932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81933. * @param onLoad defines an optional callback raised when the texture is loaded
  81934. * @param onError defines an optional callback raised if there is an issue to load the texture
  81935. * @param format defines the format of the data
  81936. * @param forcedExtension defines the extension to use to pick the right loader
  81937. * @returns the cube texture as an InternalTexture
  81938. */
  81939. 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;
  81940. /**
  81941. * Creates a cube texture
  81942. * @param rootUrl defines the url where the files to load is located
  81943. * @param scene defines the current scene
  81944. * @param files defines the list of files to load (1 per face)
  81945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81946. * @param onLoad defines an optional callback raised when the texture is loaded
  81947. * @param onError defines an optional callback raised if there is an issue to load the texture
  81948. * @param format defines the format of the data
  81949. * @param forcedExtension defines the extension to use to pick the right loader
  81950. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81953. * @returns the cube texture as an InternalTexture
  81954. */
  81955. 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;
  81956. /** @hidden */
  81957. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81958. /** @hidden */
  81959. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81960. /** @hidden */
  81961. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81962. /** @hidden */
  81963. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81964. /**
  81965. * @hidden
  81966. */
  81967. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81968. }
  81969. }
  81970. declare module BABYLON {
  81971. /**
  81972. * Class for creating a cube texture
  81973. */
  81974. export class CubeTexture extends BaseTexture {
  81975. private _delayedOnLoad;
  81976. /**
  81977. * Observable triggered once the texture has been loaded.
  81978. */
  81979. onLoadObservable: Observable<CubeTexture>;
  81980. /**
  81981. * The url of the texture
  81982. */
  81983. url: string;
  81984. /**
  81985. * Gets or sets the center of the bounding box associated with the cube texture.
  81986. * It must define where the camera used to render the texture was set
  81987. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81988. */
  81989. boundingBoxPosition: Vector3;
  81990. private _boundingBoxSize;
  81991. /**
  81992. * Gets or sets the size of the bounding box associated with the cube texture
  81993. * When defined, the cubemap will switch to local mode
  81994. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81995. * @example https://www.babylonjs-playground.com/#RNASML
  81996. */
  81997. set boundingBoxSize(value: Vector3);
  81998. /**
  81999. * Returns the bounding box size
  82000. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  82001. */
  82002. get boundingBoxSize(): Vector3;
  82003. protected _rotationY: number;
  82004. /**
  82005. * Sets texture matrix rotation angle around Y axis in radians.
  82006. */
  82007. set rotationY(value: number);
  82008. /**
  82009. * Gets texture matrix rotation angle around Y axis radians.
  82010. */
  82011. get rotationY(): number;
  82012. /**
  82013. * Are mip maps generated for this texture or not.
  82014. */
  82015. get noMipmap(): boolean;
  82016. private _noMipmap;
  82017. private _files;
  82018. protected _forcedExtension: Nullable<string>;
  82019. private _extensions;
  82020. private _textureMatrix;
  82021. private _format;
  82022. private _createPolynomials;
  82023. /** @hidden */
  82024. _prefiltered: boolean;
  82025. /**
  82026. * Creates a cube texture from an array of image urls
  82027. * @param files defines an array of image urls
  82028. * @param scene defines the hosting scene
  82029. * @param noMipmap specifies if mip maps are not used
  82030. * @returns a cube texture
  82031. */
  82032. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82033. /**
  82034. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82035. * @param url defines the url of the prefiltered texture
  82036. * @param scene defines the scene the texture is attached to
  82037. * @param forcedExtension defines the extension of the file if different from the url
  82038. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82039. * @return the prefiltered texture
  82040. */
  82041. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82042. /**
  82043. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82044. * as prefiltered data.
  82045. * @param rootUrl defines the url of the texture or the root name of the six images
  82046. * @param scene defines the scene the texture is attached to
  82047. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82048. * @param noMipmap defines if mipmaps should be created or not
  82049. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82050. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82051. * @param onError defines a callback triggered in case of error during load
  82052. * @param format defines the internal format to use for the texture once loaded
  82053. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82054. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82055. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82056. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82057. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82058. * @return the cube texture
  82059. */
  82060. 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);
  82061. /**
  82062. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82063. */
  82064. get isPrefiltered(): boolean;
  82065. /**
  82066. * Get the current class name of the texture useful for serialization or dynamic coding.
  82067. * @returns "CubeTexture"
  82068. */
  82069. getClassName(): string;
  82070. /**
  82071. * Update the url (and optional buffer) of this texture if url was null during construction.
  82072. * @param url the url of the texture
  82073. * @param forcedExtension defines the extension to use
  82074. * @param onLoad callback called when the texture is loaded (defaults to null)
  82075. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82076. */
  82077. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82078. /**
  82079. * Delays loading of the cube texture
  82080. * @param forcedExtension defines the extension to use
  82081. */
  82082. delayLoad(forcedExtension?: string): void;
  82083. /**
  82084. * Returns the reflection texture matrix
  82085. * @returns the reflection texture matrix
  82086. */
  82087. getReflectionTextureMatrix(): Matrix;
  82088. /**
  82089. * Sets the reflection texture matrix
  82090. * @param value Reflection texture matrix
  82091. */
  82092. setReflectionTextureMatrix(value: Matrix): void;
  82093. /**
  82094. * Parses text to create a cube texture
  82095. * @param parsedTexture define the serialized text to read from
  82096. * @param scene defines the hosting scene
  82097. * @param rootUrl defines the root url of the cube texture
  82098. * @returns a cube texture
  82099. */
  82100. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82101. /**
  82102. * Makes a clone, or deep copy, of the cube texture
  82103. * @returns a new cube texture
  82104. */
  82105. clone(): CubeTexture;
  82106. }
  82107. }
  82108. declare module BABYLON {
  82109. /**
  82110. * Manages the defines for the Material
  82111. */
  82112. export class MaterialDefines {
  82113. /** @hidden */
  82114. protected _keys: string[];
  82115. private _isDirty;
  82116. /** @hidden */
  82117. _renderId: number;
  82118. /** @hidden */
  82119. _areLightsDirty: boolean;
  82120. /** @hidden */
  82121. _areLightsDisposed: boolean;
  82122. /** @hidden */
  82123. _areAttributesDirty: boolean;
  82124. /** @hidden */
  82125. _areTexturesDirty: boolean;
  82126. /** @hidden */
  82127. _areFresnelDirty: boolean;
  82128. /** @hidden */
  82129. _areMiscDirty: boolean;
  82130. /** @hidden */
  82131. _areImageProcessingDirty: boolean;
  82132. /** @hidden */
  82133. _normals: boolean;
  82134. /** @hidden */
  82135. _uvs: boolean;
  82136. /** @hidden */
  82137. _needNormals: boolean;
  82138. /** @hidden */
  82139. _needUVs: boolean;
  82140. [id: string]: any;
  82141. /**
  82142. * Specifies if the material needs to be re-calculated
  82143. */
  82144. get isDirty(): boolean;
  82145. /**
  82146. * Marks the material to indicate that it has been re-calculated
  82147. */
  82148. markAsProcessed(): void;
  82149. /**
  82150. * Marks the material to indicate that it needs to be re-calculated
  82151. */
  82152. markAsUnprocessed(): void;
  82153. /**
  82154. * Marks the material to indicate all of its defines need to be re-calculated
  82155. */
  82156. markAllAsDirty(): void;
  82157. /**
  82158. * Marks the material to indicate that image processing needs to be re-calculated
  82159. */
  82160. markAsImageProcessingDirty(): void;
  82161. /**
  82162. * Marks the material to indicate the lights need to be re-calculated
  82163. * @param disposed Defines whether the light is dirty due to dispose or not
  82164. */
  82165. markAsLightDirty(disposed?: boolean): void;
  82166. /**
  82167. * Marks the attribute state as changed
  82168. */
  82169. markAsAttributesDirty(): void;
  82170. /**
  82171. * Marks the texture state as changed
  82172. */
  82173. markAsTexturesDirty(): void;
  82174. /**
  82175. * Marks the fresnel state as changed
  82176. */
  82177. markAsFresnelDirty(): void;
  82178. /**
  82179. * Marks the misc state as changed
  82180. */
  82181. markAsMiscDirty(): void;
  82182. /**
  82183. * Rebuilds the material defines
  82184. */
  82185. rebuild(): void;
  82186. /**
  82187. * Specifies if two material defines are equal
  82188. * @param other - A material define instance to compare to
  82189. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82190. */
  82191. isEqual(other: MaterialDefines): boolean;
  82192. /**
  82193. * Clones this instance's defines to another instance
  82194. * @param other - material defines to clone values to
  82195. */
  82196. cloneTo(other: MaterialDefines): void;
  82197. /**
  82198. * Resets the material define values
  82199. */
  82200. reset(): void;
  82201. /**
  82202. * Converts the material define values to a string
  82203. * @returns - String of material define information
  82204. */
  82205. toString(): string;
  82206. }
  82207. }
  82208. declare module BABYLON {
  82209. /**
  82210. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82211. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82212. * 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;
  82213. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82214. */
  82215. export class ColorCurves {
  82216. private _dirty;
  82217. private _tempColor;
  82218. private _globalCurve;
  82219. private _highlightsCurve;
  82220. private _midtonesCurve;
  82221. private _shadowsCurve;
  82222. private _positiveCurve;
  82223. private _negativeCurve;
  82224. private _globalHue;
  82225. private _globalDensity;
  82226. private _globalSaturation;
  82227. private _globalExposure;
  82228. /**
  82229. * Gets the global Hue value.
  82230. * 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).
  82231. */
  82232. get globalHue(): number;
  82233. /**
  82234. * Sets the global Hue value.
  82235. * 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).
  82236. */
  82237. set globalHue(value: number);
  82238. /**
  82239. * Gets the global Density value.
  82240. * 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.
  82241. * Values less than zero provide a filter of opposite hue.
  82242. */
  82243. get globalDensity(): number;
  82244. /**
  82245. * Sets the global Density value.
  82246. * 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.
  82247. * Values less than zero provide a filter of opposite hue.
  82248. */
  82249. set globalDensity(value: number);
  82250. /**
  82251. * Gets the global Saturation value.
  82252. * 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.
  82253. */
  82254. get globalSaturation(): number;
  82255. /**
  82256. * Sets the global Saturation value.
  82257. * 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.
  82258. */
  82259. set globalSaturation(value: number);
  82260. /**
  82261. * Gets the global Exposure value.
  82262. * 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.
  82263. */
  82264. get globalExposure(): number;
  82265. /**
  82266. * Sets the global Exposure value.
  82267. * 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.
  82268. */
  82269. set globalExposure(value: number);
  82270. private _highlightsHue;
  82271. private _highlightsDensity;
  82272. private _highlightsSaturation;
  82273. private _highlightsExposure;
  82274. /**
  82275. * Gets the highlights Hue value.
  82276. * 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).
  82277. */
  82278. get highlightsHue(): number;
  82279. /**
  82280. * Sets the highlights Hue value.
  82281. * 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).
  82282. */
  82283. set highlightsHue(value: number);
  82284. /**
  82285. * Gets the highlights Density value.
  82286. * 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.
  82287. * Values less than zero provide a filter of opposite hue.
  82288. */
  82289. get highlightsDensity(): number;
  82290. /**
  82291. * Sets the highlights Density value.
  82292. * 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.
  82293. * Values less than zero provide a filter of opposite hue.
  82294. */
  82295. set highlightsDensity(value: number);
  82296. /**
  82297. * Gets the highlights Saturation value.
  82298. * 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.
  82299. */
  82300. get highlightsSaturation(): number;
  82301. /**
  82302. * Sets the highlights Saturation value.
  82303. * 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.
  82304. */
  82305. set highlightsSaturation(value: number);
  82306. /**
  82307. * Gets the highlights Exposure value.
  82308. * 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.
  82309. */
  82310. get highlightsExposure(): number;
  82311. /**
  82312. * Sets the highlights Exposure value.
  82313. * 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.
  82314. */
  82315. set highlightsExposure(value: number);
  82316. private _midtonesHue;
  82317. private _midtonesDensity;
  82318. private _midtonesSaturation;
  82319. private _midtonesExposure;
  82320. /**
  82321. * Gets the midtones Hue value.
  82322. * 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).
  82323. */
  82324. get midtonesHue(): number;
  82325. /**
  82326. * Sets the midtones Hue value.
  82327. * 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).
  82328. */
  82329. set midtonesHue(value: number);
  82330. /**
  82331. * Gets the midtones Density value.
  82332. * 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.
  82333. * Values less than zero provide a filter of opposite hue.
  82334. */
  82335. get midtonesDensity(): number;
  82336. /**
  82337. * Sets the midtones Density value.
  82338. * 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.
  82339. * Values less than zero provide a filter of opposite hue.
  82340. */
  82341. set midtonesDensity(value: number);
  82342. /**
  82343. * Gets the midtones Saturation value.
  82344. * 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.
  82345. */
  82346. get midtonesSaturation(): number;
  82347. /**
  82348. * Sets the midtones Saturation value.
  82349. * 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.
  82350. */
  82351. set midtonesSaturation(value: number);
  82352. /**
  82353. * Gets the midtones Exposure value.
  82354. * 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.
  82355. */
  82356. get midtonesExposure(): number;
  82357. /**
  82358. * Sets the midtones Exposure value.
  82359. * 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.
  82360. */
  82361. set midtonesExposure(value: number);
  82362. private _shadowsHue;
  82363. private _shadowsDensity;
  82364. private _shadowsSaturation;
  82365. private _shadowsExposure;
  82366. /**
  82367. * Gets the shadows Hue value.
  82368. * 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).
  82369. */
  82370. get shadowsHue(): number;
  82371. /**
  82372. * Sets the shadows Hue value.
  82373. * 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).
  82374. */
  82375. set shadowsHue(value: number);
  82376. /**
  82377. * Gets the shadows Density value.
  82378. * 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.
  82379. * Values less than zero provide a filter of opposite hue.
  82380. */
  82381. get shadowsDensity(): number;
  82382. /**
  82383. * Sets the shadows Density value.
  82384. * 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.
  82385. * Values less than zero provide a filter of opposite hue.
  82386. */
  82387. set shadowsDensity(value: number);
  82388. /**
  82389. * Gets the shadows Saturation value.
  82390. * 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.
  82391. */
  82392. get shadowsSaturation(): number;
  82393. /**
  82394. * Sets the shadows Saturation value.
  82395. * 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.
  82396. */
  82397. set shadowsSaturation(value: number);
  82398. /**
  82399. * Gets the shadows Exposure value.
  82400. * 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.
  82401. */
  82402. get shadowsExposure(): number;
  82403. /**
  82404. * Sets the shadows Exposure value.
  82405. * 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.
  82406. */
  82407. set shadowsExposure(value: number);
  82408. /**
  82409. * Returns the class name
  82410. * @returns The class name
  82411. */
  82412. getClassName(): string;
  82413. /**
  82414. * Binds the color curves to the shader.
  82415. * @param colorCurves The color curve to bind
  82416. * @param effect The effect to bind to
  82417. * @param positiveUniform The positive uniform shader parameter
  82418. * @param neutralUniform The neutral uniform shader parameter
  82419. * @param negativeUniform The negative uniform shader parameter
  82420. */
  82421. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82422. /**
  82423. * Prepare the list of uniforms associated with the ColorCurves effects.
  82424. * @param uniformsList The list of uniforms used in the effect
  82425. */
  82426. static PrepareUniforms(uniformsList: string[]): void;
  82427. /**
  82428. * Returns color grading data based on a hue, density, saturation and exposure value.
  82429. * @param filterHue The hue of the color filter.
  82430. * @param filterDensity The density of the color filter.
  82431. * @param saturation The saturation.
  82432. * @param exposure The exposure.
  82433. * @param result The result data container.
  82434. */
  82435. private getColorGradingDataToRef;
  82436. /**
  82437. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82438. * @param value The input slider value in range [-100,100].
  82439. * @returns Adjusted value.
  82440. */
  82441. private static applyColorGradingSliderNonlinear;
  82442. /**
  82443. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82444. * @param hue The hue (H) input.
  82445. * @param saturation The saturation (S) input.
  82446. * @param brightness The brightness (B) input.
  82447. * @result An RGBA color represented as Vector4.
  82448. */
  82449. private static fromHSBToRef;
  82450. /**
  82451. * Returns a value clamped between min and max
  82452. * @param value The value to clamp
  82453. * @param min The minimum of value
  82454. * @param max The maximum of value
  82455. * @returns The clamped value.
  82456. */
  82457. private static clamp;
  82458. /**
  82459. * Clones the current color curve instance.
  82460. * @return The cloned curves
  82461. */
  82462. clone(): ColorCurves;
  82463. /**
  82464. * Serializes the current color curve instance to a json representation.
  82465. * @return a JSON representation
  82466. */
  82467. serialize(): any;
  82468. /**
  82469. * Parses the color curve from a json representation.
  82470. * @param source the JSON source to parse
  82471. * @return The parsed curves
  82472. */
  82473. static Parse(source: any): ColorCurves;
  82474. }
  82475. }
  82476. declare module BABYLON {
  82477. /**
  82478. * Interface to follow in your material defines to integrate easily the
  82479. * Image proccessing functions.
  82480. * @hidden
  82481. */
  82482. export interface IImageProcessingConfigurationDefines {
  82483. IMAGEPROCESSING: boolean;
  82484. VIGNETTE: boolean;
  82485. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82486. VIGNETTEBLENDMODEOPAQUE: boolean;
  82487. TONEMAPPING: boolean;
  82488. TONEMAPPING_ACES: boolean;
  82489. CONTRAST: boolean;
  82490. EXPOSURE: boolean;
  82491. COLORCURVES: boolean;
  82492. COLORGRADING: boolean;
  82493. COLORGRADING3D: boolean;
  82494. SAMPLER3DGREENDEPTH: boolean;
  82495. SAMPLER3DBGRMAP: boolean;
  82496. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82497. }
  82498. /**
  82499. * @hidden
  82500. */
  82501. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82502. IMAGEPROCESSING: boolean;
  82503. VIGNETTE: boolean;
  82504. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82505. VIGNETTEBLENDMODEOPAQUE: boolean;
  82506. TONEMAPPING: boolean;
  82507. TONEMAPPING_ACES: boolean;
  82508. CONTRAST: boolean;
  82509. COLORCURVES: boolean;
  82510. COLORGRADING: boolean;
  82511. COLORGRADING3D: boolean;
  82512. SAMPLER3DGREENDEPTH: boolean;
  82513. SAMPLER3DBGRMAP: boolean;
  82514. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82515. EXPOSURE: boolean;
  82516. constructor();
  82517. }
  82518. /**
  82519. * This groups together the common properties used for image processing either in direct forward pass
  82520. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82521. * or not.
  82522. */
  82523. export class ImageProcessingConfiguration {
  82524. /**
  82525. * Default tone mapping applied in BabylonJS.
  82526. */
  82527. static readonly TONEMAPPING_STANDARD: number;
  82528. /**
  82529. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82530. * to other engines rendering to increase portability.
  82531. */
  82532. static readonly TONEMAPPING_ACES: number;
  82533. /**
  82534. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82535. */
  82536. colorCurves: Nullable<ColorCurves>;
  82537. private _colorCurvesEnabled;
  82538. /**
  82539. * Gets wether the color curves effect is enabled.
  82540. */
  82541. get colorCurvesEnabled(): boolean;
  82542. /**
  82543. * Sets wether the color curves effect is enabled.
  82544. */
  82545. set colorCurvesEnabled(value: boolean);
  82546. private _colorGradingTexture;
  82547. /**
  82548. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82549. */
  82550. get colorGradingTexture(): Nullable<BaseTexture>;
  82551. /**
  82552. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82553. */
  82554. set colorGradingTexture(value: Nullable<BaseTexture>);
  82555. private _colorGradingEnabled;
  82556. /**
  82557. * Gets wether the color grading effect is enabled.
  82558. */
  82559. get colorGradingEnabled(): boolean;
  82560. /**
  82561. * Sets wether the color grading effect is enabled.
  82562. */
  82563. set colorGradingEnabled(value: boolean);
  82564. private _colorGradingWithGreenDepth;
  82565. /**
  82566. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82567. */
  82568. get colorGradingWithGreenDepth(): boolean;
  82569. /**
  82570. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82571. */
  82572. set colorGradingWithGreenDepth(value: boolean);
  82573. private _colorGradingBGR;
  82574. /**
  82575. * Gets wether the color grading texture contains BGR values.
  82576. */
  82577. get colorGradingBGR(): boolean;
  82578. /**
  82579. * Sets wether the color grading texture contains BGR values.
  82580. */
  82581. set colorGradingBGR(value: boolean);
  82582. /** @hidden */
  82583. _exposure: number;
  82584. /**
  82585. * Gets the Exposure used in the effect.
  82586. */
  82587. get exposure(): number;
  82588. /**
  82589. * Sets the Exposure used in the effect.
  82590. */
  82591. set exposure(value: number);
  82592. private _toneMappingEnabled;
  82593. /**
  82594. * Gets wether the tone mapping effect is enabled.
  82595. */
  82596. get toneMappingEnabled(): boolean;
  82597. /**
  82598. * Sets wether the tone mapping effect is enabled.
  82599. */
  82600. set toneMappingEnabled(value: boolean);
  82601. private _toneMappingType;
  82602. /**
  82603. * Gets the type of tone mapping effect.
  82604. */
  82605. get toneMappingType(): number;
  82606. /**
  82607. * Sets the type of tone mapping effect used in BabylonJS.
  82608. */
  82609. set toneMappingType(value: number);
  82610. protected _contrast: number;
  82611. /**
  82612. * Gets the contrast used in the effect.
  82613. */
  82614. get contrast(): number;
  82615. /**
  82616. * Sets the contrast used in the effect.
  82617. */
  82618. set contrast(value: number);
  82619. /**
  82620. * Vignette stretch size.
  82621. */
  82622. vignetteStretch: number;
  82623. /**
  82624. * Vignette centre X Offset.
  82625. */
  82626. vignetteCentreX: number;
  82627. /**
  82628. * Vignette centre Y Offset.
  82629. */
  82630. vignetteCentreY: number;
  82631. /**
  82632. * Vignette weight or intensity of the vignette effect.
  82633. */
  82634. vignetteWeight: number;
  82635. /**
  82636. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82637. * if vignetteEnabled is set to true.
  82638. */
  82639. vignetteColor: Color4;
  82640. /**
  82641. * Camera field of view used by the Vignette effect.
  82642. */
  82643. vignetteCameraFov: number;
  82644. private _vignetteBlendMode;
  82645. /**
  82646. * Gets the vignette blend mode allowing different kind of effect.
  82647. */
  82648. get vignetteBlendMode(): number;
  82649. /**
  82650. * Sets the vignette blend mode allowing different kind of effect.
  82651. */
  82652. set vignetteBlendMode(value: number);
  82653. private _vignetteEnabled;
  82654. /**
  82655. * Gets wether the vignette effect is enabled.
  82656. */
  82657. get vignetteEnabled(): boolean;
  82658. /**
  82659. * Sets wether the vignette effect is enabled.
  82660. */
  82661. set vignetteEnabled(value: boolean);
  82662. private _applyByPostProcess;
  82663. /**
  82664. * Gets wether the image processing is applied through a post process or not.
  82665. */
  82666. get applyByPostProcess(): boolean;
  82667. /**
  82668. * Sets wether the image processing is applied through a post process or not.
  82669. */
  82670. set applyByPostProcess(value: boolean);
  82671. private _isEnabled;
  82672. /**
  82673. * Gets wether the image processing is enabled or not.
  82674. */
  82675. get isEnabled(): boolean;
  82676. /**
  82677. * Sets wether the image processing is enabled or not.
  82678. */
  82679. set isEnabled(value: boolean);
  82680. /**
  82681. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82682. */
  82683. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82684. /**
  82685. * Method called each time the image processing information changes requires to recompile the effect.
  82686. */
  82687. protected _updateParameters(): void;
  82688. /**
  82689. * Gets the current class name.
  82690. * @return "ImageProcessingConfiguration"
  82691. */
  82692. getClassName(): string;
  82693. /**
  82694. * Prepare the list of uniforms associated with the Image Processing effects.
  82695. * @param uniforms The list of uniforms used in the effect
  82696. * @param defines the list of defines currently in use
  82697. */
  82698. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82699. /**
  82700. * Prepare the list of samplers associated with the Image Processing effects.
  82701. * @param samplersList The list of uniforms used in the effect
  82702. * @param defines the list of defines currently in use
  82703. */
  82704. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82705. /**
  82706. * Prepare the list of defines associated to the shader.
  82707. * @param defines the list of defines to complete
  82708. * @param forPostProcess Define if we are currently in post process mode or not
  82709. */
  82710. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82711. /**
  82712. * Returns true if all the image processing information are ready.
  82713. * @returns True if ready, otherwise, false
  82714. */
  82715. isReady(): boolean;
  82716. /**
  82717. * Binds the image processing to the shader.
  82718. * @param effect The effect to bind to
  82719. * @param overrideAspectRatio Override the aspect ratio of the effect
  82720. */
  82721. bind(effect: Effect, overrideAspectRatio?: number): void;
  82722. /**
  82723. * Clones the current image processing instance.
  82724. * @return The cloned image processing
  82725. */
  82726. clone(): ImageProcessingConfiguration;
  82727. /**
  82728. * Serializes the current image processing instance to a json representation.
  82729. * @return a JSON representation
  82730. */
  82731. serialize(): any;
  82732. /**
  82733. * Parses the image processing from a json representation.
  82734. * @param source the JSON source to parse
  82735. * @return The parsed image processing
  82736. */
  82737. static Parse(source: any): ImageProcessingConfiguration;
  82738. private static _VIGNETTEMODE_MULTIPLY;
  82739. private static _VIGNETTEMODE_OPAQUE;
  82740. /**
  82741. * Used to apply the vignette as a mix with the pixel color.
  82742. */
  82743. static get VIGNETTEMODE_MULTIPLY(): number;
  82744. /**
  82745. * Used to apply the vignette as a replacement of the pixel color.
  82746. */
  82747. static get VIGNETTEMODE_OPAQUE(): number;
  82748. }
  82749. }
  82750. declare module BABYLON {
  82751. /** @hidden */
  82752. export var postprocessVertexShader: {
  82753. name: string;
  82754. shader: string;
  82755. };
  82756. }
  82757. declare module BABYLON {
  82758. interface ThinEngine {
  82759. /**
  82760. * Creates a new render target texture
  82761. * @param size defines the size of the texture
  82762. * @param options defines the options used to create the texture
  82763. * @returns a new render target texture stored in an InternalTexture
  82764. */
  82765. createRenderTargetTexture(size: number | {
  82766. width: number;
  82767. height: number;
  82768. layers?: number;
  82769. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82770. /**
  82771. * Creates a depth stencil texture.
  82772. * This is only available in WebGL 2 or with the depth texture extension available.
  82773. * @param size The size of face edge in the texture.
  82774. * @param options The options defining the texture.
  82775. * @returns The texture
  82776. */
  82777. createDepthStencilTexture(size: number | {
  82778. width: number;
  82779. height: number;
  82780. layers?: number;
  82781. }, options: DepthTextureCreationOptions): InternalTexture;
  82782. /** @hidden */
  82783. _createDepthStencilTexture(size: number | {
  82784. width: number;
  82785. height: number;
  82786. layers?: number;
  82787. }, options: DepthTextureCreationOptions): InternalTexture;
  82788. }
  82789. }
  82790. declare module BABYLON {
  82791. /** Defines supported spaces */
  82792. export enum Space {
  82793. /** Local (object) space */
  82794. LOCAL = 0,
  82795. /** World space */
  82796. WORLD = 1,
  82797. /** Bone space */
  82798. BONE = 2
  82799. }
  82800. /** Defines the 3 main axes */
  82801. export class Axis {
  82802. /** X axis */
  82803. static X: Vector3;
  82804. /** Y axis */
  82805. static Y: Vector3;
  82806. /** Z axis */
  82807. static Z: Vector3;
  82808. }
  82809. }
  82810. declare module BABYLON {
  82811. /**
  82812. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82813. * This is the base of the follow, arc rotate cameras and Free camera
  82814. * @see http://doc.babylonjs.com/features/cameras
  82815. */
  82816. export class TargetCamera extends Camera {
  82817. private static _RigCamTransformMatrix;
  82818. private static _TargetTransformMatrix;
  82819. private static _TargetFocalPoint;
  82820. /**
  82821. * Define the current direction the camera is moving to
  82822. */
  82823. cameraDirection: Vector3;
  82824. /**
  82825. * Define the current rotation the camera is rotating to
  82826. */
  82827. cameraRotation: Vector2;
  82828. /**
  82829. * When set, the up vector of the camera will be updated by the rotation of the camera
  82830. */
  82831. updateUpVectorFromRotation: boolean;
  82832. private _tmpQuaternion;
  82833. /**
  82834. * Define the current rotation of the camera
  82835. */
  82836. rotation: Vector3;
  82837. /**
  82838. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82839. */
  82840. rotationQuaternion: Quaternion;
  82841. /**
  82842. * Define the current speed of the camera
  82843. */
  82844. speed: number;
  82845. /**
  82846. * Add constraint to the camera to prevent it to move freely in all directions and
  82847. * around all axis.
  82848. */
  82849. noRotationConstraint: boolean;
  82850. /**
  82851. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82852. * panning
  82853. */
  82854. invertRotation: boolean;
  82855. /**
  82856. * Speed multiplier for inverse camera panning
  82857. */
  82858. inverseRotationSpeed: number;
  82859. /**
  82860. * Define the current target of the camera as an object or a position.
  82861. */
  82862. lockedTarget: any;
  82863. /** @hidden */
  82864. _currentTarget: Vector3;
  82865. /** @hidden */
  82866. _initialFocalDistance: number;
  82867. /** @hidden */
  82868. _viewMatrix: Matrix;
  82869. /** @hidden */
  82870. _camMatrix: Matrix;
  82871. /** @hidden */
  82872. _cameraTransformMatrix: Matrix;
  82873. /** @hidden */
  82874. _cameraRotationMatrix: Matrix;
  82875. /** @hidden */
  82876. _referencePoint: Vector3;
  82877. /** @hidden */
  82878. _transformedReferencePoint: Vector3;
  82879. protected _globalCurrentTarget: Vector3;
  82880. protected _globalCurrentUpVector: Vector3;
  82881. /** @hidden */
  82882. _reset: () => void;
  82883. private _defaultUp;
  82884. /**
  82885. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82886. * This is the base of the follow, arc rotate cameras and Free camera
  82887. * @see http://doc.babylonjs.com/features/cameras
  82888. * @param name Defines the name of the camera in the scene
  82889. * @param position Defines the start position of the camera in the scene
  82890. * @param scene Defines the scene the camera belongs to
  82891. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82892. */
  82893. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82894. /**
  82895. * Gets the position in front of the camera at a given distance.
  82896. * @param distance The distance from the camera we want the position to be
  82897. * @returns the position
  82898. */
  82899. getFrontPosition(distance: number): Vector3;
  82900. /** @hidden */
  82901. _getLockedTargetPosition(): Nullable<Vector3>;
  82902. private _storedPosition;
  82903. private _storedRotation;
  82904. private _storedRotationQuaternion;
  82905. /**
  82906. * Store current camera state of the camera (fov, position, rotation, etc..)
  82907. * @returns the camera
  82908. */
  82909. storeState(): Camera;
  82910. /**
  82911. * Restored camera state. You must call storeState() first
  82912. * @returns whether it was successful or not
  82913. * @hidden
  82914. */
  82915. _restoreStateValues(): boolean;
  82916. /** @hidden */
  82917. _initCache(): void;
  82918. /** @hidden */
  82919. _updateCache(ignoreParentClass?: boolean): void;
  82920. /** @hidden */
  82921. _isSynchronizedViewMatrix(): boolean;
  82922. /** @hidden */
  82923. _computeLocalCameraSpeed(): number;
  82924. /**
  82925. * Defines the target the camera should look at.
  82926. * @param target Defines the new target as a Vector or a mesh
  82927. */
  82928. setTarget(target: Vector3): void;
  82929. /**
  82930. * Return the current target position of the camera. This value is expressed in local space.
  82931. * @returns the target position
  82932. */
  82933. getTarget(): Vector3;
  82934. /** @hidden */
  82935. _decideIfNeedsToMove(): boolean;
  82936. /** @hidden */
  82937. _updatePosition(): void;
  82938. /** @hidden */
  82939. _checkInputs(): void;
  82940. protected _updateCameraRotationMatrix(): void;
  82941. /**
  82942. * 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)
  82943. * @returns the current camera
  82944. */
  82945. private _rotateUpVectorWithCameraRotationMatrix;
  82946. private _cachedRotationZ;
  82947. private _cachedQuaternionRotationZ;
  82948. /** @hidden */
  82949. _getViewMatrix(): Matrix;
  82950. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82951. /**
  82952. * @hidden
  82953. */
  82954. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82955. /**
  82956. * @hidden
  82957. */
  82958. _updateRigCameras(): void;
  82959. private _getRigCamPositionAndTarget;
  82960. /**
  82961. * Gets the current object class name.
  82962. * @return the class name
  82963. */
  82964. getClassName(): string;
  82965. }
  82966. }
  82967. declare module BABYLON {
  82968. /**
  82969. * Gather the list of keyboard event types as constants.
  82970. */
  82971. export class KeyboardEventTypes {
  82972. /**
  82973. * The keydown event is fired when a key becomes active (pressed).
  82974. */
  82975. static readonly KEYDOWN: number;
  82976. /**
  82977. * The keyup event is fired when a key has been released.
  82978. */
  82979. static readonly KEYUP: number;
  82980. }
  82981. /**
  82982. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82983. */
  82984. export class KeyboardInfo {
  82985. /**
  82986. * Defines the type of event (KeyboardEventTypes)
  82987. */
  82988. type: number;
  82989. /**
  82990. * Defines the related dom event
  82991. */
  82992. event: KeyboardEvent;
  82993. /**
  82994. * Instantiates a new keyboard info.
  82995. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82996. * @param type Defines the type of event (KeyboardEventTypes)
  82997. * @param event Defines the related dom event
  82998. */
  82999. constructor(
  83000. /**
  83001. * Defines the type of event (KeyboardEventTypes)
  83002. */
  83003. type: number,
  83004. /**
  83005. * Defines the related dom event
  83006. */
  83007. event: KeyboardEvent);
  83008. }
  83009. /**
  83010. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83011. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  83012. */
  83013. export class KeyboardInfoPre extends KeyboardInfo {
  83014. /**
  83015. * Defines the type of event (KeyboardEventTypes)
  83016. */
  83017. type: number;
  83018. /**
  83019. * Defines the related dom event
  83020. */
  83021. event: KeyboardEvent;
  83022. /**
  83023. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83024. */
  83025. skipOnPointerObservable: boolean;
  83026. /**
  83027. * Instantiates a new keyboard pre info.
  83028. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83029. * @param type Defines the type of event (KeyboardEventTypes)
  83030. * @param event Defines the related dom event
  83031. */
  83032. constructor(
  83033. /**
  83034. * Defines the type of event (KeyboardEventTypes)
  83035. */
  83036. type: number,
  83037. /**
  83038. * Defines the related dom event
  83039. */
  83040. event: KeyboardEvent);
  83041. }
  83042. }
  83043. declare module BABYLON {
  83044. /**
  83045. * Manage the keyboard inputs to control the movement of a free camera.
  83046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83047. */
  83048. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83049. /**
  83050. * Defines the camera the input is attached to.
  83051. */
  83052. camera: FreeCamera;
  83053. /**
  83054. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83055. */
  83056. keysUp: number[];
  83057. /**
  83058. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83059. */
  83060. keysUpward: number[];
  83061. /**
  83062. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83063. */
  83064. keysDown: number[];
  83065. /**
  83066. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83067. */
  83068. keysDownward: number[];
  83069. /**
  83070. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83071. */
  83072. keysLeft: number[];
  83073. /**
  83074. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83075. */
  83076. keysRight: number[];
  83077. private _keys;
  83078. private _onCanvasBlurObserver;
  83079. private _onKeyboardObserver;
  83080. private _engine;
  83081. private _scene;
  83082. /**
  83083. * Attach the input controls to a specific dom element to get the input from.
  83084. * @param element Defines the element the controls should be listened from
  83085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83086. */
  83087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83088. /**
  83089. * Detach the current controls from the specified dom element.
  83090. * @param element Defines the element to stop listening the inputs from
  83091. */
  83092. detachControl(element: Nullable<HTMLElement>): void;
  83093. /**
  83094. * Update the current camera state depending on the inputs that have been used this frame.
  83095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83096. */
  83097. checkInputs(): void;
  83098. /**
  83099. * Gets the class name of the current intput.
  83100. * @returns the class name
  83101. */
  83102. getClassName(): string;
  83103. /** @hidden */
  83104. _onLostFocus(): void;
  83105. /**
  83106. * Get the friendly name associated with the input class.
  83107. * @returns the input friendly name
  83108. */
  83109. getSimpleName(): string;
  83110. }
  83111. }
  83112. declare module BABYLON {
  83113. /**
  83114. * Interface describing all the common properties and methods a shadow light needs to implement.
  83115. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83116. * as well as binding the different shadow properties to the effects.
  83117. */
  83118. export interface IShadowLight extends Light {
  83119. /**
  83120. * The light id in the scene (used in scene.findLighById for instance)
  83121. */
  83122. id: string;
  83123. /**
  83124. * The position the shdow will be casted from.
  83125. */
  83126. position: Vector3;
  83127. /**
  83128. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83129. */
  83130. direction: Vector3;
  83131. /**
  83132. * The transformed position. Position of the light in world space taking parenting in account.
  83133. */
  83134. transformedPosition: Vector3;
  83135. /**
  83136. * The transformed direction. Direction of the light in world space taking parenting in account.
  83137. */
  83138. transformedDirection: Vector3;
  83139. /**
  83140. * The friendly name of the light in the scene.
  83141. */
  83142. name: string;
  83143. /**
  83144. * Defines the shadow projection clipping minimum z value.
  83145. */
  83146. shadowMinZ: number;
  83147. /**
  83148. * Defines the shadow projection clipping maximum z value.
  83149. */
  83150. shadowMaxZ: number;
  83151. /**
  83152. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83153. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83154. */
  83155. computeTransformedInformation(): boolean;
  83156. /**
  83157. * Gets the scene the light belongs to.
  83158. * @returns The scene
  83159. */
  83160. getScene(): Scene;
  83161. /**
  83162. * Callback defining a custom Projection Matrix Builder.
  83163. * This can be used to override the default projection matrix computation.
  83164. */
  83165. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83166. /**
  83167. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83168. * @param matrix The materix to updated with the projection information
  83169. * @param viewMatrix The transform matrix of the light
  83170. * @param renderList The list of mesh to render in the map
  83171. * @returns The current light
  83172. */
  83173. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83174. /**
  83175. * Gets the current depth scale used in ESM.
  83176. * @returns The scale
  83177. */
  83178. getDepthScale(): number;
  83179. /**
  83180. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83181. * @returns true if a cube texture needs to be use
  83182. */
  83183. needCube(): boolean;
  83184. /**
  83185. * Detects if the projection matrix requires to be recomputed this frame.
  83186. * @returns true if it requires to be recomputed otherwise, false.
  83187. */
  83188. needProjectionMatrixCompute(): boolean;
  83189. /**
  83190. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83191. */
  83192. forceProjectionMatrixCompute(): void;
  83193. /**
  83194. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83195. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83196. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83197. */
  83198. getShadowDirection(faceIndex?: number): Vector3;
  83199. /**
  83200. * Gets the minZ used for shadow according to both the scene and the light.
  83201. * @param activeCamera The camera we are returning the min for
  83202. * @returns the depth min z
  83203. */
  83204. getDepthMinZ(activeCamera: Camera): number;
  83205. /**
  83206. * Gets the maxZ used for shadow according to both the scene and the light.
  83207. * @param activeCamera The camera we are returning the max for
  83208. * @returns the depth max z
  83209. */
  83210. getDepthMaxZ(activeCamera: Camera): number;
  83211. }
  83212. /**
  83213. * Base implementation IShadowLight
  83214. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83215. */
  83216. export abstract class ShadowLight extends Light implements IShadowLight {
  83217. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83218. protected _position: Vector3;
  83219. protected _setPosition(value: Vector3): void;
  83220. /**
  83221. * Sets the position the shadow will be casted from. Also use as the light position for both
  83222. * point and spot lights.
  83223. */
  83224. get position(): Vector3;
  83225. /**
  83226. * Sets the position the shadow will be casted from. Also use as the light position for both
  83227. * point and spot lights.
  83228. */
  83229. set position(value: Vector3);
  83230. protected _direction: Vector3;
  83231. protected _setDirection(value: Vector3): void;
  83232. /**
  83233. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83234. * Also use as the light direction on spot and directional lights.
  83235. */
  83236. get direction(): Vector3;
  83237. /**
  83238. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83239. * Also use as the light direction on spot and directional lights.
  83240. */
  83241. set direction(value: Vector3);
  83242. protected _shadowMinZ: number;
  83243. /**
  83244. * Gets the shadow projection clipping minimum z value.
  83245. */
  83246. get shadowMinZ(): number;
  83247. /**
  83248. * Sets the shadow projection clipping minimum z value.
  83249. */
  83250. set shadowMinZ(value: number);
  83251. protected _shadowMaxZ: number;
  83252. /**
  83253. * Sets the shadow projection clipping maximum z value.
  83254. */
  83255. get shadowMaxZ(): number;
  83256. /**
  83257. * Gets the shadow projection clipping maximum z value.
  83258. */
  83259. set shadowMaxZ(value: number);
  83260. /**
  83261. * Callback defining a custom Projection Matrix Builder.
  83262. * This can be used to override the default projection matrix computation.
  83263. */
  83264. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83265. /**
  83266. * The transformed position. Position of the light in world space taking parenting in account.
  83267. */
  83268. transformedPosition: Vector3;
  83269. /**
  83270. * The transformed direction. Direction of the light in world space taking parenting in account.
  83271. */
  83272. transformedDirection: Vector3;
  83273. private _needProjectionMatrixCompute;
  83274. /**
  83275. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83276. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83277. */
  83278. computeTransformedInformation(): boolean;
  83279. /**
  83280. * Return the depth scale used for the shadow map.
  83281. * @returns the depth scale.
  83282. */
  83283. getDepthScale(): number;
  83284. /**
  83285. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83286. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83287. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83288. */
  83289. getShadowDirection(faceIndex?: number): Vector3;
  83290. /**
  83291. * Returns the ShadowLight absolute position in the World.
  83292. * @returns the position vector in world space
  83293. */
  83294. getAbsolutePosition(): Vector3;
  83295. /**
  83296. * Sets the ShadowLight direction toward the passed target.
  83297. * @param target The point to target in local space
  83298. * @returns the updated ShadowLight direction
  83299. */
  83300. setDirectionToTarget(target: Vector3): Vector3;
  83301. /**
  83302. * Returns the light rotation in euler definition.
  83303. * @returns the x y z rotation in local space.
  83304. */
  83305. getRotation(): Vector3;
  83306. /**
  83307. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83308. * @returns true if a cube texture needs to be use
  83309. */
  83310. needCube(): boolean;
  83311. /**
  83312. * Detects if the projection matrix requires to be recomputed this frame.
  83313. * @returns true if it requires to be recomputed otherwise, false.
  83314. */
  83315. needProjectionMatrixCompute(): boolean;
  83316. /**
  83317. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83318. */
  83319. forceProjectionMatrixCompute(): void;
  83320. /** @hidden */
  83321. _initCache(): void;
  83322. /** @hidden */
  83323. _isSynchronized(): boolean;
  83324. /**
  83325. * Computes the world matrix of the node
  83326. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83327. * @returns the world matrix
  83328. */
  83329. computeWorldMatrix(force?: boolean): Matrix;
  83330. /**
  83331. * Gets the minZ used for shadow according to both the scene and the light.
  83332. * @param activeCamera The camera we are returning the min for
  83333. * @returns the depth min z
  83334. */
  83335. getDepthMinZ(activeCamera: Camera): number;
  83336. /**
  83337. * Gets the maxZ used for shadow according to both the scene and the light.
  83338. * @param activeCamera The camera we are returning the max for
  83339. * @returns the depth max z
  83340. */
  83341. getDepthMaxZ(activeCamera: Camera): number;
  83342. /**
  83343. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83344. * @param matrix The materix to updated with the projection information
  83345. * @param viewMatrix The transform matrix of the light
  83346. * @param renderList The list of mesh to render in the map
  83347. * @returns The current light
  83348. */
  83349. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83350. }
  83351. }
  83352. declare module BABYLON {
  83353. /**
  83354. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83355. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83356. */
  83357. export class EffectFallbacks implements IEffectFallbacks {
  83358. private _defines;
  83359. private _currentRank;
  83360. private _maxRank;
  83361. private _mesh;
  83362. /**
  83363. * Removes the fallback from the bound mesh.
  83364. */
  83365. unBindMesh(): void;
  83366. /**
  83367. * Adds a fallback on the specified property.
  83368. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83369. * @param define The name of the define in the shader
  83370. */
  83371. addFallback(rank: number, define: string): void;
  83372. /**
  83373. * Sets the mesh to use CPU skinning when needing to fallback.
  83374. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83375. * @param mesh The mesh to use the fallbacks.
  83376. */
  83377. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83378. /**
  83379. * Checks to see if more fallbacks are still availible.
  83380. */
  83381. get hasMoreFallbacks(): boolean;
  83382. /**
  83383. * Removes the defines that should be removed when falling back.
  83384. * @param currentDefines defines the current define statements for the shader.
  83385. * @param effect defines the current effect we try to compile
  83386. * @returns The resulting defines with defines of the current rank removed.
  83387. */
  83388. reduce(currentDefines: string, effect: Effect): string;
  83389. }
  83390. }
  83391. declare module BABYLON {
  83392. /**
  83393. * "Static Class" containing the most commonly used helper while dealing with material for
  83394. * rendering purpose.
  83395. *
  83396. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83397. *
  83398. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83399. */
  83400. export class MaterialHelper {
  83401. /**
  83402. * Bind the current view position to an effect.
  83403. * @param effect The effect to be bound
  83404. * @param scene The scene the eyes position is used from
  83405. */
  83406. static BindEyePosition(effect: Effect, scene: Scene): void;
  83407. /**
  83408. * Helps preparing the defines values about the UVs in used in the effect.
  83409. * UVs are shared as much as we can accross channels in the shaders.
  83410. * @param texture The texture we are preparing the UVs for
  83411. * @param defines The defines to update
  83412. * @param key The channel key "diffuse", "specular"... used in the shader
  83413. */
  83414. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83415. /**
  83416. * Binds a texture matrix value to its corrsponding uniform
  83417. * @param texture The texture to bind the matrix for
  83418. * @param uniformBuffer The uniform buffer receivin the data
  83419. * @param key The channel key "diffuse", "specular"... used in the shader
  83420. */
  83421. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83422. /**
  83423. * Gets the current status of the fog (should it be enabled?)
  83424. * @param mesh defines the mesh to evaluate for fog support
  83425. * @param scene defines the hosting scene
  83426. * @returns true if fog must be enabled
  83427. */
  83428. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83429. /**
  83430. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83431. * @param mesh defines the current mesh
  83432. * @param scene defines the current scene
  83433. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83434. * @param pointsCloud defines if point cloud rendering has to be turned on
  83435. * @param fogEnabled defines if fog has to be turned on
  83436. * @param alphaTest defines if alpha testing has to be turned on
  83437. * @param defines defines the current list of defines
  83438. */
  83439. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83440. /**
  83441. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83442. * @param scene defines the current scene
  83443. * @param engine defines the current engine
  83444. * @param defines specifies the list of active defines
  83445. * @param useInstances defines if instances have to be turned on
  83446. * @param useClipPlane defines if clip plane have to be turned on
  83447. */
  83448. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83449. /**
  83450. * Prepares the defines for bones
  83451. * @param mesh The mesh containing the geometry data we will draw
  83452. * @param defines The defines to update
  83453. */
  83454. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83455. /**
  83456. * Prepares the defines for morph targets
  83457. * @param mesh The mesh containing the geometry data we will draw
  83458. * @param defines The defines to update
  83459. */
  83460. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83461. /**
  83462. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83463. * @param mesh The mesh containing the geometry data we will draw
  83464. * @param defines The defines to update
  83465. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83466. * @param useBones Precise whether bones should be used or not (override mesh info)
  83467. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83468. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83469. * @returns false if defines are considered not dirty and have not been checked
  83470. */
  83471. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83472. /**
  83473. * Prepares the defines related to multiview
  83474. * @param scene The scene we are intending to draw
  83475. * @param defines The defines to update
  83476. */
  83477. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83478. /**
  83479. * Prepares the defines related to the light information passed in parameter
  83480. * @param scene The scene we are intending to draw
  83481. * @param mesh The mesh the effect is compiling for
  83482. * @param light The light the effect is compiling for
  83483. * @param lightIndex The index of the light
  83484. * @param defines The defines to update
  83485. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83486. * @param state Defines the current state regarding what is needed (normals, etc...)
  83487. */
  83488. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83489. needNormals: boolean;
  83490. needRebuild: boolean;
  83491. shadowEnabled: boolean;
  83492. specularEnabled: boolean;
  83493. lightmapMode: boolean;
  83494. }): void;
  83495. /**
  83496. * Prepares the defines related to the light information passed in parameter
  83497. * @param scene The scene we are intending to draw
  83498. * @param mesh The mesh the effect is compiling for
  83499. * @param defines The defines to update
  83500. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83501. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83502. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83503. * @returns true if normals will be required for the rest of the effect
  83504. */
  83505. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83506. /**
  83507. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83508. * @param lightIndex defines the light index
  83509. * @param uniformsList The uniform list
  83510. * @param samplersList The sampler list
  83511. * @param projectedLightTexture defines if projected texture must be used
  83512. * @param uniformBuffersList defines an optional list of uniform buffers
  83513. */
  83514. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83515. /**
  83516. * Prepares the uniforms and samplers list to be used in the effect
  83517. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83518. * @param samplersList The sampler list
  83519. * @param defines The defines helping in the list generation
  83520. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83521. */
  83522. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83523. /**
  83524. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83525. * @param defines The defines to update while falling back
  83526. * @param fallbacks The authorized effect fallbacks
  83527. * @param maxSimultaneousLights The maximum number of lights allowed
  83528. * @param rank the current rank of the Effect
  83529. * @returns The newly affected rank
  83530. */
  83531. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83532. private static _TmpMorphInfluencers;
  83533. /**
  83534. * Prepares the list of attributes required for morph targets according to the effect defines.
  83535. * @param attribs The current list of supported attribs
  83536. * @param mesh The mesh to prepare the morph targets attributes for
  83537. * @param influencers The number of influencers
  83538. */
  83539. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83540. /**
  83541. * Prepares the list of attributes required for morph targets according to the effect defines.
  83542. * @param attribs The current list of supported attribs
  83543. * @param mesh The mesh to prepare the morph targets attributes for
  83544. * @param defines The current Defines of the effect
  83545. */
  83546. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83547. /**
  83548. * Prepares the list of attributes required for bones according to the effect defines.
  83549. * @param attribs The current list of supported attribs
  83550. * @param mesh The mesh to prepare the bones attributes for
  83551. * @param defines The current Defines of the effect
  83552. * @param fallbacks The current efffect fallback strategy
  83553. */
  83554. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83555. /**
  83556. * Check and prepare the list of attributes required for instances according to the effect defines.
  83557. * @param attribs The current list of supported attribs
  83558. * @param defines The current MaterialDefines of the effect
  83559. */
  83560. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83561. /**
  83562. * Add the list of attributes required for instances to the attribs array.
  83563. * @param attribs The current list of supported attribs
  83564. */
  83565. static PushAttributesForInstances(attribs: string[]): void;
  83566. /**
  83567. * Binds the light information to the effect.
  83568. * @param light The light containing the generator
  83569. * @param effect The effect we are binding the data to
  83570. * @param lightIndex The light index in the effect used to render
  83571. */
  83572. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83573. /**
  83574. * Binds the lights information from the scene to the effect for the given mesh.
  83575. * @param light Light to bind
  83576. * @param lightIndex Light index
  83577. * @param scene The scene where the light belongs to
  83578. * @param effect The effect we are binding the data to
  83579. * @param useSpecular Defines if specular is supported
  83580. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83581. */
  83582. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83583. /**
  83584. * Binds the lights information from the scene to the effect for the given mesh.
  83585. * @param scene The scene the lights belongs to
  83586. * @param mesh The mesh we are binding the information to render
  83587. * @param effect The effect we are binding the data to
  83588. * @param defines The generated defines for the effect
  83589. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83590. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83591. */
  83592. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83593. private static _tempFogColor;
  83594. /**
  83595. * Binds the fog information from the scene to the effect for the given mesh.
  83596. * @param scene The scene the lights belongs to
  83597. * @param mesh The mesh we are binding the information to render
  83598. * @param effect The effect we are binding the data to
  83599. * @param linearSpace Defines if the fog effect is applied in linear space
  83600. */
  83601. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83602. /**
  83603. * Binds the bones information from the mesh to the effect.
  83604. * @param mesh The mesh we are binding the information to render
  83605. * @param effect The effect we are binding the data to
  83606. */
  83607. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83608. /**
  83609. * Binds the morph targets information from the mesh to the effect.
  83610. * @param abstractMesh The mesh we are binding the information to render
  83611. * @param effect The effect we are binding the data to
  83612. */
  83613. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83614. /**
  83615. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83616. * @param defines The generated defines used in the effect
  83617. * @param effect The effect we are binding the data to
  83618. * @param scene The scene we are willing to render with logarithmic scale for
  83619. */
  83620. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83621. /**
  83622. * Binds the clip plane information from the scene to the effect.
  83623. * @param scene The scene the clip plane information are extracted from
  83624. * @param effect The effect we are binding the data to
  83625. */
  83626. static BindClipPlane(effect: Effect, scene: Scene): void;
  83627. }
  83628. }
  83629. declare module BABYLON {
  83630. /** @hidden */
  83631. export var packingFunctions: {
  83632. name: string;
  83633. shader: string;
  83634. };
  83635. }
  83636. declare module BABYLON {
  83637. /** @hidden */
  83638. export var clipPlaneFragmentDeclaration: {
  83639. name: string;
  83640. shader: string;
  83641. };
  83642. }
  83643. declare module BABYLON {
  83644. /** @hidden */
  83645. export var clipPlaneFragment: {
  83646. name: string;
  83647. shader: string;
  83648. };
  83649. }
  83650. declare module BABYLON {
  83651. /** @hidden */
  83652. export var shadowMapPixelShader: {
  83653. name: string;
  83654. shader: string;
  83655. };
  83656. }
  83657. declare module BABYLON {
  83658. /** @hidden */
  83659. export var bonesDeclaration: {
  83660. name: string;
  83661. shader: string;
  83662. };
  83663. }
  83664. declare module BABYLON {
  83665. /** @hidden */
  83666. export var morphTargetsVertexGlobalDeclaration: {
  83667. name: string;
  83668. shader: string;
  83669. };
  83670. }
  83671. declare module BABYLON {
  83672. /** @hidden */
  83673. export var morphTargetsVertexDeclaration: {
  83674. name: string;
  83675. shader: string;
  83676. };
  83677. }
  83678. declare module BABYLON {
  83679. /** @hidden */
  83680. export var instancesDeclaration: {
  83681. name: string;
  83682. shader: string;
  83683. };
  83684. }
  83685. declare module BABYLON {
  83686. /** @hidden */
  83687. export var helperFunctions: {
  83688. name: string;
  83689. shader: string;
  83690. };
  83691. }
  83692. declare module BABYLON {
  83693. /** @hidden */
  83694. export var clipPlaneVertexDeclaration: {
  83695. name: string;
  83696. shader: string;
  83697. };
  83698. }
  83699. declare module BABYLON {
  83700. /** @hidden */
  83701. export var morphTargetsVertex: {
  83702. name: string;
  83703. shader: string;
  83704. };
  83705. }
  83706. declare module BABYLON {
  83707. /** @hidden */
  83708. export var instancesVertex: {
  83709. name: string;
  83710. shader: string;
  83711. };
  83712. }
  83713. declare module BABYLON {
  83714. /** @hidden */
  83715. export var bonesVertex: {
  83716. name: string;
  83717. shader: string;
  83718. };
  83719. }
  83720. declare module BABYLON {
  83721. /** @hidden */
  83722. export var clipPlaneVertex: {
  83723. name: string;
  83724. shader: string;
  83725. };
  83726. }
  83727. declare module BABYLON {
  83728. /** @hidden */
  83729. export var shadowMapVertexShader: {
  83730. name: string;
  83731. shader: string;
  83732. };
  83733. }
  83734. declare module BABYLON {
  83735. /** @hidden */
  83736. export var depthBoxBlurPixelShader: {
  83737. name: string;
  83738. shader: string;
  83739. };
  83740. }
  83741. declare module BABYLON {
  83742. /**
  83743. * Class representing a ray with position and direction
  83744. */
  83745. export class Ray {
  83746. /** origin point */
  83747. origin: Vector3;
  83748. /** direction */
  83749. direction: Vector3;
  83750. /** length of the ray */
  83751. length: number;
  83752. private static readonly TmpVector3;
  83753. private _tmpRay;
  83754. /**
  83755. * Creates a new ray
  83756. * @param origin origin point
  83757. * @param direction direction
  83758. * @param length length of the ray
  83759. */
  83760. constructor(
  83761. /** origin point */
  83762. origin: Vector3,
  83763. /** direction */
  83764. direction: Vector3,
  83765. /** length of the ray */
  83766. length?: number);
  83767. /**
  83768. * Checks if the ray intersects a box
  83769. * @param minimum bound of the box
  83770. * @param maximum bound of the box
  83771. * @param intersectionTreshold extra extend to be added to the box in all direction
  83772. * @returns if the box was hit
  83773. */
  83774. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83775. /**
  83776. * Checks if the ray intersects a box
  83777. * @param box the bounding box to check
  83778. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83779. * @returns if the box was hit
  83780. */
  83781. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83782. /**
  83783. * If the ray hits a sphere
  83784. * @param sphere the bounding sphere to check
  83785. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83786. * @returns true if it hits the sphere
  83787. */
  83788. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83789. /**
  83790. * If the ray hits a triange
  83791. * @param vertex0 triangle vertex
  83792. * @param vertex1 triangle vertex
  83793. * @param vertex2 triangle vertex
  83794. * @returns intersection information if hit
  83795. */
  83796. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83797. /**
  83798. * Checks if ray intersects a plane
  83799. * @param plane the plane to check
  83800. * @returns the distance away it was hit
  83801. */
  83802. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83803. /**
  83804. * Calculate the intercept of a ray on a given axis
  83805. * @param axis to check 'x' | 'y' | 'z'
  83806. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83807. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83808. */
  83809. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83810. /**
  83811. * Checks if ray intersects a mesh
  83812. * @param mesh the mesh to check
  83813. * @param fastCheck if only the bounding box should checked
  83814. * @returns picking info of the intersecton
  83815. */
  83816. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83817. /**
  83818. * Checks if ray intersects a mesh
  83819. * @param meshes the meshes to check
  83820. * @param fastCheck if only the bounding box should checked
  83821. * @param results array to store result in
  83822. * @returns Array of picking infos
  83823. */
  83824. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83825. private _comparePickingInfo;
  83826. private static smallnum;
  83827. private static rayl;
  83828. /**
  83829. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83830. * @param sega the first point of the segment to test the intersection against
  83831. * @param segb the second point of the segment to test the intersection against
  83832. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83833. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83834. */
  83835. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83836. /**
  83837. * Update the ray from viewport position
  83838. * @param x position
  83839. * @param y y position
  83840. * @param viewportWidth viewport width
  83841. * @param viewportHeight viewport height
  83842. * @param world world matrix
  83843. * @param view view matrix
  83844. * @param projection projection matrix
  83845. * @returns this ray updated
  83846. */
  83847. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83848. /**
  83849. * Creates a ray with origin and direction of 0,0,0
  83850. * @returns the new ray
  83851. */
  83852. static Zero(): Ray;
  83853. /**
  83854. * Creates a new ray from screen space and viewport
  83855. * @param x position
  83856. * @param y y position
  83857. * @param viewportWidth viewport width
  83858. * @param viewportHeight viewport height
  83859. * @param world world matrix
  83860. * @param view view matrix
  83861. * @param projection projection matrix
  83862. * @returns new ray
  83863. */
  83864. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83865. /**
  83866. * 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
  83867. * transformed to the given world matrix.
  83868. * @param origin The origin point
  83869. * @param end The end point
  83870. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83871. * @returns the new ray
  83872. */
  83873. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83874. /**
  83875. * Transforms a ray by a matrix
  83876. * @param ray ray to transform
  83877. * @param matrix matrix to apply
  83878. * @returns the resulting new ray
  83879. */
  83880. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83881. /**
  83882. * Transforms a ray by a matrix
  83883. * @param ray ray to transform
  83884. * @param matrix matrix to apply
  83885. * @param result ray to store result in
  83886. */
  83887. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83888. /**
  83889. * Unproject a ray from screen space to object space
  83890. * @param sourceX defines the screen space x coordinate to use
  83891. * @param sourceY defines the screen space y coordinate to use
  83892. * @param viewportWidth defines the current width of the viewport
  83893. * @param viewportHeight defines the current height of the viewport
  83894. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83895. * @param view defines the view matrix to use
  83896. * @param projection defines the projection matrix to use
  83897. */
  83898. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83899. }
  83900. /**
  83901. * Type used to define predicate used to select faces when a mesh intersection is detected
  83902. */
  83903. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83904. interface Scene {
  83905. /** @hidden */
  83906. _tempPickingRay: Nullable<Ray>;
  83907. /** @hidden */
  83908. _cachedRayForTransform: Ray;
  83909. /** @hidden */
  83910. _pickWithRayInverseMatrix: Matrix;
  83911. /** @hidden */
  83912. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83913. /** @hidden */
  83914. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83915. }
  83916. }
  83917. declare module BABYLON {
  83918. /**
  83919. * Groups all the scene component constants in one place to ease maintenance.
  83920. * @hidden
  83921. */
  83922. export class SceneComponentConstants {
  83923. static readonly NAME_EFFECTLAYER: string;
  83924. static readonly NAME_LAYER: string;
  83925. static readonly NAME_LENSFLARESYSTEM: string;
  83926. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83927. static readonly NAME_PARTICLESYSTEM: string;
  83928. static readonly NAME_GAMEPAD: string;
  83929. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83930. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83931. static readonly NAME_DEPTHRENDERER: string;
  83932. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83933. static readonly NAME_SPRITE: string;
  83934. static readonly NAME_OUTLINERENDERER: string;
  83935. static readonly NAME_PROCEDURALTEXTURE: string;
  83936. static readonly NAME_SHADOWGENERATOR: string;
  83937. static readonly NAME_OCTREE: string;
  83938. static readonly NAME_PHYSICSENGINE: string;
  83939. static readonly NAME_AUDIO: string;
  83940. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83941. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83942. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83943. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83944. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83945. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83946. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83947. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83948. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83949. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83950. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83951. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83952. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83953. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83954. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83955. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83956. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83957. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83958. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83959. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83960. static readonly STEP_AFTERRENDER_AUDIO: number;
  83961. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83962. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83963. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83964. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83965. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83966. static readonly STEP_POINTERMOVE_SPRITE: number;
  83967. static readonly STEP_POINTERDOWN_SPRITE: number;
  83968. static readonly STEP_POINTERUP_SPRITE: number;
  83969. }
  83970. /**
  83971. * This represents a scene component.
  83972. *
  83973. * This is used to decouple the dependency the scene is having on the different workloads like
  83974. * layers, post processes...
  83975. */
  83976. export interface ISceneComponent {
  83977. /**
  83978. * The name of the component. Each component must have a unique name.
  83979. */
  83980. name: string;
  83981. /**
  83982. * The scene the component belongs to.
  83983. */
  83984. scene: Scene;
  83985. /**
  83986. * Register the component to one instance of a scene.
  83987. */
  83988. register(): void;
  83989. /**
  83990. * Rebuilds the elements related to this component in case of
  83991. * context lost for instance.
  83992. */
  83993. rebuild(): void;
  83994. /**
  83995. * Disposes the component and the associated ressources.
  83996. */
  83997. dispose(): void;
  83998. }
  83999. /**
  84000. * This represents a SERIALIZABLE scene component.
  84001. *
  84002. * This extends Scene Component to add Serialization methods on top.
  84003. */
  84004. export interface ISceneSerializableComponent extends ISceneComponent {
  84005. /**
  84006. * Adds all the elements from the container to the scene
  84007. * @param container the container holding the elements
  84008. */
  84009. addFromContainer(container: AbstractScene): void;
  84010. /**
  84011. * Removes all the elements in the container from the scene
  84012. * @param container contains the elements to remove
  84013. * @param dispose if the removed element should be disposed (default: false)
  84014. */
  84015. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84016. /**
  84017. * Serializes the component data to the specified json object
  84018. * @param serializationObject The object to serialize to
  84019. */
  84020. serialize(serializationObject: any): void;
  84021. }
  84022. /**
  84023. * Strong typing of a Mesh related stage step action
  84024. */
  84025. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84026. /**
  84027. * Strong typing of a Evaluate Sub Mesh related stage step action
  84028. */
  84029. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84030. /**
  84031. * Strong typing of a Active Mesh related stage step action
  84032. */
  84033. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84034. /**
  84035. * Strong typing of a Camera related stage step action
  84036. */
  84037. export type CameraStageAction = (camera: Camera) => void;
  84038. /**
  84039. * Strong typing of a Camera Frame buffer related stage step action
  84040. */
  84041. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84042. /**
  84043. * Strong typing of a Render Target related stage step action
  84044. */
  84045. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84046. /**
  84047. * Strong typing of a RenderingGroup related stage step action
  84048. */
  84049. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84050. /**
  84051. * Strong typing of a Mesh Render related stage step action
  84052. */
  84053. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84054. /**
  84055. * Strong typing of a simple stage step action
  84056. */
  84057. export type SimpleStageAction = () => void;
  84058. /**
  84059. * Strong typing of a render target action.
  84060. */
  84061. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84062. /**
  84063. * Strong typing of a pointer move action.
  84064. */
  84065. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84066. /**
  84067. * Strong typing of a pointer up/down action.
  84068. */
  84069. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84070. /**
  84071. * Representation of a stage in the scene (Basically a list of ordered steps)
  84072. * @hidden
  84073. */
  84074. export class Stage<T extends Function> extends Array<{
  84075. index: number;
  84076. component: ISceneComponent;
  84077. action: T;
  84078. }> {
  84079. /**
  84080. * Hide ctor from the rest of the world.
  84081. * @param items The items to add.
  84082. */
  84083. private constructor();
  84084. /**
  84085. * Creates a new Stage.
  84086. * @returns A new instance of a Stage
  84087. */
  84088. static Create<T extends Function>(): Stage<T>;
  84089. /**
  84090. * Registers a step in an ordered way in the targeted stage.
  84091. * @param index Defines the position to register the step in
  84092. * @param component Defines the component attached to the step
  84093. * @param action Defines the action to launch during the step
  84094. */
  84095. registerStep(index: number, component: ISceneComponent, action: T): void;
  84096. /**
  84097. * Clears all the steps from the stage.
  84098. */
  84099. clear(): void;
  84100. }
  84101. }
  84102. declare module BABYLON {
  84103. interface Scene {
  84104. /** @hidden */
  84105. _pointerOverSprite: Nullable<Sprite>;
  84106. /** @hidden */
  84107. _pickedDownSprite: Nullable<Sprite>;
  84108. /** @hidden */
  84109. _tempSpritePickingRay: Nullable<Ray>;
  84110. /**
  84111. * All of the sprite managers added to this scene
  84112. * @see http://doc.babylonjs.com/babylon101/sprites
  84113. */
  84114. spriteManagers: Array<ISpriteManager>;
  84115. /**
  84116. * An event triggered when sprites rendering is about to start
  84117. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84118. */
  84119. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84120. /**
  84121. * An event triggered when sprites rendering is done
  84122. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84123. */
  84124. onAfterSpritesRenderingObservable: Observable<Scene>;
  84125. /** @hidden */
  84126. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84127. /** Launch a ray to try to pick a sprite in the scene
  84128. * @param x position on screen
  84129. * @param y position on screen
  84130. * @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
  84131. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84132. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84133. * @returns a PickingInfo
  84134. */
  84135. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84136. /** Use the given ray to pick a sprite in the scene
  84137. * @param ray The ray (in world space) to use to pick meshes
  84138. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  84139. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84140. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84141. * @returns a PickingInfo
  84142. */
  84143. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84144. /** @hidden */
  84145. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84146. /** Launch a ray to try to pick sprites in the scene
  84147. * @param x position on screen
  84148. * @param y position on screen
  84149. * @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
  84150. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84151. * @returns a PickingInfo array
  84152. */
  84153. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84154. /** Use the given ray to pick sprites in the scene
  84155. * @param ray The ray (in world space) to use to pick meshes
  84156. * @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
  84157. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84158. * @returns a PickingInfo array
  84159. */
  84160. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84161. /**
  84162. * Force the sprite under the pointer
  84163. * @param sprite defines the sprite to use
  84164. */
  84165. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84166. /**
  84167. * Gets the sprite under the pointer
  84168. * @returns a Sprite or null if no sprite is under the pointer
  84169. */
  84170. getPointerOverSprite(): Nullable<Sprite>;
  84171. }
  84172. /**
  84173. * Defines the sprite scene component responsible to manage sprites
  84174. * in a given scene.
  84175. */
  84176. export class SpriteSceneComponent implements ISceneComponent {
  84177. /**
  84178. * The component name helpfull to identify the component in the list of scene components.
  84179. */
  84180. readonly name: string;
  84181. /**
  84182. * The scene the component belongs to.
  84183. */
  84184. scene: Scene;
  84185. /** @hidden */
  84186. private _spritePredicate;
  84187. /**
  84188. * Creates a new instance of the component for the given scene
  84189. * @param scene Defines the scene to register the component in
  84190. */
  84191. constructor(scene: Scene);
  84192. /**
  84193. * Registers the component in a given scene
  84194. */
  84195. register(): void;
  84196. /**
  84197. * Rebuilds the elements related to this component in case of
  84198. * context lost for instance.
  84199. */
  84200. rebuild(): void;
  84201. /**
  84202. * Disposes the component and the associated ressources.
  84203. */
  84204. dispose(): void;
  84205. private _pickSpriteButKeepRay;
  84206. private _pointerMove;
  84207. private _pointerDown;
  84208. private _pointerUp;
  84209. }
  84210. }
  84211. declare module BABYLON {
  84212. /** @hidden */
  84213. export var fogFragmentDeclaration: {
  84214. name: string;
  84215. shader: string;
  84216. };
  84217. }
  84218. declare module BABYLON {
  84219. /** @hidden */
  84220. export var fogFragment: {
  84221. name: string;
  84222. shader: string;
  84223. };
  84224. }
  84225. declare module BABYLON {
  84226. /** @hidden */
  84227. export var spritesPixelShader: {
  84228. name: string;
  84229. shader: string;
  84230. };
  84231. }
  84232. declare module BABYLON {
  84233. /** @hidden */
  84234. export var fogVertexDeclaration: {
  84235. name: string;
  84236. shader: string;
  84237. };
  84238. }
  84239. declare module BABYLON {
  84240. /** @hidden */
  84241. export var spritesVertexShader: {
  84242. name: string;
  84243. shader: string;
  84244. };
  84245. }
  84246. declare module BABYLON {
  84247. /**
  84248. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84249. */
  84250. export interface ISpriteManager extends IDisposable {
  84251. /**
  84252. * Restricts the camera to viewing objects with the same layerMask.
  84253. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84254. */
  84255. layerMask: number;
  84256. /**
  84257. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84258. */
  84259. isPickable: boolean;
  84260. /**
  84261. * Specifies the rendering group id for this mesh (0 by default)
  84262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84263. */
  84264. renderingGroupId: number;
  84265. /**
  84266. * Defines the list of sprites managed by the manager.
  84267. */
  84268. sprites: Array<Sprite>;
  84269. /**
  84270. * Tests the intersection of a sprite with a specific ray.
  84271. * @param ray The ray we are sending to test the collision
  84272. * @param camera The camera space we are sending rays in
  84273. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84274. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84275. * @returns picking info or null.
  84276. */
  84277. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84278. /**
  84279. * Intersects the sprites with a ray
  84280. * @param ray defines the ray to intersect with
  84281. * @param camera defines the current active camera
  84282. * @param predicate defines a predicate used to select candidate sprites
  84283. * @returns null if no hit or a PickingInfo array
  84284. */
  84285. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84286. /**
  84287. * Renders the list of sprites on screen.
  84288. */
  84289. render(): void;
  84290. }
  84291. /**
  84292. * Class used to manage multiple sprites on the same spritesheet
  84293. * @see http://doc.babylonjs.com/babylon101/sprites
  84294. */
  84295. export class SpriteManager implements ISpriteManager {
  84296. /** defines the manager's name */
  84297. name: string;
  84298. /** Gets the list of sprites */
  84299. sprites: Sprite[];
  84300. /** Gets or sets the rendering group id (0 by default) */
  84301. renderingGroupId: number;
  84302. /** Gets or sets camera layer mask */
  84303. layerMask: number;
  84304. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84305. fogEnabled: boolean;
  84306. /** Gets or sets a boolean indicating if the sprites are pickable */
  84307. isPickable: boolean;
  84308. /** Defines the default width of a cell in the spritesheet */
  84309. cellWidth: number;
  84310. /** Defines the default height of a cell in the spritesheet */
  84311. cellHeight: number;
  84312. /** Associative array from JSON sprite data file */
  84313. private _cellData;
  84314. /** Array of sprite names from JSON sprite data file */
  84315. private _spriteMap;
  84316. /** True when packed cell data from JSON file is ready*/
  84317. private _packedAndReady;
  84318. /**
  84319. * An event triggered when the manager is disposed.
  84320. */
  84321. onDisposeObservable: Observable<SpriteManager>;
  84322. private _onDisposeObserver;
  84323. /**
  84324. * Callback called when the manager is disposed
  84325. */
  84326. set onDispose(callback: () => void);
  84327. private _capacity;
  84328. private _fromPacked;
  84329. private _spriteTexture;
  84330. private _epsilon;
  84331. private _scene;
  84332. private _vertexData;
  84333. private _buffer;
  84334. private _vertexBuffers;
  84335. private _indexBuffer;
  84336. private _effectBase;
  84337. private _effectFog;
  84338. /**
  84339. * Gets or sets the spritesheet texture
  84340. */
  84341. get texture(): Texture;
  84342. set texture(value: Texture);
  84343. private _blendMode;
  84344. /**
  84345. * Blend mode use to render the particle, it can be any of
  84346. * the static Constants.ALPHA_x properties provided in this class.
  84347. * Default value is Constants.ALPHA_COMBINE
  84348. */
  84349. get blendMode(): number;
  84350. set blendMode(blendMode: number);
  84351. /** Disables writing to the depth buffer when rendering the sprites.
  84352. * It can be handy to disable depth writing when using textures without alpha channel
  84353. * and setting some specific blend modes.
  84354. */
  84355. disableDepthWrite: boolean;
  84356. /**
  84357. * Creates a new sprite manager
  84358. * @param name defines the manager's name
  84359. * @param imgUrl defines the sprite sheet url
  84360. * @param capacity defines the maximum allowed number of sprites
  84361. * @param cellSize defines the size of a sprite cell
  84362. * @param scene defines the hosting scene
  84363. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84364. * @param samplingMode defines the smapling mode to use with spritesheet
  84365. * @param fromPacked set to false; do not alter
  84366. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84367. */
  84368. constructor(
  84369. /** defines the manager's name */
  84370. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84371. private _makePacked;
  84372. private _appendSpriteVertex;
  84373. /**
  84374. * Intersects the sprites with a ray
  84375. * @param ray defines the ray to intersect with
  84376. * @param camera defines the current active camera
  84377. * @param predicate defines a predicate used to select candidate sprites
  84378. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84379. * @returns null if no hit or a PickingInfo
  84380. */
  84381. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84382. /**
  84383. * Intersects the sprites with a ray
  84384. * @param ray defines the ray to intersect with
  84385. * @param camera defines the current active camera
  84386. * @param predicate defines a predicate used to select candidate sprites
  84387. * @returns null if no hit or a PickingInfo array
  84388. */
  84389. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84390. /**
  84391. * Render all child sprites
  84392. */
  84393. render(): void;
  84394. /**
  84395. * Release associated resources
  84396. */
  84397. dispose(): void;
  84398. }
  84399. }
  84400. declare module BABYLON {
  84401. /** Interface used by value gradients (color, factor, ...) */
  84402. export interface IValueGradient {
  84403. /**
  84404. * Gets or sets the gradient value (between 0 and 1)
  84405. */
  84406. gradient: number;
  84407. }
  84408. /** Class used to store color4 gradient */
  84409. export class ColorGradient implements IValueGradient {
  84410. /**
  84411. * Gets or sets the gradient value (between 0 and 1)
  84412. */
  84413. gradient: number;
  84414. /**
  84415. * Gets or sets first associated color
  84416. */
  84417. color1: Color4;
  84418. /**
  84419. * Gets or sets second associated color
  84420. */
  84421. color2?: Color4 | undefined;
  84422. /**
  84423. * Creates a new color4 gradient
  84424. * @param gradient gets or sets the gradient value (between 0 and 1)
  84425. * @param color1 gets or sets first associated color
  84426. * @param color2 gets or sets first second color
  84427. */
  84428. constructor(
  84429. /**
  84430. * Gets or sets the gradient value (between 0 and 1)
  84431. */
  84432. gradient: number,
  84433. /**
  84434. * Gets or sets first associated color
  84435. */
  84436. color1: Color4,
  84437. /**
  84438. * Gets or sets second associated color
  84439. */
  84440. color2?: Color4 | undefined);
  84441. /**
  84442. * Will get a color picked randomly between color1 and color2.
  84443. * If color2 is undefined then color1 will be used
  84444. * @param result defines the target Color4 to store the result in
  84445. */
  84446. getColorToRef(result: Color4): void;
  84447. }
  84448. /** Class used to store color 3 gradient */
  84449. export class Color3Gradient implements IValueGradient {
  84450. /**
  84451. * Gets or sets the gradient value (between 0 and 1)
  84452. */
  84453. gradient: number;
  84454. /**
  84455. * Gets or sets the associated color
  84456. */
  84457. color: Color3;
  84458. /**
  84459. * Creates a new color3 gradient
  84460. * @param gradient gets or sets the gradient value (between 0 and 1)
  84461. * @param color gets or sets associated color
  84462. */
  84463. constructor(
  84464. /**
  84465. * Gets or sets the gradient value (between 0 and 1)
  84466. */
  84467. gradient: number,
  84468. /**
  84469. * Gets or sets the associated color
  84470. */
  84471. color: Color3);
  84472. }
  84473. /** Class used to store factor gradient */
  84474. export class FactorGradient implements IValueGradient {
  84475. /**
  84476. * Gets or sets the gradient value (between 0 and 1)
  84477. */
  84478. gradient: number;
  84479. /**
  84480. * Gets or sets first associated factor
  84481. */
  84482. factor1: number;
  84483. /**
  84484. * Gets or sets second associated factor
  84485. */
  84486. factor2?: number | undefined;
  84487. /**
  84488. * Creates a new factor gradient
  84489. * @param gradient gets or sets the gradient value (between 0 and 1)
  84490. * @param factor1 gets or sets first associated factor
  84491. * @param factor2 gets or sets second associated factor
  84492. */
  84493. constructor(
  84494. /**
  84495. * Gets or sets the gradient value (between 0 and 1)
  84496. */
  84497. gradient: number,
  84498. /**
  84499. * Gets or sets first associated factor
  84500. */
  84501. factor1: number,
  84502. /**
  84503. * Gets or sets second associated factor
  84504. */
  84505. factor2?: number | undefined);
  84506. /**
  84507. * Will get a number picked randomly between factor1 and factor2.
  84508. * If factor2 is undefined then factor1 will be used
  84509. * @returns the picked number
  84510. */
  84511. getFactor(): number;
  84512. }
  84513. /**
  84514. * Helper used to simplify some generic gradient tasks
  84515. */
  84516. export class GradientHelper {
  84517. /**
  84518. * Gets the current gradient from an array of IValueGradient
  84519. * @param ratio defines the current ratio to get
  84520. * @param gradients defines the array of IValueGradient
  84521. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84522. */
  84523. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84524. }
  84525. }
  84526. declare module BABYLON {
  84527. /**
  84528. * Interface for the size containing width and height
  84529. */
  84530. export interface ISize {
  84531. /**
  84532. * Width
  84533. */
  84534. width: number;
  84535. /**
  84536. * Heighht
  84537. */
  84538. height: number;
  84539. }
  84540. /**
  84541. * Size containing widht and height
  84542. */
  84543. export class Size implements ISize {
  84544. /**
  84545. * Width
  84546. */
  84547. width: number;
  84548. /**
  84549. * Height
  84550. */
  84551. height: number;
  84552. /**
  84553. * Creates a Size object from the given width and height (floats).
  84554. * @param width width of the new size
  84555. * @param height height of the new size
  84556. */
  84557. constructor(width: number, height: number);
  84558. /**
  84559. * Returns a string with the Size width and height
  84560. * @returns a string with the Size width and height
  84561. */
  84562. toString(): string;
  84563. /**
  84564. * "Size"
  84565. * @returns the string "Size"
  84566. */
  84567. getClassName(): string;
  84568. /**
  84569. * Returns the Size hash code.
  84570. * @returns a hash code for a unique width and height
  84571. */
  84572. getHashCode(): number;
  84573. /**
  84574. * Updates the current size from the given one.
  84575. * @param src the given size
  84576. */
  84577. copyFrom(src: Size): void;
  84578. /**
  84579. * Updates in place the current Size from the given floats.
  84580. * @param width width of the new size
  84581. * @param height height of the new size
  84582. * @returns the updated Size.
  84583. */
  84584. copyFromFloats(width: number, height: number): Size;
  84585. /**
  84586. * Updates in place the current Size from the given floats.
  84587. * @param width width to set
  84588. * @param height height to set
  84589. * @returns the updated Size.
  84590. */
  84591. set(width: number, height: number): Size;
  84592. /**
  84593. * Multiplies the width and height by numbers
  84594. * @param w factor to multiple the width by
  84595. * @param h factor to multiple the height by
  84596. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84597. */
  84598. multiplyByFloats(w: number, h: number): Size;
  84599. /**
  84600. * Clones the size
  84601. * @returns a new Size copied from the given one.
  84602. */
  84603. clone(): Size;
  84604. /**
  84605. * True if the current Size and the given one width and height are strictly equal.
  84606. * @param other the other size to compare against
  84607. * @returns True if the current Size and the given one width and height are strictly equal.
  84608. */
  84609. equals(other: Size): boolean;
  84610. /**
  84611. * The surface of the Size : width * height (float).
  84612. */
  84613. get surface(): number;
  84614. /**
  84615. * Create a new size of zero
  84616. * @returns a new Size set to (0.0, 0.0)
  84617. */
  84618. static Zero(): Size;
  84619. /**
  84620. * Sums the width and height of two sizes
  84621. * @param otherSize size to add to this size
  84622. * @returns a new Size set as the addition result of the current Size and the given one.
  84623. */
  84624. add(otherSize: Size): Size;
  84625. /**
  84626. * Subtracts the width and height of two
  84627. * @param otherSize size to subtract to this size
  84628. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84629. */
  84630. subtract(otherSize: Size): Size;
  84631. /**
  84632. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84633. * @param start starting size to lerp between
  84634. * @param end end size to lerp between
  84635. * @param amount amount to lerp between the start and end values
  84636. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84637. */
  84638. static Lerp(start: Size, end: Size, amount: number): Size;
  84639. }
  84640. }
  84641. declare module BABYLON {
  84642. interface ThinEngine {
  84643. /**
  84644. * Creates a dynamic texture
  84645. * @param width defines the width of the texture
  84646. * @param height defines the height of the texture
  84647. * @param generateMipMaps defines if the engine should generate the mip levels
  84648. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84649. * @returns the dynamic texture inside an InternalTexture
  84650. */
  84651. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84652. /**
  84653. * Update the content of a dynamic texture
  84654. * @param texture defines the texture to update
  84655. * @param canvas defines the canvas containing the source
  84656. * @param invertY defines if data must be stored with Y axis inverted
  84657. * @param premulAlpha defines if alpha is stored as premultiplied
  84658. * @param format defines the format of the data
  84659. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84660. */
  84661. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84662. }
  84663. }
  84664. declare module BABYLON {
  84665. /**
  84666. * Helper class used to generate a canvas to manipulate images
  84667. */
  84668. export class CanvasGenerator {
  84669. /**
  84670. * Create a new canvas (or offscreen canvas depending on the context)
  84671. * @param width defines the expected width
  84672. * @param height defines the expected height
  84673. * @return a new canvas or offscreen canvas
  84674. */
  84675. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84676. }
  84677. }
  84678. declare module BABYLON {
  84679. /**
  84680. * A class extending Texture allowing drawing on a texture
  84681. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84682. */
  84683. export class DynamicTexture extends Texture {
  84684. private _generateMipMaps;
  84685. private _canvas;
  84686. private _context;
  84687. private _engine;
  84688. /**
  84689. * Creates a DynamicTexture
  84690. * @param name defines the name of the texture
  84691. * @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
  84692. * @param scene defines the scene where you want the texture
  84693. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84694. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84695. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84696. */
  84697. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84698. /**
  84699. * Get the current class name of the texture useful for serialization or dynamic coding.
  84700. * @returns "DynamicTexture"
  84701. */
  84702. getClassName(): string;
  84703. /**
  84704. * Gets the current state of canRescale
  84705. */
  84706. get canRescale(): boolean;
  84707. private _recreate;
  84708. /**
  84709. * Scales the texture
  84710. * @param ratio the scale factor to apply to both width and height
  84711. */
  84712. scale(ratio: number): void;
  84713. /**
  84714. * Resizes the texture
  84715. * @param width the new width
  84716. * @param height the new height
  84717. */
  84718. scaleTo(width: number, height: number): void;
  84719. /**
  84720. * Gets the context of the canvas used by the texture
  84721. * @returns the canvas context of the dynamic texture
  84722. */
  84723. getContext(): CanvasRenderingContext2D;
  84724. /**
  84725. * Clears the texture
  84726. */
  84727. clear(): void;
  84728. /**
  84729. * Updates the texture
  84730. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84731. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84732. */
  84733. update(invertY?: boolean, premulAlpha?: boolean): void;
  84734. /**
  84735. * Draws text onto the texture
  84736. * @param text defines the text to be drawn
  84737. * @param x defines the placement of the text from the left
  84738. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84739. * @param font defines the font to be used with font-style, font-size, font-name
  84740. * @param color defines the color used for the text
  84741. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84742. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84743. * @param update defines whether texture is immediately update (default is true)
  84744. */
  84745. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  84746. /**
  84747. * Clones the texture
  84748. * @returns the clone of the texture.
  84749. */
  84750. clone(): DynamicTexture;
  84751. /**
  84752. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84753. * @returns a serialized dynamic texture object
  84754. */
  84755. serialize(): any;
  84756. /** @hidden */
  84757. _rebuild(): void;
  84758. }
  84759. }
  84760. declare module BABYLON {
  84761. interface Engine {
  84762. /**
  84763. * Creates a raw texture
  84764. * @param data defines the data to store in the texture
  84765. * @param width defines the width of the texture
  84766. * @param height defines the height of the texture
  84767. * @param format defines the format of the data
  84768. * @param generateMipMaps defines if the engine should generate the mip levels
  84769. * @param invertY defines if data must be stored with Y axis inverted
  84770. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84771. * @param compression defines the compression used (null by default)
  84772. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84773. * @returns the raw texture inside an InternalTexture
  84774. */
  84775. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84776. /**
  84777. * Update a raw texture
  84778. * @param texture defines the texture to update
  84779. * @param data defines the data to store in the texture
  84780. * @param format defines the format of the data
  84781. * @param invertY defines if data must be stored with Y axis inverted
  84782. */
  84783. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84784. /**
  84785. * Update a raw texture
  84786. * @param texture defines the texture to update
  84787. * @param data defines the data to store in the texture
  84788. * @param format defines the format of the data
  84789. * @param invertY defines if data must be stored with Y axis inverted
  84790. * @param compression defines the compression used (null by default)
  84791. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84792. */
  84793. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84794. /**
  84795. * Creates a new raw cube texture
  84796. * @param data defines the array of data to use to create each face
  84797. * @param size defines the size of the textures
  84798. * @param format defines the format of the data
  84799. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84800. * @param generateMipMaps defines if the engine should generate the mip levels
  84801. * @param invertY defines if data must be stored with Y axis inverted
  84802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84803. * @param compression defines the compression used (null by default)
  84804. * @returns the cube texture as an InternalTexture
  84805. */
  84806. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84807. /**
  84808. * Update a raw cube texture
  84809. * @param texture defines the texture to udpdate
  84810. * @param data defines the data to store
  84811. * @param format defines the data format
  84812. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84813. * @param invertY defines if data must be stored with Y axis inverted
  84814. */
  84815. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84816. /**
  84817. * Update a raw cube texture
  84818. * @param texture defines the texture to udpdate
  84819. * @param data defines the data to store
  84820. * @param format defines the data format
  84821. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84822. * @param invertY defines if data must be stored with Y axis inverted
  84823. * @param compression defines the compression used (null by default)
  84824. */
  84825. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84826. /**
  84827. * Update a raw cube texture
  84828. * @param texture defines the texture to udpdate
  84829. * @param data defines the data to store
  84830. * @param format defines the data format
  84831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84832. * @param invertY defines if data must be stored with Y axis inverted
  84833. * @param compression defines the compression used (null by default)
  84834. * @param level defines which level of the texture to update
  84835. */
  84836. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84837. /**
  84838. * Creates a new raw cube texture from a specified url
  84839. * @param url defines the url where the data is located
  84840. * @param scene defines the current scene
  84841. * @param size defines the size of the textures
  84842. * @param format defines the format of the data
  84843. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84844. * @param noMipmap defines if the engine should avoid generating the mip levels
  84845. * @param callback defines a callback used to extract texture data from loaded data
  84846. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84847. * @param onLoad defines a callback called when texture is loaded
  84848. * @param onError defines a callback called if there is an error
  84849. * @returns the cube texture as an InternalTexture
  84850. */
  84851. 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;
  84852. /**
  84853. * Creates a new raw cube texture from a specified url
  84854. * @param url defines the url where the data is located
  84855. * @param scene defines the current scene
  84856. * @param size defines the size of the textures
  84857. * @param format defines the format of the data
  84858. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84859. * @param noMipmap defines if the engine should avoid generating the mip levels
  84860. * @param callback defines a callback used to extract texture data from loaded data
  84861. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84862. * @param onLoad defines a callback called when texture is loaded
  84863. * @param onError defines a callback called if there is an error
  84864. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84865. * @param invertY defines if data must be stored with Y axis inverted
  84866. * @returns the cube texture as an InternalTexture
  84867. */
  84868. 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;
  84869. /**
  84870. * Creates a new raw 3D texture
  84871. * @param data defines the data used to create the texture
  84872. * @param width defines the width of the texture
  84873. * @param height defines the height of the texture
  84874. * @param depth defines the depth of the texture
  84875. * @param format defines the format of the texture
  84876. * @param generateMipMaps defines if the engine must generate mip levels
  84877. * @param invertY defines if data must be stored with Y axis inverted
  84878. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84879. * @param compression defines the compressed used (can be null)
  84880. * @param textureType defines the compressed used (can be null)
  84881. * @returns a new raw 3D texture (stored in an InternalTexture)
  84882. */
  84883. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84884. /**
  84885. * Update a raw 3D texture
  84886. * @param texture defines the texture to update
  84887. * @param data defines the data to store
  84888. * @param format defines the data format
  84889. * @param invertY defines if data must be stored with Y axis inverted
  84890. */
  84891. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84892. /**
  84893. * Update a raw 3D texture
  84894. * @param texture defines the texture to update
  84895. * @param data defines the data to store
  84896. * @param format defines the data format
  84897. * @param invertY defines if data must be stored with Y axis inverted
  84898. * @param compression defines the used compression (can be null)
  84899. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84900. */
  84901. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84902. /**
  84903. * Creates a new raw 2D array texture
  84904. * @param data defines the data used to create the texture
  84905. * @param width defines the width of the texture
  84906. * @param height defines the height of the texture
  84907. * @param depth defines the number of layers of the texture
  84908. * @param format defines the format of the texture
  84909. * @param generateMipMaps defines if the engine must generate mip levels
  84910. * @param invertY defines if data must be stored with Y axis inverted
  84911. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84912. * @param compression defines the compressed used (can be null)
  84913. * @param textureType defines the compressed used (can be null)
  84914. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84915. */
  84916. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84917. /**
  84918. * Update a raw 2D array texture
  84919. * @param texture defines the texture to update
  84920. * @param data defines the data to store
  84921. * @param format defines the data format
  84922. * @param invertY defines if data must be stored with Y axis inverted
  84923. */
  84924. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84925. /**
  84926. * Update a raw 2D array texture
  84927. * @param texture defines the texture to update
  84928. * @param data defines the data to store
  84929. * @param format defines the data format
  84930. * @param invertY defines if data must be stored with Y axis inverted
  84931. * @param compression defines the used compression (can be null)
  84932. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84933. */
  84934. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84935. }
  84936. }
  84937. declare module BABYLON {
  84938. /**
  84939. * Raw texture can help creating a texture directly from an array of data.
  84940. * This can be super useful if you either get the data from an uncompressed source or
  84941. * if you wish to create your texture pixel by pixel.
  84942. */
  84943. export class RawTexture extends Texture {
  84944. /**
  84945. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84946. */
  84947. format: number;
  84948. private _engine;
  84949. /**
  84950. * Instantiates a new RawTexture.
  84951. * Raw texture can help creating a texture directly from an array of data.
  84952. * This can be super useful if you either get the data from an uncompressed source or
  84953. * if you wish to create your texture pixel by pixel.
  84954. * @param data define the array of data to use to create the texture
  84955. * @param width define the width of the texture
  84956. * @param height define the height of the texture
  84957. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84958. * @param scene define the scene the texture belongs to
  84959. * @param generateMipMaps define whether mip maps should be generated or not
  84960. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84961. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84962. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84963. */
  84964. constructor(data: ArrayBufferView, width: number, height: number,
  84965. /**
  84966. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84967. */
  84968. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84969. /**
  84970. * Updates the texture underlying data.
  84971. * @param data Define the new data of the texture
  84972. */
  84973. update(data: ArrayBufferView): void;
  84974. /**
  84975. * Creates a luminance texture from some data.
  84976. * @param data Define the texture data
  84977. * @param width Define the width of the texture
  84978. * @param height Define the height of the texture
  84979. * @param scene Define the scene the texture belongs to
  84980. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84981. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84982. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84983. * @returns the luminance texture
  84984. */
  84985. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84986. /**
  84987. * Creates a luminance alpha texture from some data.
  84988. * @param data Define the texture data
  84989. * @param width Define the width of the texture
  84990. * @param height Define the height of the texture
  84991. * @param scene Define the scene the texture belongs to
  84992. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84993. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84994. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84995. * @returns the luminance alpha texture
  84996. */
  84997. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84998. /**
  84999. * Creates an alpha texture from some data.
  85000. * @param data Define the texture data
  85001. * @param width Define the width of the texture
  85002. * @param height Define the height of the texture
  85003. * @param scene Define the scene the texture belongs to
  85004. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85007. * @returns the alpha texture
  85008. */
  85009. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85010. /**
  85011. * Creates a RGB texture from some data.
  85012. * @param data Define the texture data
  85013. * @param width Define the width of the texture
  85014. * @param height Define the height of the texture
  85015. * @param scene Define the scene the texture belongs to
  85016. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85017. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85018. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85019. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85020. * @returns the RGB alpha texture
  85021. */
  85022. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85023. /**
  85024. * Creates a RGBA texture from some data.
  85025. * @param data Define the texture data
  85026. * @param width Define the width of the texture
  85027. * @param height Define the height of the texture
  85028. * @param scene Define the scene the texture belongs to
  85029. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85030. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85031. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85032. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85033. * @returns the RGBA texture
  85034. */
  85035. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85036. /**
  85037. * Creates a R texture from some data.
  85038. * @param data Define the texture data
  85039. * @param width Define the width of the texture
  85040. * @param height Define the height of the texture
  85041. * @param scene Define the scene the texture belongs to
  85042. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85043. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85044. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85045. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85046. * @returns the R texture
  85047. */
  85048. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85049. }
  85050. }
  85051. declare module BABYLON {
  85052. interface AbstractScene {
  85053. /**
  85054. * The list of procedural textures added to the scene
  85055. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85056. */
  85057. proceduralTextures: Array<ProceduralTexture>;
  85058. }
  85059. /**
  85060. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85061. * in a given scene.
  85062. */
  85063. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85064. /**
  85065. * The component name helpfull to identify the component in the list of scene components.
  85066. */
  85067. readonly name: string;
  85068. /**
  85069. * The scene the component belongs to.
  85070. */
  85071. scene: Scene;
  85072. /**
  85073. * Creates a new instance of the component for the given scene
  85074. * @param scene Defines the scene to register the component in
  85075. */
  85076. constructor(scene: Scene);
  85077. /**
  85078. * Registers the component in a given scene
  85079. */
  85080. register(): void;
  85081. /**
  85082. * Rebuilds the elements related to this component in case of
  85083. * context lost for instance.
  85084. */
  85085. rebuild(): void;
  85086. /**
  85087. * Disposes the component and the associated ressources.
  85088. */
  85089. dispose(): void;
  85090. private _beforeClear;
  85091. }
  85092. }
  85093. declare module BABYLON {
  85094. interface ThinEngine {
  85095. /**
  85096. * Creates a new render target cube texture
  85097. * @param size defines the size of the texture
  85098. * @param options defines the options used to create the texture
  85099. * @returns a new render target cube texture stored in an InternalTexture
  85100. */
  85101. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85102. }
  85103. }
  85104. declare module BABYLON {
  85105. /** @hidden */
  85106. export var proceduralVertexShader: {
  85107. name: string;
  85108. shader: string;
  85109. };
  85110. }
  85111. declare module BABYLON {
  85112. /**
  85113. * 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.
  85114. * This is the base class of any Procedural texture and contains most of the shareable code.
  85115. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85116. */
  85117. export class ProceduralTexture extends Texture {
  85118. isCube: boolean;
  85119. /**
  85120. * Define if the texture is enabled or not (disabled texture will not render)
  85121. */
  85122. isEnabled: boolean;
  85123. /**
  85124. * Define if the texture must be cleared before rendering (default is true)
  85125. */
  85126. autoClear: boolean;
  85127. /**
  85128. * Callback called when the texture is generated
  85129. */
  85130. onGenerated: () => void;
  85131. /**
  85132. * Event raised when the texture is generated
  85133. */
  85134. onGeneratedObservable: Observable<ProceduralTexture>;
  85135. /** @hidden */
  85136. _generateMipMaps: boolean;
  85137. /** @hidden **/
  85138. _effect: Effect;
  85139. /** @hidden */
  85140. _textures: {
  85141. [key: string]: Texture;
  85142. };
  85143. /** @hidden */
  85144. protected _fallbackTexture: Nullable<Texture>;
  85145. private _size;
  85146. private _currentRefreshId;
  85147. private _frameId;
  85148. private _refreshRate;
  85149. private _vertexBuffers;
  85150. private _indexBuffer;
  85151. private _uniforms;
  85152. private _samplers;
  85153. private _fragment;
  85154. private _floats;
  85155. private _ints;
  85156. private _floatsArrays;
  85157. private _colors3;
  85158. private _colors4;
  85159. private _vectors2;
  85160. private _vectors3;
  85161. private _matrices;
  85162. private _fallbackTextureUsed;
  85163. private _engine;
  85164. private _cachedDefines;
  85165. private _contentUpdateId;
  85166. private _contentData;
  85167. /**
  85168. * Instantiates a new procedural texture.
  85169. * 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.
  85170. * This is the base class of any Procedural texture and contains most of the shareable code.
  85171. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85172. * @param name Define the name of the texture
  85173. * @param size Define the size of the texture to create
  85174. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85175. * @param scene Define the scene the texture belongs to
  85176. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85177. * @param generateMipMaps Define if the texture should creates mip maps or not
  85178. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85179. */
  85180. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85181. /**
  85182. * The effect that is created when initializing the post process.
  85183. * @returns The created effect corresponding the the postprocess.
  85184. */
  85185. getEffect(): Effect;
  85186. /**
  85187. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85188. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85189. */
  85190. getContent(): Nullable<ArrayBufferView>;
  85191. private _createIndexBuffer;
  85192. /** @hidden */
  85193. _rebuild(): void;
  85194. /**
  85195. * Resets the texture in order to recreate its associated resources.
  85196. * This can be called in case of context loss
  85197. */
  85198. reset(): void;
  85199. protected _getDefines(): string;
  85200. /**
  85201. * Is the texture ready to be used ? (rendered at least once)
  85202. * @returns true if ready, otherwise, false.
  85203. */
  85204. isReady(): boolean;
  85205. /**
  85206. * Resets the refresh counter of the texture and start bak from scratch.
  85207. * Could be useful to regenerate the texture if it is setup to render only once.
  85208. */
  85209. resetRefreshCounter(): void;
  85210. /**
  85211. * Set the fragment shader to use in order to render the texture.
  85212. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85213. */
  85214. setFragment(fragment: any): void;
  85215. /**
  85216. * Define the refresh rate of the texture or the rendering frequency.
  85217. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85218. */
  85219. get refreshRate(): number;
  85220. set refreshRate(value: number);
  85221. /** @hidden */
  85222. _shouldRender(): boolean;
  85223. /**
  85224. * Get the size the texture is rendering at.
  85225. * @returns the size (texture is always squared)
  85226. */
  85227. getRenderSize(): number;
  85228. /**
  85229. * Resize the texture to new value.
  85230. * @param size Define the new size the texture should have
  85231. * @param generateMipMaps Define whether the new texture should create mip maps
  85232. */
  85233. resize(size: number, generateMipMaps: boolean): void;
  85234. private _checkUniform;
  85235. /**
  85236. * Set a texture in the shader program used to render.
  85237. * @param name Define the name of the uniform samplers as defined in the shader
  85238. * @param texture Define the texture to bind to this sampler
  85239. * @return the texture itself allowing "fluent" like uniform updates
  85240. */
  85241. setTexture(name: string, texture: Texture): ProceduralTexture;
  85242. /**
  85243. * Set a float in the shader.
  85244. * @param name Define the name of the uniform as defined in the shader
  85245. * @param value Define the value to give to the uniform
  85246. * @return the texture itself allowing "fluent" like uniform updates
  85247. */
  85248. setFloat(name: string, value: number): ProceduralTexture;
  85249. /**
  85250. * Set a int in the shader.
  85251. * @param name Define the name of the uniform as defined in the shader
  85252. * @param value Define the value to give to the uniform
  85253. * @return the texture itself allowing "fluent" like uniform updates
  85254. */
  85255. setInt(name: string, value: number): ProceduralTexture;
  85256. /**
  85257. * Set an array of floats in the shader.
  85258. * @param name Define the name of the uniform as defined in the shader
  85259. * @param value Define the value to give to the uniform
  85260. * @return the texture itself allowing "fluent" like uniform updates
  85261. */
  85262. setFloats(name: string, value: number[]): ProceduralTexture;
  85263. /**
  85264. * Set a vec3 in the shader from a Color3.
  85265. * @param name Define the name of the uniform as defined in the shader
  85266. * @param value Define the value to give to the uniform
  85267. * @return the texture itself allowing "fluent" like uniform updates
  85268. */
  85269. setColor3(name: string, value: Color3): ProceduralTexture;
  85270. /**
  85271. * Set a vec4 in the shader from a Color4.
  85272. * @param name Define the name of the uniform as defined in the shader
  85273. * @param value Define the value to give to the uniform
  85274. * @return the texture itself allowing "fluent" like uniform updates
  85275. */
  85276. setColor4(name: string, value: Color4): ProceduralTexture;
  85277. /**
  85278. * Set a vec2 in the shader from a Vector2.
  85279. * @param name Define the name of the uniform as defined in the shader
  85280. * @param value Define the value to give to the uniform
  85281. * @return the texture itself allowing "fluent" like uniform updates
  85282. */
  85283. setVector2(name: string, value: Vector2): ProceduralTexture;
  85284. /**
  85285. * Set a vec3 in the shader from a Vector3.
  85286. * @param name Define the name of the uniform as defined in the shader
  85287. * @param value Define the value to give to the uniform
  85288. * @return the texture itself allowing "fluent" like uniform updates
  85289. */
  85290. setVector3(name: string, value: Vector3): ProceduralTexture;
  85291. /**
  85292. * Set a mat4 in the shader from a MAtrix.
  85293. * @param name Define the name of the uniform as defined in the shader
  85294. * @param value Define the value to give to the uniform
  85295. * @return the texture itself allowing "fluent" like uniform updates
  85296. */
  85297. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85298. /**
  85299. * Render the texture to its associated render target.
  85300. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85301. */
  85302. render(useCameraPostProcess?: boolean): void;
  85303. /**
  85304. * Clone the texture.
  85305. * @returns the cloned texture
  85306. */
  85307. clone(): ProceduralTexture;
  85308. /**
  85309. * Dispose the texture and release its asoociated resources.
  85310. */
  85311. dispose(): void;
  85312. }
  85313. }
  85314. declare module BABYLON {
  85315. /**
  85316. * This represents the base class for particle system in Babylon.
  85317. * 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.
  85318. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85319. * @example https://doc.babylonjs.com/babylon101/particles
  85320. */
  85321. export class BaseParticleSystem {
  85322. /**
  85323. * Source color is added to the destination color without alpha affecting the result
  85324. */
  85325. static BLENDMODE_ONEONE: number;
  85326. /**
  85327. * Blend current color and particle color using particle’s alpha
  85328. */
  85329. static BLENDMODE_STANDARD: number;
  85330. /**
  85331. * Add current color and particle color multiplied by particle’s alpha
  85332. */
  85333. static BLENDMODE_ADD: number;
  85334. /**
  85335. * Multiply current color with particle color
  85336. */
  85337. static BLENDMODE_MULTIPLY: number;
  85338. /**
  85339. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85340. */
  85341. static BLENDMODE_MULTIPLYADD: number;
  85342. /**
  85343. * List of animations used by the particle system.
  85344. */
  85345. animations: Animation[];
  85346. /**
  85347. * Gets or sets the unique id of the particle system
  85348. */
  85349. uniqueId: number;
  85350. /**
  85351. * The id of the Particle system.
  85352. */
  85353. id: string;
  85354. /**
  85355. * The friendly name of the Particle system.
  85356. */
  85357. name: string;
  85358. /**
  85359. * Snippet ID if the particle system was created from the snippet server
  85360. */
  85361. snippetId: string;
  85362. /**
  85363. * The rendering group used by the Particle system to chose when to render.
  85364. */
  85365. renderingGroupId: number;
  85366. /**
  85367. * The emitter represents the Mesh or position we are attaching the particle system to.
  85368. */
  85369. emitter: Nullable<AbstractMesh | Vector3>;
  85370. /**
  85371. * The maximum number of particles to emit per frame
  85372. */
  85373. emitRate: number;
  85374. /**
  85375. * If you want to launch only a few particles at once, that can be done, as well.
  85376. */
  85377. manualEmitCount: number;
  85378. /**
  85379. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85380. */
  85381. updateSpeed: number;
  85382. /**
  85383. * The amount of time the particle system is running (depends of the overall update speed).
  85384. */
  85385. targetStopDuration: number;
  85386. /**
  85387. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85388. */
  85389. disposeOnStop: boolean;
  85390. /**
  85391. * Minimum power of emitting particles.
  85392. */
  85393. minEmitPower: number;
  85394. /**
  85395. * Maximum power of emitting particles.
  85396. */
  85397. maxEmitPower: number;
  85398. /**
  85399. * Minimum life time of emitting particles.
  85400. */
  85401. minLifeTime: number;
  85402. /**
  85403. * Maximum life time of emitting particles.
  85404. */
  85405. maxLifeTime: number;
  85406. /**
  85407. * Minimum Size of emitting particles.
  85408. */
  85409. minSize: number;
  85410. /**
  85411. * Maximum Size of emitting particles.
  85412. */
  85413. maxSize: number;
  85414. /**
  85415. * Minimum scale of emitting particles on X axis.
  85416. */
  85417. minScaleX: number;
  85418. /**
  85419. * Maximum scale of emitting particles on X axis.
  85420. */
  85421. maxScaleX: number;
  85422. /**
  85423. * Minimum scale of emitting particles on Y axis.
  85424. */
  85425. minScaleY: number;
  85426. /**
  85427. * Maximum scale of emitting particles on Y axis.
  85428. */
  85429. maxScaleY: number;
  85430. /**
  85431. * Gets or sets the minimal initial rotation in radians.
  85432. */
  85433. minInitialRotation: number;
  85434. /**
  85435. * Gets or sets the maximal initial rotation in radians.
  85436. */
  85437. maxInitialRotation: number;
  85438. /**
  85439. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85440. */
  85441. minAngularSpeed: number;
  85442. /**
  85443. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85444. */
  85445. maxAngularSpeed: number;
  85446. /**
  85447. * The texture used to render each particle. (this can be a spritesheet)
  85448. */
  85449. particleTexture: Nullable<Texture>;
  85450. /**
  85451. * The layer mask we are rendering the particles through.
  85452. */
  85453. layerMask: number;
  85454. /**
  85455. * This can help using your own shader to render the particle system.
  85456. * The according effect will be created
  85457. */
  85458. customShader: any;
  85459. /**
  85460. * By default particle system starts as soon as they are created. This prevents the
  85461. * automatic start to happen and let you decide when to start emitting particles.
  85462. */
  85463. preventAutoStart: boolean;
  85464. private _noiseTexture;
  85465. /**
  85466. * Gets or sets a texture used to add random noise to particle positions
  85467. */
  85468. get noiseTexture(): Nullable<ProceduralTexture>;
  85469. set noiseTexture(value: Nullable<ProceduralTexture>);
  85470. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85471. noiseStrength: Vector3;
  85472. /**
  85473. * Callback triggered when the particle animation is ending.
  85474. */
  85475. onAnimationEnd: Nullable<() => void>;
  85476. /**
  85477. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85478. */
  85479. blendMode: number;
  85480. /**
  85481. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85482. * to override the particles.
  85483. */
  85484. forceDepthWrite: boolean;
  85485. /** 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 */
  85486. preWarmCycles: number;
  85487. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85488. preWarmStepOffset: number;
  85489. /**
  85490. * 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)
  85491. */
  85492. spriteCellChangeSpeed: number;
  85493. /**
  85494. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85495. */
  85496. startSpriteCellID: number;
  85497. /**
  85498. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85499. */
  85500. endSpriteCellID: number;
  85501. /**
  85502. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85503. */
  85504. spriteCellWidth: number;
  85505. /**
  85506. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85507. */
  85508. spriteCellHeight: number;
  85509. /**
  85510. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85511. */
  85512. spriteRandomStartCell: boolean;
  85513. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85514. translationPivot: Vector2;
  85515. /** @hidden */
  85516. protected _isAnimationSheetEnabled: boolean;
  85517. /**
  85518. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85519. */
  85520. beginAnimationOnStart: boolean;
  85521. /**
  85522. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85523. */
  85524. beginAnimationFrom: number;
  85525. /**
  85526. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85527. */
  85528. beginAnimationTo: number;
  85529. /**
  85530. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85531. */
  85532. beginAnimationLoop: boolean;
  85533. /**
  85534. * Gets or sets a world offset applied to all particles
  85535. */
  85536. worldOffset: Vector3;
  85537. /**
  85538. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85539. */
  85540. get isAnimationSheetEnabled(): boolean;
  85541. set isAnimationSheetEnabled(value: boolean);
  85542. /**
  85543. * Get hosting scene
  85544. * @returns the scene
  85545. */
  85546. getScene(): Scene;
  85547. /**
  85548. * You can use gravity if you want to give an orientation to your particles.
  85549. */
  85550. gravity: Vector3;
  85551. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85552. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85553. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85554. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85555. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85556. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85557. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85558. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85559. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85560. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85561. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85562. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85563. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85564. /**
  85565. * Defines the delay in milliseconds before starting the system (0 by default)
  85566. */
  85567. startDelay: number;
  85568. /**
  85569. * Gets the current list of drag gradients.
  85570. * You must use addDragGradient and removeDragGradient to udpate this list
  85571. * @returns the list of drag gradients
  85572. */
  85573. getDragGradients(): Nullable<Array<FactorGradient>>;
  85574. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85575. limitVelocityDamping: number;
  85576. /**
  85577. * Gets the current list of limit velocity gradients.
  85578. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85579. * @returns the list of limit velocity gradients
  85580. */
  85581. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85582. /**
  85583. * Gets the current list of color gradients.
  85584. * You must use addColorGradient and removeColorGradient to udpate this list
  85585. * @returns the list of color gradients
  85586. */
  85587. getColorGradients(): Nullable<Array<ColorGradient>>;
  85588. /**
  85589. * Gets the current list of size gradients.
  85590. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85591. * @returns the list of size gradients
  85592. */
  85593. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85594. /**
  85595. * Gets the current list of color remap gradients.
  85596. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85597. * @returns the list of color remap gradients
  85598. */
  85599. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85600. /**
  85601. * Gets the current list of alpha remap gradients.
  85602. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85603. * @returns the list of alpha remap gradients
  85604. */
  85605. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85606. /**
  85607. * Gets the current list of life time gradients.
  85608. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85609. * @returns the list of life time gradients
  85610. */
  85611. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85612. /**
  85613. * Gets the current list of angular speed gradients.
  85614. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85615. * @returns the list of angular speed gradients
  85616. */
  85617. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85618. /**
  85619. * Gets the current list of velocity gradients.
  85620. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85621. * @returns the list of velocity gradients
  85622. */
  85623. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85624. /**
  85625. * Gets the current list of start size gradients.
  85626. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85627. * @returns the list of start size gradients
  85628. */
  85629. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85630. /**
  85631. * Gets the current list of emit rate gradients.
  85632. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85633. * @returns the list of emit rate gradients
  85634. */
  85635. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85636. /**
  85637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85638. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85639. */
  85640. get direction1(): Vector3;
  85641. set direction1(value: Vector3);
  85642. /**
  85643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85644. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85645. */
  85646. get direction2(): Vector3;
  85647. set direction2(value: Vector3);
  85648. /**
  85649. * 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.
  85650. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85651. */
  85652. get minEmitBox(): Vector3;
  85653. set minEmitBox(value: Vector3);
  85654. /**
  85655. * 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.
  85656. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85657. */
  85658. get maxEmitBox(): Vector3;
  85659. set maxEmitBox(value: Vector3);
  85660. /**
  85661. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85662. */
  85663. color1: Color4;
  85664. /**
  85665. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85666. */
  85667. color2: Color4;
  85668. /**
  85669. * Color the particle will have at the end of its lifetime
  85670. */
  85671. colorDead: Color4;
  85672. /**
  85673. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85674. */
  85675. textureMask: Color4;
  85676. /**
  85677. * The particle emitter type defines the emitter used by the particle system.
  85678. * It can be for example box, sphere, or cone...
  85679. */
  85680. particleEmitterType: IParticleEmitterType;
  85681. /** @hidden */
  85682. _isSubEmitter: boolean;
  85683. /**
  85684. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85685. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85686. */
  85687. billboardMode: number;
  85688. protected _isBillboardBased: boolean;
  85689. /**
  85690. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85691. */
  85692. get isBillboardBased(): boolean;
  85693. set isBillboardBased(value: boolean);
  85694. /**
  85695. * The scene the particle system belongs to.
  85696. */
  85697. protected _scene: Scene;
  85698. /**
  85699. * Local cache of defines for image processing.
  85700. */
  85701. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85702. /**
  85703. * Default configuration related to image processing available in the standard Material.
  85704. */
  85705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85706. /**
  85707. * Gets the image processing configuration used either in this material.
  85708. */
  85709. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85710. /**
  85711. * Sets the Default image processing configuration used either in the this material.
  85712. *
  85713. * If sets to null, the scene one is in use.
  85714. */
  85715. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85716. /**
  85717. * Attaches a new image processing configuration to the Standard Material.
  85718. * @param configuration
  85719. */
  85720. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85721. /** @hidden */
  85722. protected _reset(): void;
  85723. /** @hidden */
  85724. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85725. /**
  85726. * Instantiates a particle system.
  85727. * 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.
  85728. * @param name The name of the particle system
  85729. */
  85730. constructor(name: string);
  85731. /**
  85732. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85733. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85734. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85735. * @returns the emitter
  85736. */
  85737. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85738. /**
  85739. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85740. * @param radius The radius of the hemisphere to emit from
  85741. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85742. * @returns the emitter
  85743. */
  85744. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85745. /**
  85746. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85747. * @param radius The radius of the sphere to emit from
  85748. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85749. * @returns the emitter
  85750. */
  85751. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85752. /**
  85753. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85754. * @param radius The radius of the sphere to emit from
  85755. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85756. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85757. * @returns the emitter
  85758. */
  85759. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85760. /**
  85761. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85762. * @param radius The radius of the emission cylinder
  85763. * @param height The height of the emission cylinder
  85764. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85765. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85766. * @returns the emitter
  85767. */
  85768. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85769. /**
  85770. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85771. * @param radius The radius of the cylinder to emit from
  85772. * @param height The height of the emission cylinder
  85773. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85774. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85775. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85776. * @returns the emitter
  85777. */
  85778. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85779. /**
  85780. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85781. * @param radius The radius of the cone to emit from
  85782. * @param angle The base angle of the cone
  85783. * @returns the emitter
  85784. */
  85785. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85786. /**
  85787. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85788. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85789. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85790. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85791. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85792. * @returns the emitter
  85793. */
  85794. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85795. }
  85796. }
  85797. declare module BABYLON {
  85798. /**
  85799. * Type of sub emitter
  85800. */
  85801. export enum SubEmitterType {
  85802. /**
  85803. * Attached to the particle over it's lifetime
  85804. */
  85805. ATTACHED = 0,
  85806. /**
  85807. * Created when the particle dies
  85808. */
  85809. END = 1
  85810. }
  85811. /**
  85812. * Sub emitter class used to emit particles from an existing particle
  85813. */
  85814. export class SubEmitter {
  85815. /**
  85816. * the particle system to be used by the sub emitter
  85817. */
  85818. particleSystem: ParticleSystem;
  85819. /**
  85820. * Type of the submitter (Default: END)
  85821. */
  85822. type: SubEmitterType;
  85823. /**
  85824. * 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)
  85825. * Note: This only is supported when using an emitter of type Mesh
  85826. */
  85827. inheritDirection: boolean;
  85828. /**
  85829. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85830. */
  85831. inheritedVelocityAmount: number;
  85832. /**
  85833. * Creates a sub emitter
  85834. * @param particleSystem the particle system to be used by the sub emitter
  85835. */
  85836. constructor(
  85837. /**
  85838. * the particle system to be used by the sub emitter
  85839. */
  85840. particleSystem: ParticleSystem);
  85841. /**
  85842. * Clones the sub emitter
  85843. * @returns the cloned sub emitter
  85844. */
  85845. clone(): SubEmitter;
  85846. /**
  85847. * Serialize current object to a JSON object
  85848. * @returns the serialized object
  85849. */
  85850. serialize(): any;
  85851. /** @hidden */
  85852. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85853. /**
  85854. * Creates a new SubEmitter from a serialized JSON version
  85855. * @param serializationObject defines the JSON object to read from
  85856. * @param scene defines the hosting scene
  85857. * @param rootUrl defines the rootUrl for data loading
  85858. * @returns a new SubEmitter
  85859. */
  85860. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85861. /** Release associated resources */
  85862. dispose(): void;
  85863. }
  85864. }
  85865. declare module BABYLON {
  85866. /** @hidden */
  85867. export var imageProcessingDeclaration: {
  85868. name: string;
  85869. shader: string;
  85870. };
  85871. }
  85872. declare module BABYLON {
  85873. /** @hidden */
  85874. export var imageProcessingFunctions: {
  85875. name: string;
  85876. shader: string;
  85877. };
  85878. }
  85879. declare module BABYLON {
  85880. /** @hidden */
  85881. export var particlesPixelShader: {
  85882. name: string;
  85883. shader: string;
  85884. };
  85885. }
  85886. declare module BABYLON {
  85887. /** @hidden */
  85888. export var particlesVertexShader: {
  85889. name: string;
  85890. shader: string;
  85891. };
  85892. }
  85893. declare module BABYLON {
  85894. /**
  85895. * This represents a particle system in Babylon.
  85896. * 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.
  85897. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85898. * @example https://doc.babylonjs.com/babylon101/particles
  85899. */
  85900. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85901. /**
  85902. * Billboard mode will only apply to Y axis
  85903. */
  85904. static readonly BILLBOARDMODE_Y: number;
  85905. /**
  85906. * Billboard mode will apply to all axes
  85907. */
  85908. static readonly BILLBOARDMODE_ALL: number;
  85909. /**
  85910. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85911. */
  85912. static readonly BILLBOARDMODE_STRETCHED: number;
  85913. /**
  85914. * This function can be defined to provide custom update for active particles.
  85915. * This function will be called instead of regular update (age, position, color, etc.).
  85916. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85917. */
  85918. updateFunction: (particles: Particle[]) => void;
  85919. private _emitterWorldMatrix;
  85920. /**
  85921. * This function can be defined to specify initial direction for every new particle.
  85922. * It by default use the emitterType defined function
  85923. */
  85924. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85925. /**
  85926. * This function can be defined to specify initial position for every new particle.
  85927. * It by default use the emitterType defined function
  85928. */
  85929. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85930. /**
  85931. * @hidden
  85932. */
  85933. _inheritedVelocityOffset: Vector3;
  85934. /**
  85935. * An event triggered when the system is disposed
  85936. */
  85937. onDisposeObservable: Observable<ParticleSystem>;
  85938. private _onDisposeObserver;
  85939. /**
  85940. * Sets a callback that will be triggered when the system is disposed
  85941. */
  85942. set onDispose(callback: () => void);
  85943. private _particles;
  85944. private _epsilon;
  85945. private _capacity;
  85946. private _stockParticles;
  85947. private _newPartsExcess;
  85948. private _vertexData;
  85949. private _vertexBuffer;
  85950. private _vertexBuffers;
  85951. private _spriteBuffer;
  85952. private _indexBuffer;
  85953. private _effect;
  85954. private _customEffect;
  85955. private _cachedDefines;
  85956. private _scaledColorStep;
  85957. private _colorDiff;
  85958. private _scaledDirection;
  85959. private _scaledGravity;
  85960. private _currentRenderId;
  85961. private _alive;
  85962. private _useInstancing;
  85963. private _started;
  85964. private _stopped;
  85965. private _actualFrame;
  85966. private _scaledUpdateSpeed;
  85967. private _vertexBufferSize;
  85968. /** @hidden */
  85969. _currentEmitRateGradient: Nullable<FactorGradient>;
  85970. /** @hidden */
  85971. _currentEmitRate1: number;
  85972. /** @hidden */
  85973. _currentEmitRate2: number;
  85974. /** @hidden */
  85975. _currentStartSizeGradient: Nullable<FactorGradient>;
  85976. /** @hidden */
  85977. _currentStartSize1: number;
  85978. /** @hidden */
  85979. _currentStartSize2: number;
  85980. private readonly _rawTextureWidth;
  85981. private _rampGradientsTexture;
  85982. private _useRampGradients;
  85983. /** Gets or sets a boolean indicating that ramp gradients must be used
  85984. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85985. */
  85986. get useRampGradients(): boolean;
  85987. set useRampGradients(value: boolean);
  85988. /**
  85989. * 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.
  85990. * 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: [])
  85991. */
  85992. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85993. private _subEmitters;
  85994. /**
  85995. * @hidden
  85996. * If the particle systems emitter should be disposed when the particle system is disposed
  85997. */
  85998. _disposeEmitterOnDispose: boolean;
  85999. /**
  86000. * The current active Sub-systems, this property is used by the root particle system only.
  86001. */
  86002. activeSubSystems: Array<ParticleSystem>;
  86003. /**
  86004. * Specifies if the particles are updated in emitter local space or world space
  86005. */
  86006. isLocal: boolean;
  86007. private _rootParticleSystem;
  86008. /**
  86009. * Gets the current list of active particles
  86010. */
  86011. get particles(): Particle[];
  86012. /**
  86013. * Gets the number of particles active at the same time.
  86014. * @returns The number of active particles.
  86015. */
  86016. getActiveCount(): number;
  86017. /**
  86018. * Returns the string "ParticleSystem"
  86019. * @returns a string containing the class name
  86020. */
  86021. getClassName(): string;
  86022. /**
  86023. * Gets a boolean indicating that the system is stopping
  86024. * @returns true if the system is currently stopping
  86025. */
  86026. isStopping(): boolean;
  86027. /**
  86028. * Instantiates a particle system.
  86029. * 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.
  86030. * @param name The name of the particle system
  86031. * @param capacity The max number of particles alive at the same time
  86032. * @param scene The scene the particle system belongs to
  86033. * @param customEffect a custom effect used to change the way particles are rendered by default
  86034. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86035. * @param epsilon Offset used to render the particles
  86036. */
  86037. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86038. private _addFactorGradient;
  86039. private _removeFactorGradient;
  86040. /**
  86041. * Adds a new life time gradient
  86042. * @param gradient defines the gradient to use (between 0 and 1)
  86043. * @param factor defines the life time factor to affect to the specified gradient
  86044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86045. * @returns the current particle system
  86046. */
  86047. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86048. /**
  86049. * Remove a specific life time gradient
  86050. * @param gradient defines the gradient to remove
  86051. * @returns the current particle system
  86052. */
  86053. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86054. /**
  86055. * Adds a new size gradient
  86056. * @param gradient defines the gradient to use (between 0 and 1)
  86057. * @param factor defines the size factor to affect to the specified gradient
  86058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86059. * @returns the current particle system
  86060. */
  86061. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86062. /**
  86063. * Remove a specific size gradient
  86064. * @param gradient defines the gradient to remove
  86065. * @returns the current particle system
  86066. */
  86067. removeSizeGradient(gradient: number): IParticleSystem;
  86068. /**
  86069. * Adds a new color remap gradient
  86070. * @param gradient defines the gradient to use (between 0 and 1)
  86071. * @param min defines the color remap minimal range
  86072. * @param max defines the color remap maximal range
  86073. * @returns the current particle system
  86074. */
  86075. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86076. /**
  86077. * Remove a specific color remap gradient
  86078. * @param gradient defines the gradient to remove
  86079. * @returns the current particle system
  86080. */
  86081. removeColorRemapGradient(gradient: number): IParticleSystem;
  86082. /**
  86083. * Adds a new alpha remap gradient
  86084. * @param gradient defines the gradient to use (between 0 and 1)
  86085. * @param min defines the alpha remap minimal range
  86086. * @param max defines the alpha remap maximal range
  86087. * @returns the current particle system
  86088. */
  86089. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86090. /**
  86091. * Remove a specific alpha remap gradient
  86092. * @param gradient defines the gradient to remove
  86093. * @returns the current particle system
  86094. */
  86095. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86096. /**
  86097. * Adds a new angular speed gradient
  86098. * @param gradient defines the gradient to use (between 0 and 1)
  86099. * @param factor defines the angular speed to affect to the specified gradient
  86100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86101. * @returns the current particle system
  86102. */
  86103. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86104. /**
  86105. * Remove a specific angular speed gradient
  86106. * @param gradient defines the gradient to remove
  86107. * @returns the current particle system
  86108. */
  86109. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86110. /**
  86111. * Adds a new velocity gradient
  86112. * @param gradient defines the gradient to use (between 0 and 1)
  86113. * @param factor defines the velocity to affect to the specified gradient
  86114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86115. * @returns the current particle system
  86116. */
  86117. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86118. /**
  86119. * Remove a specific velocity gradient
  86120. * @param gradient defines the gradient to remove
  86121. * @returns the current particle system
  86122. */
  86123. removeVelocityGradient(gradient: number): IParticleSystem;
  86124. /**
  86125. * Adds a new limit velocity gradient
  86126. * @param gradient defines the gradient to use (between 0 and 1)
  86127. * @param factor defines the limit velocity value to affect to the specified gradient
  86128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86129. * @returns the current particle system
  86130. */
  86131. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86132. /**
  86133. * Remove a specific limit velocity gradient
  86134. * @param gradient defines the gradient to remove
  86135. * @returns the current particle system
  86136. */
  86137. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86138. /**
  86139. * Adds a new drag gradient
  86140. * @param gradient defines the gradient to use (between 0 and 1)
  86141. * @param factor defines the drag value to affect to the specified gradient
  86142. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86143. * @returns the current particle system
  86144. */
  86145. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86146. /**
  86147. * Remove a specific drag gradient
  86148. * @param gradient defines the gradient to remove
  86149. * @returns the current particle system
  86150. */
  86151. removeDragGradient(gradient: number): IParticleSystem;
  86152. /**
  86153. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86154. * @param gradient defines the gradient to use (between 0 and 1)
  86155. * @param factor defines the emit rate value to affect to the specified gradient
  86156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86157. * @returns the current particle system
  86158. */
  86159. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86160. /**
  86161. * Remove a specific emit rate gradient
  86162. * @param gradient defines the gradient to remove
  86163. * @returns the current particle system
  86164. */
  86165. removeEmitRateGradient(gradient: number): IParticleSystem;
  86166. /**
  86167. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86168. * @param gradient defines the gradient to use (between 0 and 1)
  86169. * @param factor defines the start size value to affect to the specified gradient
  86170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86171. * @returns the current particle system
  86172. */
  86173. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86174. /**
  86175. * Remove a specific start size gradient
  86176. * @param gradient defines the gradient to remove
  86177. * @returns the current particle system
  86178. */
  86179. removeStartSizeGradient(gradient: number): IParticleSystem;
  86180. private _createRampGradientTexture;
  86181. /**
  86182. * Gets the current list of ramp gradients.
  86183. * You must use addRampGradient and removeRampGradient to udpate this list
  86184. * @returns the list of ramp gradients
  86185. */
  86186. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86187. /** Force the system to rebuild all gradients that need to be resync */
  86188. forceRefreshGradients(): void;
  86189. private _syncRampGradientTexture;
  86190. /**
  86191. * Adds a new ramp gradient used to remap particle colors
  86192. * @param gradient defines the gradient to use (between 0 and 1)
  86193. * @param color defines the color to affect to the specified gradient
  86194. * @returns the current particle system
  86195. */
  86196. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86197. /**
  86198. * Remove a specific ramp gradient
  86199. * @param gradient defines the gradient to remove
  86200. * @returns the current particle system
  86201. */
  86202. removeRampGradient(gradient: number): ParticleSystem;
  86203. /**
  86204. * Adds a new color gradient
  86205. * @param gradient defines the gradient to use (between 0 and 1)
  86206. * @param color1 defines the color to affect to the specified gradient
  86207. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86208. * @returns this particle system
  86209. */
  86210. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86211. /**
  86212. * Remove a specific color gradient
  86213. * @param gradient defines the gradient to remove
  86214. * @returns this particle system
  86215. */
  86216. removeColorGradient(gradient: number): IParticleSystem;
  86217. private _fetchR;
  86218. protected _reset(): void;
  86219. private _resetEffect;
  86220. private _createVertexBuffers;
  86221. private _createIndexBuffer;
  86222. /**
  86223. * Gets the maximum number of particles active at the same time.
  86224. * @returns The max number of active particles.
  86225. */
  86226. getCapacity(): number;
  86227. /**
  86228. * Gets whether there are still active particles in the system.
  86229. * @returns True if it is alive, otherwise false.
  86230. */
  86231. isAlive(): boolean;
  86232. /**
  86233. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86234. * @returns True if it has been started, otherwise false.
  86235. */
  86236. isStarted(): boolean;
  86237. private _prepareSubEmitterInternalArray;
  86238. /**
  86239. * Starts the particle system and begins to emit
  86240. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86241. */
  86242. start(delay?: number): void;
  86243. /**
  86244. * Stops the particle system.
  86245. * @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.
  86246. */
  86247. stop(stopSubEmitters?: boolean): void;
  86248. /**
  86249. * Remove all active particles
  86250. */
  86251. reset(): void;
  86252. /**
  86253. * @hidden (for internal use only)
  86254. */
  86255. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86256. /**
  86257. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86258. * Its lifetime will start back at 0.
  86259. */
  86260. recycleParticle: (particle: Particle) => void;
  86261. private _stopSubEmitters;
  86262. private _createParticle;
  86263. private _removeFromRoot;
  86264. private _emitFromParticle;
  86265. private _update;
  86266. /** @hidden */
  86267. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86268. /** @hidden */
  86269. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86270. /** @hidden */
  86271. private _getEffect;
  86272. /**
  86273. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86274. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86275. */
  86276. animate(preWarmOnly?: boolean): void;
  86277. private _appendParticleVertices;
  86278. /**
  86279. * Rebuilds the particle system.
  86280. */
  86281. rebuild(): void;
  86282. /**
  86283. * Is this system ready to be used/rendered
  86284. * @return true if the system is ready
  86285. */
  86286. isReady(): boolean;
  86287. private _render;
  86288. /**
  86289. * Renders the particle system in its current state.
  86290. * @returns the current number of particles
  86291. */
  86292. render(): number;
  86293. /**
  86294. * Disposes the particle system and free the associated resources
  86295. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86296. */
  86297. dispose(disposeTexture?: boolean): void;
  86298. /**
  86299. * Clones the particle system.
  86300. * @param name The name of the cloned object
  86301. * @param newEmitter The new emitter to use
  86302. * @returns the cloned particle system
  86303. */
  86304. clone(name: string, newEmitter: any): ParticleSystem;
  86305. /**
  86306. * Serializes the particle system to a JSON object
  86307. * @param serializeTexture defines if the texture must be serialized as well
  86308. * @returns the JSON object
  86309. */
  86310. serialize(serializeTexture?: boolean): any;
  86311. /** @hidden */
  86312. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  86313. /** @hidden */
  86314. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86315. /**
  86316. * Parses a JSON object to create a particle system.
  86317. * @param parsedParticleSystem The JSON object to parse
  86318. * @param scene The scene to create the particle system in
  86319. * @param rootUrl The root url to use to load external dependencies like texture
  86320. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86321. * @returns the Parsed particle system
  86322. */
  86323. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86324. }
  86325. }
  86326. declare module BABYLON {
  86327. /**
  86328. * A particle represents one of the element emitted by a particle system.
  86329. * This is mainly define by its coordinates, direction, velocity and age.
  86330. */
  86331. export class Particle {
  86332. /**
  86333. * The particle system the particle belongs to.
  86334. */
  86335. particleSystem: ParticleSystem;
  86336. private static _Count;
  86337. /**
  86338. * Unique ID of the particle
  86339. */
  86340. id: number;
  86341. /**
  86342. * The world position of the particle in the scene.
  86343. */
  86344. position: Vector3;
  86345. /**
  86346. * The world direction of the particle in the scene.
  86347. */
  86348. direction: Vector3;
  86349. /**
  86350. * The color of the particle.
  86351. */
  86352. color: Color4;
  86353. /**
  86354. * The color change of the particle per step.
  86355. */
  86356. colorStep: Color4;
  86357. /**
  86358. * Defines how long will the life of the particle be.
  86359. */
  86360. lifeTime: number;
  86361. /**
  86362. * The current age of the particle.
  86363. */
  86364. age: number;
  86365. /**
  86366. * The current size of the particle.
  86367. */
  86368. size: number;
  86369. /**
  86370. * The current scale of the particle.
  86371. */
  86372. scale: Vector2;
  86373. /**
  86374. * The current angle of the particle.
  86375. */
  86376. angle: number;
  86377. /**
  86378. * Defines how fast is the angle changing.
  86379. */
  86380. angularSpeed: number;
  86381. /**
  86382. * Defines the cell index used by the particle to be rendered from a sprite.
  86383. */
  86384. cellIndex: number;
  86385. /**
  86386. * The information required to support color remapping
  86387. */
  86388. remapData: Vector4;
  86389. /** @hidden */
  86390. _randomCellOffset?: number;
  86391. /** @hidden */
  86392. _initialDirection: Nullable<Vector3>;
  86393. /** @hidden */
  86394. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86395. /** @hidden */
  86396. _initialStartSpriteCellID: number;
  86397. /** @hidden */
  86398. _initialEndSpriteCellID: number;
  86399. /** @hidden */
  86400. _currentColorGradient: Nullable<ColorGradient>;
  86401. /** @hidden */
  86402. _currentColor1: Color4;
  86403. /** @hidden */
  86404. _currentColor2: Color4;
  86405. /** @hidden */
  86406. _currentSizeGradient: Nullable<FactorGradient>;
  86407. /** @hidden */
  86408. _currentSize1: number;
  86409. /** @hidden */
  86410. _currentSize2: number;
  86411. /** @hidden */
  86412. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86413. /** @hidden */
  86414. _currentAngularSpeed1: number;
  86415. /** @hidden */
  86416. _currentAngularSpeed2: number;
  86417. /** @hidden */
  86418. _currentVelocityGradient: Nullable<FactorGradient>;
  86419. /** @hidden */
  86420. _currentVelocity1: number;
  86421. /** @hidden */
  86422. _currentVelocity2: number;
  86423. /** @hidden */
  86424. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86425. /** @hidden */
  86426. _currentLimitVelocity1: number;
  86427. /** @hidden */
  86428. _currentLimitVelocity2: number;
  86429. /** @hidden */
  86430. _currentDragGradient: Nullable<FactorGradient>;
  86431. /** @hidden */
  86432. _currentDrag1: number;
  86433. /** @hidden */
  86434. _currentDrag2: number;
  86435. /** @hidden */
  86436. _randomNoiseCoordinates1: Vector3;
  86437. /** @hidden */
  86438. _randomNoiseCoordinates2: Vector3;
  86439. /** @hidden */
  86440. _localPosition?: Vector3;
  86441. /**
  86442. * Creates a new instance Particle
  86443. * @param particleSystem the particle system the particle belongs to
  86444. */
  86445. constructor(
  86446. /**
  86447. * The particle system the particle belongs to.
  86448. */
  86449. particleSystem: ParticleSystem);
  86450. private updateCellInfoFromSystem;
  86451. /**
  86452. * Defines how the sprite cell index is updated for the particle
  86453. */
  86454. updateCellIndex(): void;
  86455. /** @hidden */
  86456. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86457. /** @hidden */
  86458. _inheritParticleInfoToSubEmitters(): void;
  86459. /** @hidden */
  86460. _reset(): void;
  86461. /**
  86462. * Copy the properties of particle to another one.
  86463. * @param other the particle to copy the information to.
  86464. */
  86465. copyTo(other: Particle): void;
  86466. }
  86467. }
  86468. declare module BABYLON {
  86469. /**
  86470. * Particle emitter represents a volume emitting particles.
  86471. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86472. */
  86473. export interface IParticleEmitterType {
  86474. /**
  86475. * Called by the particle System when the direction is computed for the created particle.
  86476. * @param worldMatrix is the world matrix of the particle system
  86477. * @param directionToUpdate is the direction vector to update with the result
  86478. * @param particle is the particle we are computed the direction for
  86479. * @param isLocal defines if the direction should be set in local space
  86480. */
  86481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86482. /**
  86483. * Called by the particle System when the position is computed for the created particle.
  86484. * @param worldMatrix is the world matrix of the particle system
  86485. * @param positionToUpdate is the position vector to update with the result
  86486. * @param particle is the particle we are computed the position for
  86487. * @param isLocal defines if the position should be set in local space
  86488. */
  86489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86490. /**
  86491. * Clones the current emitter and returns a copy of it
  86492. * @returns the new emitter
  86493. */
  86494. clone(): IParticleEmitterType;
  86495. /**
  86496. * Called by the GPUParticleSystem to setup the update shader
  86497. * @param effect defines the update shader
  86498. */
  86499. applyToShader(effect: Effect): void;
  86500. /**
  86501. * Returns a string to use to update the GPU particles update shader
  86502. * @returns the effect defines string
  86503. */
  86504. getEffectDefines(): string;
  86505. /**
  86506. * Returns a string representing the class name
  86507. * @returns a string containing the class name
  86508. */
  86509. getClassName(): string;
  86510. /**
  86511. * Serializes the particle system to a JSON object.
  86512. * @returns the JSON object
  86513. */
  86514. serialize(): any;
  86515. /**
  86516. * Parse properties from a JSON object
  86517. * @param serializationObject defines the JSON object
  86518. * @param scene defines the hosting scene
  86519. */
  86520. parse(serializationObject: any, scene: Scene): void;
  86521. }
  86522. }
  86523. declare module BABYLON {
  86524. /**
  86525. * Particle emitter emitting particles from the inside of a box.
  86526. * It emits the particles randomly between 2 given directions.
  86527. */
  86528. export class BoxParticleEmitter implements IParticleEmitterType {
  86529. /**
  86530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86531. */
  86532. direction1: Vector3;
  86533. /**
  86534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86535. */
  86536. direction2: Vector3;
  86537. /**
  86538. * 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.
  86539. */
  86540. minEmitBox: Vector3;
  86541. /**
  86542. * 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.
  86543. */
  86544. maxEmitBox: Vector3;
  86545. /**
  86546. * Creates a new instance BoxParticleEmitter
  86547. */
  86548. constructor();
  86549. /**
  86550. * Called by the particle System when the direction is computed for the created particle.
  86551. * @param worldMatrix is the world matrix of the particle system
  86552. * @param directionToUpdate is the direction vector to update with the result
  86553. * @param particle is the particle we are computed the direction for
  86554. * @param isLocal defines if the direction should be set in local space
  86555. */
  86556. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86557. /**
  86558. * Called by the particle System when the position is computed for the created particle.
  86559. * @param worldMatrix is the world matrix of the particle system
  86560. * @param positionToUpdate is the position vector to update with the result
  86561. * @param particle is the particle we are computed the position for
  86562. * @param isLocal defines if the position should be set in local space
  86563. */
  86564. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86565. /**
  86566. * Clones the current emitter and returns a copy of it
  86567. * @returns the new emitter
  86568. */
  86569. clone(): BoxParticleEmitter;
  86570. /**
  86571. * Called by the GPUParticleSystem to setup the update shader
  86572. * @param effect defines the update shader
  86573. */
  86574. applyToShader(effect: Effect): void;
  86575. /**
  86576. * Returns a string to use to update the GPU particles update shader
  86577. * @returns a string containng the defines string
  86578. */
  86579. getEffectDefines(): string;
  86580. /**
  86581. * Returns the string "BoxParticleEmitter"
  86582. * @returns a string containing the class name
  86583. */
  86584. getClassName(): string;
  86585. /**
  86586. * Serializes the particle system to a JSON object.
  86587. * @returns the JSON object
  86588. */
  86589. serialize(): any;
  86590. /**
  86591. * Parse properties from a JSON object
  86592. * @param serializationObject defines the JSON object
  86593. */
  86594. parse(serializationObject: any): void;
  86595. }
  86596. }
  86597. declare module BABYLON {
  86598. /**
  86599. * Particle emitter emitting particles from the inside of a cone.
  86600. * It emits the particles alongside the cone volume from the base to the particle.
  86601. * The emission direction might be randomized.
  86602. */
  86603. export class ConeParticleEmitter implements IParticleEmitterType {
  86604. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86605. directionRandomizer: number;
  86606. private _radius;
  86607. private _angle;
  86608. private _height;
  86609. /**
  86610. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86611. */
  86612. radiusRange: number;
  86613. /**
  86614. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86615. */
  86616. heightRange: number;
  86617. /**
  86618. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86619. */
  86620. emitFromSpawnPointOnly: boolean;
  86621. /**
  86622. * Gets or sets the radius of the emission cone
  86623. */
  86624. get radius(): number;
  86625. set radius(value: number);
  86626. /**
  86627. * Gets or sets the angle of the emission cone
  86628. */
  86629. get angle(): number;
  86630. set angle(value: number);
  86631. private _buildHeight;
  86632. /**
  86633. * Creates a new instance ConeParticleEmitter
  86634. * @param radius the radius of the emission cone (1 by default)
  86635. * @param angle the cone base angle (PI by default)
  86636. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86637. */
  86638. constructor(radius?: number, angle?: number,
  86639. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86640. directionRandomizer?: number);
  86641. /**
  86642. * Called by the particle System when the direction is computed for the created particle.
  86643. * @param worldMatrix is the world matrix of the particle system
  86644. * @param directionToUpdate is the direction vector to update with the result
  86645. * @param particle is the particle we are computed the direction for
  86646. * @param isLocal defines if the direction should be set in local space
  86647. */
  86648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86649. /**
  86650. * Called by the particle System when the position is computed for the created particle.
  86651. * @param worldMatrix is the world matrix of the particle system
  86652. * @param positionToUpdate is the position vector to update with the result
  86653. * @param particle is the particle we are computed the position for
  86654. * @param isLocal defines if the position should be set in local space
  86655. */
  86656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86657. /**
  86658. * Clones the current emitter and returns a copy of it
  86659. * @returns the new emitter
  86660. */
  86661. clone(): ConeParticleEmitter;
  86662. /**
  86663. * Called by the GPUParticleSystem to setup the update shader
  86664. * @param effect defines the update shader
  86665. */
  86666. applyToShader(effect: Effect): void;
  86667. /**
  86668. * Returns a string to use to update the GPU particles update shader
  86669. * @returns a string containng the defines string
  86670. */
  86671. getEffectDefines(): string;
  86672. /**
  86673. * Returns the string "ConeParticleEmitter"
  86674. * @returns a string containing the class name
  86675. */
  86676. getClassName(): string;
  86677. /**
  86678. * Serializes the particle system to a JSON object.
  86679. * @returns the JSON object
  86680. */
  86681. serialize(): any;
  86682. /**
  86683. * Parse properties from a JSON object
  86684. * @param serializationObject defines the JSON object
  86685. */
  86686. parse(serializationObject: any): void;
  86687. }
  86688. }
  86689. declare module BABYLON {
  86690. /**
  86691. * Particle emitter emitting particles from the inside of a cylinder.
  86692. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86693. */
  86694. export class CylinderParticleEmitter implements IParticleEmitterType {
  86695. /**
  86696. * The radius of the emission cylinder.
  86697. */
  86698. radius: number;
  86699. /**
  86700. * The height of the emission cylinder.
  86701. */
  86702. height: number;
  86703. /**
  86704. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86705. */
  86706. radiusRange: number;
  86707. /**
  86708. * How much to randomize the particle direction [0-1].
  86709. */
  86710. directionRandomizer: number;
  86711. /**
  86712. * Creates a new instance CylinderParticleEmitter
  86713. * @param radius the radius of the emission cylinder (1 by default)
  86714. * @param height the height of the emission cylinder (1 by default)
  86715. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86716. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86717. */
  86718. constructor(
  86719. /**
  86720. * The radius of the emission cylinder.
  86721. */
  86722. radius?: number,
  86723. /**
  86724. * The height of the emission cylinder.
  86725. */
  86726. height?: number,
  86727. /**
  86728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86729. */
  86730. radiusRange?: number,
  86731. /**
  86732. * How much to randomize the particle direction [0-1].
  86733. */
  86734. directionRandomizer?: number);
  86735. /**
  86736. * Called by the particle System when the direction is computed for the created particle.
  86737. * @param worldMatrix is the world matrix of the particle system
  86738. * @param directionToUpdate is the direction vector to update with the result
  86739. * @param particle is the particle we are computed the direction for
  86740. * @param isLocal defines if the direction should be set in local space
  86741. */
  86742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86743. /**
  86744. * Called by the particle System when the position is computed for the created particle.
  86745. * @param worldMatrix is the world matrix of the particle system
  86746. * @param positionToUpdate is the position vector to update with the result
  86747. * @param particle is the particle we are computed the position for
  86748. * @param isLocal defines if the position should be set in local space
  86749. */
  86750. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86751. /**
  86752. * Clones the current emitter and returns a copy of it
  86753. * @returns the new emitter
  86754. */
  86755. clone(): CylinderParticleEmitter;
  86756. /**
  86757. * Called by the GPUParticleSystem to setup the update shader
  86758. * @param effect defines the update shader
  86759. */
  86760. applyToShader(effect: Effect): void;
  86761. /**
  86762. * Returns a string to use to update the GPU particles update shader
  86763. * @returns a string containng the defines string
  86764. */
  86765. getEffectDefines(): string;
  86766. /**
  86767. * Returns the string "CylinderParticleEmitter"
  86768. * @returns a string containing the class name
  86769. */
  86770. getClassName(): string;
  86771. /**
  86772. * Serializes the particle system to a JSON object.
  86773. * @returns the JSON object
  86774. */
  86775. serialize(): any;
  86776. /**
  86777. * Parse properties from a JSON object
  86778. * @param serializationObject defines the JSON object
  86779. */
  86780. parse(serializationObject: any): void;
  86781. }
  86782. /**
  86783. * Particle emitter emitting particles from the inside of a cylinder.
  86784. * It emits the particles randomly between two vectors.
  86785. */
  86786. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86787. /**
  86788. * The min limit of the emission direction.
  86789. */
  86790. direction1: Vector3;
  86791. /**
  86792. * The max limit of the emission direction.
  86793. */
  86794. direction2: Vector3;
  86795. /**
  86796. * Creates a new instance CylinderDirectedParticleEmitter
  86797. * @param radius the radius of the emission cylinder (1 by default)
  86798. * @param height the height of the emission cylinder (1 by default)
  86799. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86800. * @param direction1 the min limit of the emission direction (up vector by default)
  86801. * @param direction2 the max limit of the emission direction (up vector by default)
  86802. */
  86803. constructor(radius?: number, height?: number, radiusRange?: number,
  86804. /**
  86805. * The min limit of the emission direction.
  86806. */
  86807. direction1?: Vector3,
  86808. /**
  86809. * The max limit of the emission direction.
  86810. */
  86811. direction2?: Vector3);
  86812. /**
  86813. * Called by the particle System when the direction is computed for the created particle.
  86814. * @param worldMatrix is the world matrix of the particle system
  86815. * @param directionToUpdate is the direction vector to update with the result
  86816. * @param particle is the particle we are computed the direction for
  86817. */
  86818. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86819. /**
  86820. * Clones the current emitter and returns a copy of it
  86821. * @returns the new emitter
  86822. */
  86823. clone(): CylinderDirectedParticleEmitter;
  86824. /**
  86825. * Called by the GPUParticleSystem to setup the update shader
  86826. * @param effect defines the update shader
  86827. */
  86828. applyToShader(effect: Effect): void;
  86829. /**
  86830. * Returns a string to use to update the GPU particles update shader
  86831. * @returns a string containng the defines string
  86832. */
  86833. getEffectDefines(): string;
  86834. /**
  86835. * Returns the string "CylinderDirectedParticleEmitter"
  86836. * @returns a string containing the class name
  86837. */
  86838. getClassName(): string;
  86839. /**
  86840. * Serializes the particle system to a JSON object.
  86841. * @returns the JSON object
  86842. */
  86843. serialize(): any;
  86844. /**
  86845. * Parse properties from a JSON object
  86846. * @param serializationObject defines the JSON object
  86847. */
  86848. parse(serializationObject: any): void;
  86849. }
  86850. }
  86851. declare module BABYLON {
  86852. /**
  86853. * Particle emitter emitting particles from the inside of a hemisphere.
  86854. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86855. */
  86856. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86857. /**
  86858. * The radius of the emission hemisphere.
  86859. */
  86860. radius: number;
  86861. /**
  86862. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86863. */
  86864. radiusRange: number;
  86865. /**
  86866. * How much to randomize the particle direction [0-1].
  86867. */
  86868. directionRandomizer: number;
  86869. /**
  86870. * Creates a new instance HemisphericParticleEmitter
  86871. * @param radius the radius of the emission hemisphere (1 by default)
  86872. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86873. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86874. */
  86875. constructor(
  86876. /**
  86877. * The radius of the emission hemisphere.
  86878. */
  86879. radius?: number,
  86880. /**
  86881. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86882. */
  86883. radiusRange?: number,
  86884. /**
  86885. * How much to randomize the particle direction [0-1].
  86886. */
  86887. directionRandomizer?: number);
  86888. /**
  86889. * Called by the particle System when the direction is computed for the created particle.
  86890. * @param worldMatrix is the world matrix of the particle system
  86891. * @param directionToUpdate is the direction vector to update with the result
  86892. * @param particle is the particle we are computed the direction for
  86893. * @param isLocal defines if the direction should be set in local space
  86894. */
  86895. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86896. /**
  86897. * Called by the particle System when the position is computed for the created particle.
  86898. * @param worldMatrix is the world matrix of the particle system
  86899. * @param positionToUpdate is the position vector to update with the result
  86900. * @param particle is the particle we are computed the position for
  86901. * @param isLocal defines if the position should be set in local space
  86902. */
  86903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86904. /**
  86905. * Clones the current emitter and returns a copy of it
  86906. * @returns the new emitter
  86907. */
  86908. clone(): HemisphericParticleEmitter;
  86909. /**
  86910. * Called by the GPUParticleSystem to setup the update shader
  86911. * @param effect defines the update shader
  86912. */
  86913. applyToShader(effect: Effect): void;
  86914. /**
  86915. * Returns a string to use to update the GPU particles update shader
  86916. * @returns a string containng the defines string
  86917. */
  86918. getEffectDefines(): string;
  86919. /**
  86920. * Returns the string "HemisphericParticleEmitter"
  86921. * @returns a string containing the class name
  86922. */
  86923. getClassName(): string;
  86924. /**
  86925. * Serializes the particle system to a JSON object.
  86926. * @returns the JSON object
  86927. */
  86928. serialize(): any;
  86929. /**
  86930. * Parse properties from a JSON object
  86931. * @param serializationObject defines the JSON object
  86932. */
  86933. parse(serializationObject: any): void;
  86934. }
  86935. }
  86936. declare module BABYLON {
  86937. /**
  86938. * Particle emitter emitting particles from a point.
  86939. * It emits the particles randomly between 2 given directions.
  86940. */
  86941. export class PointParticleEmitter implements IParticleEmitterType {
  86942. /**
  86943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86944. */
  86945. direction1: Vector3;
  86946. /**
  86947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86948. */
  86949. direction2: Vector3;
  86950. /**
  86951. * Creates a new instance PointParticleEmitter
  86952. */
  86953. constructor();
  86954. /**
  86955. * Called by the particle System when the direction is computed for the created particle.
  86956. * @param worldMatrix is the world matrix of the particle system
  86957. * @param directionToUpdate is the direction vector to update with the result
  86958. * @param particle is the particle we are computed the direction for
  86959. * @param isLocal defines if the direction should be set in local space
  86960. */
  86961. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86962. /**
  86963. * Called by the particle System when the position is computed for the created particle.
  86964. * @param worldMatrix is the world matrix of the particle system
  86965. * @param positionToUpdate is the position vector to update with the result
  86966. * @param particle is the particle we are computed the position for
  86967. * @param isLocal defines if the position should be set in local space
  86968. */
  86969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86970. /**
  86971. * Clones the current emitter and returns a copy of it
  86972. * @returns the new emitter
  86973. */
  86974. clone(): PointParticleEmitter;
  86975. /**
  86976. * Called by the GPUParticleSystem to setup the update shader
  86977. * @param effect defines the update shader
  86978. */
  86979. applyToShader(effect: Effect): void;
  86980. /**
  86981. * Returns a string to use to update the GPU particles update shader
  86982. * @returns a string containng the defines string
  86983. */
  86984. getEffectDefines(): string;
  86985. /**
  86986. * Returns the string "PointParticleEmitter"
  86987. * @returns a string containing the class name
  86988. */
  86989. getClassName(): string;
  86990. /**
  86991. * Serializes the particle system to a JSON object.
  86992. * @returns the JSON object
  86993. */
  86994. serialize(): any;
  86995. /**
  86996. * Parse properties from a JSON object
  86997. * @param serializationObject defines the JSON object
  86998. */
  86999. parse(serializationObject: any): void;
  87000. }
  87001. }
  87002. declare module BABYLON {
  87003. /**
  87004. * Particle emitter emitting particles from the inside of a sphere.
  87005. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87006. */
  87007. export class SphereParticleEmitter implements IParticleEmitterType {
  87008. /**
  87009. * The radius of the emission sphere.
  87010. */
  87011. radius: number;
  87012. /**
  87013. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87014. */
  87015. radiusRange: number;
  87016. /**
  87017. * How much to randomize the particle direction [0-1].
  87018. */
  87019. directionRandomizer: number;
  87020. /**
  87021. * Creates a new instance SphereParticleEmitter
  87022. * @param radius the radius of the emission sphere (1 by default)
  87023. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87024. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87025. */
  87026. constructor(
  87027. /**
  87028. * The radius of the emission sphere.
  87029. */
  87030. radius?: number,
  87031. /**
  87032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87033. */
  87034. radiusRange?: number,
  87035. /**
  87036. * How much to randomize the particle direction [0-1].
  87037. */
  87038. directionRandomizer?: number);
  87039. /**
  87040. * Called by the particle System when the direction is computed for the created particle.
  87041. * @param worldMatrix is the world matrix of the particle system
  87042. * @param directionToUpdate is the direction vector to update with the result
  87043. * @param particle is the particle we are computed the direction for
  87044. * @param isLocal defines if the direction should be set in local space
  87045. */
  87046. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87047. /**
  87048. * Called by the particle System when the position is computed for the created particle.
  87049. * @param worldMatrix is the world matrix of the particle system
  87050. * @param positionToUpdate is the position vector to update with the result
  87051. * @param particle is the particle we are computed the position for
  87052. * @param isLocal defines if the position should be set in local space
  87053. */
  87054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87055. /**
  87056. * Clones the current emitter and returns a copy of it
  87057. * @returns the new emitter
  87058. */
  87059. clone(): SphereParticleEmitter;
  87060. /**
  87061. * Called by the GPUParticleSystem to setup the update shader
  87062. * @param effect defines the update shader
  87063. */
  87064. applyToShader(effect: Effect): void;
  87065. /**
  87066. * Returns a string to use to update the GPU particles update shader
  87067. * @returns a string containng the defines string
  87068. */
  87069. getEffectDefines(): string;
  87070. /**
  87071. * Returns the string "SphereParticleEmitter"
  87072. * @returns a string containing the class name
  87073. */
  87074. getClassName(): string;
  87075. /**
  87076. * Serializes the particle system to a JSON object.
  87077. * @returns the JSON object
  87078. */
  87079. serialize(): any;
  87080. /**
  87081. * Parse properties from a JSON object
  87082. * @param serializationObject defines the JSON object
  87083. */
  87084. parse(serializationObject: any): void;
  87085. }
  87086. /**
  87087. * Particle emitter emitting particles from the inside of a sphere.
  87088. * It emits the particles randomly between two vectors.
  87089. */
  87090. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87091. /**
  87092. * The min limit of the emission direction.
  87093. */
  87094. direction1: Vector3;
  87095. /**
  87096. * The max limit of the emission direction.
  87097. */
  87098. direction2: Vector3;
  87099. /**
  87100. * Creates a new instance SphereDirectedParticleEmitter
  87101. * @param radius the radius of the emission sphere (1 by default)
  87102. * @param direction1 the min limit of the emission direction (up vector by default)
  87103. * @param direction2 the max limit of the emission direction (up vector by default)
  87104. */
  87105. constructor(radius?: number,
  87106. /**
  87107. * The min limit of the emission direction.
  87108. */
  87109. direction1?: Vector3,
  87110. /**
  87111. * The max limit of the emission direction.
  87112. */
  87113. direction2?: Vector3);
  87114. /**
  87115. * Called by the particle System when the direction is computed for the created particle.
  87116. * @param worldMatrix is the world matrix of the particle system
  87117. * @param directionToUpdate is the direction vector to update with the result
  87118. * @param particle is the particle we are computed the direction for
  87119. */
  87120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87121. /**
  87122. * Clones the current emitter and returns a copy of it
  87123. * @returns the new emitter
  87124. */
  87125. clone(): SphereDirectedParticleEmitter;
  87126. /**
  87127. * Called by the GPUParticleSystem to setup the update shader
  87128. * @param effect defines the update shader
  87129. */
  87130. applyToShader(effect: Effect): void;
  87131. /**
  87132. * Returns a string to use to update the GPU particles update shader
  87133. * @returns a string containng the defines string
  87134. */
  87135. getEffectDefines(): string;
  87136. /**
  87137. * Returns the string "SphereDirectedParticleEmitter"
  87138. * @returns a string containing the class name
  87139. */
  87140. getClassName(): string;
  87141. /**
  87142. * Serializes the particle system to a JSON object.
  87143. * @returns the JSON object
  87144. */
  87145. serialize(): any;
  87146. /**
  87147. * Parse properties from a JSON object
  87148. * @param serializationObject defines the JSON object
  87149. */
  87150. parse(serializationObject: any): void;
  87151. }
  87152. }
  87153. declare module BABYLON {
  87154. /**
  87155. * Particle emitter emitting particles from a custom list of positions.
  87156. */
  87157. export class CustomParticleEmitter implements IParticleEmitterType {
  87158. /**
  87159. * Gets or sets the position generator that will create the inital position of each particle.
  87160. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87161. */
  87162. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87163. /**
  87164. * Gets or sets the destination generator that will create the final destination of each particle.
  87165. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87166. */
  87167. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87168. /**
  87169. * Creates a new instance CustomParticleEmitter
  87170. */
  87171. constructor();
  87172. /**
  87173. * Called by the particle System when the direction is computed for the created particle.
  87174. * @param worldMatrix is the world matrix of the particle system
  87175. * @param directionToUpdate is the direction vector to update with the result
  87176. * @param particle is the particle we are computed the direction for
  87177. * @param isLocal defines if the direction should be set in local space
  87178. */
  87179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87180. /**
  87181. * Called by the particle System when the position is computed for the created particle.
  87182. * @param worldMatrix is the world matrix of the particle system
  87183. * @param positionToUpdate is the position vector to update with the result
  87184. * @param particle is the particle we are computed the position for
  87185. * @param isLocal defines if the position should be set in local space
  87186. */
  87187. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87188. /**
  87189. * Clones the current emitter and returns a copy of it
  87190. * @returns the new emitter
  87191. */
  87192. clone(): CustomParticleEmitter;
  87193. /**
  87194. * Called by the GPUParticleSystem to setup the update shader
  87195. * @param effect defines the update shader
  87196. */
  87197. applyToShader(effect: Effect): void;
  87198. /**
  87199. * Returns a string to use to update the GPU particles update shader
  87200. * @returns a string containng the defines string
  87201. */
  87202. getEffectDefines(): string;
  87203. /**
  87204. * Returns the string "PointParticleEmitter"
  87205. * @returns a string containing the class name
  87206. */
  87207. getClassName(): string;
  87208. /**
  87209. * Serializes the particle system to a JSON object.
  87210. * @returns the JSON object
  87211. */
  87212. serialize(): any;
  87213. /**
  87214. * Parse properties from a JSON object
  87215. * @param serializationObject defines the JSON object
  87216. */
  87217. parse(serializationObject: any): void;
  87218. }
  87219. }
  87220. declare module BABYLON {
  87221. /**
  87222. * Particle emitter emitting particles from the inside of a box.
  87223. * It emits the particles randomly between 2 given directions.
  87224. */
  87225. export class MeshParticleEmitter implements IParticleEmitterType {
  87226. private _indices;
  87227. private _positions;
  87228. private _normals;
  87229. private _storedNormal;
  87230. private _mesh;
  87231. /**
  87232. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87233. */
  87234. direction1: Vector3;
  87235. /**
  87236. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87237. */
  87238. direction2: Vector3;
  87239. /**
  87240. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87241. */
  87242. useMeshNormalsForDirection: boolean;
  87243. /** Defines the mesh to use as source */
  87244. get mesh(): Nullable<AbstractMesh>;
  87245. set mesh(value: Nullable<AbstractMesh>);
  87246. /**
  87247. * Creates a new instance MeshParticleEmitter
  87248. * @param mesh defines the mesh to use as source
  87249. */
  87250. constructor(mesh?: Nullable<AbstractMesh>);
  87251. /**
  87252. * Called by the particle System when the direction is computed for the created particle.
  87253. * @param worldMatrix is the world matrix of the particle system
  87254. * @param directionToUpdate is the direction vector to update with the result
  87255. * @param particle is the particle we are computed the direction for
  87256. * @param isLocal defines if the direction should be set in local space
  87257. */
  87258. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87259. /**
  87260. * Called by the particle System when the position is computed for the created particle.
  87261. * @param worldMatrix is the world matrix of the particle system
  87262. * @param positionToUpdate is the position vector to update with the result
  87263. * @param particle is the particle we are computed the position for
  87264. * @param isLocal defines if the position should be set in local space
  87265. */
  87266. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87267. /**
  87268. * Clones the current emitter and returns a copy of it
  87269. * @returns the new emitter
  87270. */
  87271. clone(): MeshParticleEmitter;
  87272. /**
  87273. * Called by the GPUParticleSystem to setup the update shader
  87274. * @param effect defines the update shader
  87275. */
  87276. applyToShader(effect: Effect): void;
  87277. /**
  87278. * Returns a string to use to update the GPU particles update shader
  87279. * @returns a string containng the defines string
  87280. */
  87281. getEffectDefines(): string;
  87282. /**
  87283. * Returns the string "BoxParticleEmitter"
  87284. * @returns a string containing the class name
  87285. */
  87286. getClassName(): string;
  87287. /**
  87288. * Serializes the particle system to a JSON object.
  87289. * @returns the JSON object
  87290. */
  87291. serialize(): any;
  87292. /**
  87293. * Parse properties from a JSON object
  87294. * @param serializationObject defines the JSON object
  87295. * @param scene defines the hosting scene
  87296. */
  87297. parse(serializationObject: any, scene: Scene): void;
  87298. }
  87299. }
  87300. declare module BABYLON {
  87301. /**
  87302. * Interface representing a particle system in Babylon.js.
  87303. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87304. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87305. */
  87306. export interface IParticleSystem {
  87307. /**
  87308. * List of animations used by the particle system.
  87309. */
  87310. animations: Animation[];
  87311. /**
  87312. * The id of the Particle system.
  87313. */
  87314. id: string;
  87315. /**
  87316. * The name of the Particle system.
  87317. */
  87318. name: string;
  87319. /**
  87320. * The emitter represents the Mesh or position we are attaching the particle system to.
  87321. */
  87322. emitter: Nullable<AbstractMesh | Vector3>;
  87323. /**
  87324. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87325. */
  87326. isBillboardBased: boolean;
  87327. /**
  87328. * The rendering group used by the Particle system to chose when to render.
  87329. */
  87330. renderingGroupId: number;
  87331. /**
  87332. * The layer mask we are rendering the particles through.
  87333. */
  87334. layerMask: number;
  87335. /**
  87336. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87337. */
  87338. updateSpeed: number;
  87339. /**
  87340. * The amount of time the particle system is running (depends of the overall update speed).
  87341. */
  87342. targetStopDuration: number;
  87343. /**
  87344. * The texture used to render each particle. (this can be a spritesheet)
  87345. */
  87346. particleTexture: Nullable<Texture>;
  87347. /**
  87348. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87349. */
  87350. blendMode: number;
  87351. /**
  87352. * Minimum life time of emitting particles.
  87353. */
  87354. minLifeTime: number;
  87355. /**
  87356. * Maximum life time of emitting particles.
  87357. */
  87358. maxLifeTime: number;
  87359. /**
  87360. * Minimum Size of emitting particles.
  87361. */
  87362. minSize: number;
  87363. /**
  87364. * Maximum Size of emitting particles.
  87365. */
  87366. maxSize: number;
  87367. /**
  87368. * Minimum scale of emitting particles on X axis.
  87369. */
  87370. minScaleX: number;
  87371. /**
  87372. * Maximum scale of emitting particles on X axis.
  87373. */
  87374. maxScaleX: number;
  87375. /**
  87376. * Minimum scale of emitting particles on Y axis.
  87377. */
  87378. minScaleY: number;
  87379. /**
  87380. * Maximum scale of emitting particles on Y axis.
  87381. */
  87382. maxScaleY: number;
  87383. /**
  87384. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87385. */
  87386. color1: Color4;
  87387. /**
  87388. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87389. */
  87390. color2: Color4;
  87391. /**
  87392. * Color the particle will have at the end of its lifetime.
  87393. */
  87394. colorDead: Color4;
  87395. /**
  87396. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87397. */
  87398. emitRate: number;
  87399. /**
  87400. * You can use gravity if you want to give an orientation to your particles.
  87401. */
  87402. gravity: Vector3;
  87403. /**
  87404. * Minimum power of emitting particles.
  87405. */
  87406. minEmitPower: number;
  87407. /**
  87408. * Maximum power of emitting particles.
  87409. */
  87410. maxEmitPower: number;
  87411. /**
  87412. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87413. */
  87414. minAngularSpeed: number;
  87415. /**
  87416. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87417. */
  87418. maxAngularSpeed: number;
  87419. /**
  87420. * Gets or sets the minimal initial rotation in radians.
  87421. */
  87422. minInitialRotation: number;
  87423. /**
  87424. * Gets or sets the maximal initial rotation in radians.
  87425. */
  87426. maxInitialRotation: number;
  87427. /**
  87428. * The particle emitter type defines the emitter used by the particle system.
  87429. * It can be for example box, sphere, or cone...
  87430. */
  87431. particleEmitterType: Nullable<IParticleEmitterType>;
  87432. /**
  87433. * Defines the delay in milliseconds before starting the system (0 by default)
  87434. */
  87435. startDelay: number;
  87436. /**
  87437. * 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
  87438. */
  87439. preWarmCycles: number;
  87440. /**
  87441. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87442. */
  87443. preWarmStepOffset: number;
  87444. /**
  87445. * 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)
  87446. */
  87447. spriteCellChangeSpeed: number;
  87448. /**
  87449. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87450. */
  87451. startSpriteCellID: number;
  87452. /**
  87453. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87454. */
  87455. endSpriteCellID: number;
  87456. /**
  87457. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87458. */
  87459. spriteCellWidth: number;
  87460. /**
  87461. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87462. */
  87463. spriteCellHeight: number;
  87464. /**
  87465. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87466. */
  87467. spriteRandomStartCell: boolean;
  87468. /**
  87469. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87470. */
  87471. isAnimationSheetEnabled: boolean;
  87472. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87473. translationPivot: Vector2;
  87474. /**
  87475. * Gets or sets a texture used to add random noise to particle positions
  87476. */
  87477. noiseTexture: Nullable<BaseTexture>;
  87478. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87479. noiseStrength: Vector3;
  87480. /**
  87481. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87482. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87483. */
  87484. billboardMode: number;
  87485. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87486. limitVelocityDamping: number;
  87487. /**
  87488. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87489. */
  87490. beginAnimationOnStart: boolean;
  87491. /**
  87492. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87493. */
  87494. beginAnimationFrom: number;
  87495. /**
  87496. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87497. */
  87498. beginAnimationTo: number;
  87499. /**
  87500. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87501. */
  87502. beginAnimationLoop: boolean;
  87503. /**
  87504. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87505. */
  87506. disposeOnStop: boolean;
  87507. /**
  87508. * Specifies if the particles are updated in emitter local space or world space
  87509. */
  87510. isLocal: boolean;
  87511. /** Snippet ID if the particle system was created from the snippet server */
  87512. snippetId: string;
  87513. /**
  87514. * Gets the maximum number of particles active at the same time.
  87515. * @returns The max number of active particles.
  87516. */
  87517. getCapacity(): number;
  87518. /**
  87519. * Gets the number of particles active at the same time.
  87520. * @returns The number of active particles.
  87521. */
  87522. getActiveCount(): number;
  87523. /**
  87524. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87525. * @returns True if it has been started, otherwise false.
  87526. */
  87527. isStarted(): boolean;
  87528. /**
  87529. * Animates the particle system for this frame.
  87530. */
  87531. animate(): void;
  87532. /**
  87533. * Renders the particle system in its current state.
  87534. * @returns the current number of particles
  87535. */
  87536. render(): number;
  87537. /**
  87538. * Dispose the particle system and frees its associated resources.
  87539. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87540. */
  87541. dispose(disposeTexture?: boolean): void;
  87542. /**
  87543. * Clones the particle system.
  87544. * @param name The name of the cloned object
  87545. * @param newEmitter The new emitter to use
  87546. * @returns the cloned particle system
  87547. */
  87548. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87549. /**
  87550. * Serializes the particle system to a JSON object
  87551. * @param serializeTexture defines if the texture must be serialized as well
  87552. * @returns the JSON object
  87553. */
  87554. serialize(serializeTexture: boolean): any;
  87555. /**
  87556. * Rebuild the particle system
  87557. */
  87558. rebuild(): void;
  87559. /** Force the system to rebuild all gradients that need to be resync */
  87560. forceRefreshGradients(): void;
  87561. /**
  87562. * Starts the particle system and begins to emit
  87563. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87564. */
  87565. start(delay?: number): void;
  87566. /**
  87567. * Stops the particle system.
  87568. */
  87569. stop(): void;
  87570. /**
  87571. * Remove all active particles
  87572. */
  87573. reset(): void;
  87574. /**
  87575. * Gets a boolean indicating that the system is stopping
  87576. * @returns true if the system is currently stopping
  87577. */
  87578. isStopping(): boolean;
  87579. /**
  87580. * Is this system ready to be used/rendered
  87581. * @return true if the system is ready
  87582. */
  87583. isReady(): boolean;
  87584. /**
  87585. * Returns the string "ParticleSystem"
  87586. * @returns a string containing the class name
  87587. */
  87588. getClassName(): string;
  87589. /**
  87590. * Adds a new color gradient
  87591. * @param gradient defines the gradient to use (between 0 and 1)
  87592. * @param color1 defines the color to affect to the specified gradient
  87593. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87594. * @returns the current particle system
  87595. */
  87596. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87597. /**
  87598. * Remove a specific color gradient
  87599. * @param gradient defines the gradient to remove
  87600. * @returns the current particle system
  87601. */
  87602. removeColorGradient(gradient: number): IParticleSystem;
  87603. /**
  87604. * Adds a new size gradient
  87605. * @param gradient defines the gradient to use (between 0 and 1)
  87606. * @param factor defines the size factor to affect to the specified gradient
  87607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87608. * @returns the current particle system
  87609. */
  87610. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87611. /**
  87612. * Remove a specific size gradient
  87613. * @param gradient defines the gradient to remove
  87614. * @returns the current particle system
  87615. */
  87616. removeSizeGradient(gradient: number): IParticleSystem;
  87617. /**
  87618. * Gets the current list of color gradients.
  87619. * You must use addColorGradient and removeColorGradient to udpate this list
  87620. * @returns the list of color gradients
  87621. */
  87622. getColorGradients(): Nullable<Array<ColorGradient>>;
  87623. /**
  87624. * Gets the current list of size gradients.
  87625. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87626. * @returns the list of size gradients
  87627. */
  87628. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87629. /**
  87630. * Gets the current list of angular speed gradients.
  87631. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87632. * @returns the list of angular speed gradients
  87633. */
  87634. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87635. /**
  87636. * Adds a new angular speed gradient
  87637. * @param gradient defines the gradient to use (between 0 and 1)
  87638. * @param factor defines the angular speed to affect to the specified gradient
  87639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87640. * @returns the current particle system
  87641. */
  87642. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87643. /**
  87644. * Remove a specific angular speed gradient
  87645. * @param gradient defines the gradient to remove
  87646. * @returns the current particle system
  87647. */
  87648. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87649. /**
  87650. * Gets the current list of velocity gradients.
  87651. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87652. * @returns the list of velocity gradients
  87653. */
  87654. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87655. /**
  87656. * Adds a new velocity gradient
  87657. * @param gradient defines the gradient to use (between 0 and 1)
  87658. * @param factor defines the velocity to affect to the specified gradient
  87659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87660. * @returns the current particle system
  87661. */
  87662. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87663. /**
  87664. * Remove a specific velocity gradient
  87665. * @param gradient defines the gradient to remove
  87666. * @returns the current particle system
  87667. */
  87668. removeVelocityGradient(gradient: number): IParticleSystem;
  87669. /**
  87670. * Gets the current list of limit velocity gradients.
  87671. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87672. * @returns the list of limit velocity gradients
  87673. */
  87674. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87675. /**
  87676. * Adds a new limit velocity gradient
  87677. * @param gradient defines the gradient to use (between 0 and 1)
  87678. * @param factor defines the limit velocity to affect to the specified gradient
  87679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87680. * @returns the current particle system
  87681. */
  87682. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87683. /**
  87684. * Remove a specific limit velocity gradient
  87685. * @param gradient defines the gradient to remove
  87686. * @returns the current particle system
  87687. */
  87688. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87689. /**
  87690. * Adds a new drag gradient
  87691. * @param gradient defines the gradient to use (between 0 and 1)
  87692. * @param factor defines the drag to affect to the specified gradient
  87693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87694. * @returns the current particle system
  87695. */
  87696. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87697. /**
  87698. * Remove a specific drag gradient
  87699. * @param gradient defines the gradient to remove
  87700. * @returns the current particle system
  87701. */
  87702. removeDragGradient(gradient: number): IParticleSystem;
  87703. /**
  87704. * Gets the current list of drag gradients.
  87705. * You must use addDragGradient and removeDragGradient to udpate this list
  87706. * @returns the list of drag gradients
  87707. */
  87708. getDragGradients(): Nullable<Array<FactorGradient>>;
  87709. /**
  87710. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87711. * @param gradient defines the gradient to use (between 0 and 1)
  87712. * @param factor defines the emit rate to affect to the specified gradient
  87713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87714. * @returns the current particle system
  87715. */
  87716. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87717. /**
  87718. * Remove a specific emit rate gradient
  87719. * @param gradient defines the gradient to remove
  87720. * @returns the current particle system
  87721. */
  87722. removeEmitRateGradient(gradient: number): IParticleSystem;
  87723. /**
  87724. * Gets the current list of emit rate gradients.
  87725. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87726. * @returns the list of emit rate gradients
  87727. */
  87728. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87729. /**
  87730. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87731. * @param gradient defines the gradient to use (between 0 and 1)
  87732. * @param factor defines the start size to affect to the specified gradient
  87733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87734. * @returns the current particle system
  87735. */
  87736. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87737. /**
  87738. * Remove a specific start size gradient
  87739. * @param gradient defines the gradient to remove
  87740. * @returns the current particle system
  87741. */
  87742. removeStartSizeGradient(gradient: number): IParticleSystem;
  87743. /**
  87744. * Gets the current list of start size gradients.
  87745. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87746. * @returns the list of start size gradients
  87747. */
  87748. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87749. /**
  87750. * Adds a new life time gradient
  87751. * @param gradient defines the gradient to use (between 0 and 1)
  87752. * @param factor defines the life time factor to affect to the specified gradient
  87753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87754. * @returns the current particle system
  87755. */
  87756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87757. /**
  87758. * Remove a specific life time gradient
  87759. * @param gradient defines the gradient to remove
  87760. * @returns the current particle system
  87761. */
  87762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87763. /**
  87764. * Gets the current list of life time gradients.
  87765. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87766. * @returns the list of life time gradients
  87767. */
  87768. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87769. /**
  87770. * Gets the current list of color gradients.
  87771. * You must use addColorGradient and removeColorGradient to udpate this list
  87772. * @returns the list of color gradients
  87773. */
  87774. getColorGradients(): Nullable<Array<ColorGradient>>;
  87775. /**
  87776. * Adds a new ramp gradient used to remap particle colors
  87777. * @param gradient defines the gradient to use (between 0 and 1)
  87778. * @param color defines the color to affect to the specified gradient
  87779. * @returns the current particle system
  87780. */
  87781. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87782. /**
  87783. * Gets the current list of ramp gradients.
  87784. * You must use addRampGradient and removeRampGradient to udpate this list
  87785. * @returns the list of ramp gradients
  87786. */
  87787. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87788. /** Gets or sets a boolean indicating that ramp gradients must be used
  87789. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87790. */
  87791. useRampGradients: boolean;
  87792. /**
  87793. * Adds a new color remap gradient
  87794. * @param gradient defines the gradient to use (between 0 and 1)
  87795. * @param min defines the color remap minimal range
  87796. * @param max defines the color remap maximal range
  87797. * @returns the current particle system
  87798. */
  87799. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87800. /**
  87801. * Gets the current list of color remap gradients.
  87802. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87803. * @returns the list of color remap gradients
  87804. */
  87805. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87806. /**
  87807. * Adds a new alpha remap gradient
  87808. * @param gradient defines the gradient to use (between 0 and 1)
  87809. * @param min defines the alpha remap minimal range
  87810. * @param max defines the alpha remap maximal range
  87811. * @returns the current particle system
  87812. */
  87813. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87814. /**
  87815. * Gets the current list of alpha remap gradients.
  87816. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87817. * @returns the list of alpha remap gradients
  87818. */
  87819. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87820. /**
  87821. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87824. * @returns the emitter
  87825. */
  87826. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87827. /**
  87828. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87829. * @param radius The radius of the hemisphere to emit from
  87830. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87831. * @returns the emitter
  87832. */
  87833. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87834. /**
  87835. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87836. * @param radius The radius of the sphere to emit from
  87837. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87838. * @returns the emitter
  87839. */
  87840. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87841. /**
  87842. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87843. * @param radius The radius of the sphere to emit from
  87844. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87845. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87846. * @returns the emitter
  87847. */
  87848. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87849. /**
  87850. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87851. * @param radius The radius of the emission cylinder
  87852. * @param height The height of the emission cylinder
  87853. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87854. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87855. * @returns the emitter
  87856. */
  87857. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87858. /**
  87859. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87860. * @param radius The radius of the cylinder to emit from
  87861. * @param height The height of the emission cylinder
  87862. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87865. * @returns the emitter
  87866. */
  87867. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87868. /**
  87869. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87870. * @param radius The radius of the cone to emit from
  87871. * @param angle The base angle of the cone
  87872. * @returns the emitter
  87873. */
  87874. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87875. /**
  87876. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87879. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87880. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87881. * @returns the emitter
  87882. */
  87883. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87884. /**
  87885. * Get hosting scene
  87886. * @returns the scene
  87887. */
  87888. getScene(): Scene;
  87889. }
  87890. }
  87891. declare module BABYLON {
  87892. /**
  87893. * 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.
  87894. * @see https://doc.babylonjs.com/how_to/transformnode
  87895. */
  87896. export class TransformNode extends Node {
  87897. /**
  87898. * Object will not rotate to face the camera
  87899. */
  87900. static BILLBOARDMODE_NONE: number;
  87901. /**
  87902. * Object will rotate to face the camera but only on the x axis
  87903. */
  87904. static BILLBOARDMODE_X: number;
  87905. /**
  87906. * Object will rotate to face the camera but only on the y axis
  87907. */
  87908. static BILLBOARDMODE_Y: number;
  87909. /**
  87910. * Object will rotate to face the camera but only on the z axis
  87911. */
  87912. static BILLBOARDMODE_Z: number;
  87913. /**
  87914. * Object will rotate to face the camera
  87915. */
  87916. static BILLBOARDMODE_ALL: number;
  87917. /**
  87918. * Object will rotate to face the camera's position instead of orientation
  87919. */
  87920. static BILLBOARDMODE_USE_POSITION: number;
  87921. private _forward;
  87922. private _forwardInverted;
  87923. private _up;
  87924. private _right;
  87925. private _rightInverted;
  87926. private _position;
  87927. private _rotation;
  87928. private _rotationQuaternion;
  87929. protected _scaling: Vector3;
  87930. protected _isDirty: boolean;
  87931. private _transformToBoneReferal;
  87932. private _isAbsoluteSynced;
  87933. private _billboardMode;
  87934. /**
  87935. * Gets or sets the billboard mode. Default is 0.
  87936. *
  87937. * | Value | Type | Description |
  87938. * | --- | --- | --- |
  87939. * | 0 | BILLBOARDMODE_NONE | |
  87940. * | 1 | BILLBOARDMODE_X | |
  87941. * | 2 | BILLBOARDMODE_Y | |
  87942. * | 4 | BILLBOARDMODE_Z | |
  87943. * | 7 | BILLBOARDMODE_ALL | |
  87944. *
  87945. */
  87946. get billboardMode(): number;
  87947. set billboardMode(value: number);
  87948. private _preserveParentRotationForBillboard;
  87949. /**
  87950. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87951. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87952. */
  87953. get preserveParentRotationForBillboard(): boolean;
  87954. set preserveParentRotationForBillboard(value: boolean);
  87955. /**
  87956. * 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
  87957. */
  87958. scalingDeterminant: number;
  87959. private _infiniteDistance;
  87960. /**
  87961. * Gets or sets the distance of the object to max, often used by skybox
  87962. */
  87963. get infiniteDistance(): boolean;
  87964. set infiniteDistance(value: boolean);
  87965. /**
  87966. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87967. * By default the system will update normals to compensate
  87968. */
  87969. ignoreNonUniformScaling: boolean;
  87970. /**
  87971. * 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
  87972. */
  87973. reIntegrateRotationIntoRotationQuaternion: boolean;
  87974. /** @hidden */
  87975. _poseMatrix: Nullable<Matrix>;
  87976. /** @hidden */
  87977. _localMatrix: Matrix;
  87978. private _usePivotMatrix;
  87979. private _absolutePosition;
  87980. private _absoluteScaling;
  87981. private _absoluteRotationQuaternion;
  87982. private _pivotMatrix;
  87983. private _pivotMatrixInverse;
  87984. protected _postMultiplyPivotMatrix: boolean;
  87985. protected _isWorldMatrixFrozen: boolean;
  87986. /** @hidden */
  87987. _indexInSceneTransformNodesArray: number;
  87988. /**
  87989. * An event triggered after the world matrix is updated
  87990. */
  87991. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87992. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87993. /**
  87994. * Gets a string identifying the name of the class
  87995. * @returns "TransformNode" string
  87996. */
  87997. getClassName(): string;
  87998. /**
  87999. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  88000. */
  88001. get position(): Vector3;
  88002. set position(newPosition: Vector3);
  88003. /**
  88004. * 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)).
  88005. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  88006. */
  88007. get rotation(): Vector3;
  88008. set rotation(newRotation: Vector3);
  88009. /**
  88010. * 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)).
  88011. */
  88012. get scaling(): Vector3;
  88013. set scaling(newScaling: Vector3);
  88014. /**
  88015. * 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).
  88016. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  88017. */
  88018. get rotationQuaternion(): Nullable<Quaternion>;
  88019. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  88020. /**
  88021. * The forward direction of that transform in world space.
  88022. */
  88023. get forward(): Vector3;
  88024. /**
  88025. * The up direction of that transform in world space.
  88026. */
  88027. get up(): Vector3;
  88028. /**
  88029. * The right direction of that transform in world space.
  88030. */
  88031. get right(): Vector3;
  88032. /**
  88033. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88034. * @param matrix the matrix to copy the pose from
  88035. * @returns this TransformNode.
  88036. */
  88037. updatePoseMatrix(matrix: Matrix): TransformNode;
  88038. /**
  88039. * Returns the mesh Pose matrix.
  88040. * @returns the pose matrix
  88041. */
  88042. getPoseMatrix(): Matrix;
  88043. /** @hidden */
  88044. _isSynchronized(): boolean;
  88045. /** @hidden */
  88046. _initCache(): void;
  88047. /**
  88048. * Flag the transform node as dirty (Forcing it to update everything)
  88049. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88050. * @returns this transform node
  88051. */
  88052. markAsDirty(property: string): TransformNode;
  88053. /**
  88054. * Returns the current mesh absolute position.
  88055. * Returns a Vector3.
  88056. */
  88057. get absolutePosition(): Vector3;
  88058. /**
  88059. * Returns the current mesh absolute scaling.
  88060. * Returns a Vector3.
  88061. */
  88062. get absoluteScaling(): Vector3;
  88063. /**
  88064. * Returns the current mesh absolute rotation.
  88065. * Returns a Quaternion.
  88066. */
  88067. get absoluteRotationQuaternion(): Quaternion;
  88068. /**
  88069. * Sets a new matrix to apply before all other transformation
  88070. * @param matrix defines the transform matrix
  88071. * @returns the current TransformNode
  88072. */
  88073. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88074. /**
  88075. * Sets a new pivot matrix to the current node
  88076. * @param matrix defines the new pivot matrix to use
  88077. * @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
  88078. * @returns the current TransformNode
  88079. */
  88080. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88081. /**
  88082. * Returns the mesh pivot matrix.
  88083. * Default : Identity.
  88084. * @returns the matrix
  88085. */
  88086. getPivotMatrix(): Matrix;
  88087. /**
  88088. * Instantiate (when possible) or clone that node with its hierarchy
  88089. * @param newParent defines the new parent to use for the instance (or clone)
  88090. * @param options defines options to configure how copy is done
  88091. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88092. * @returns an instance (or a clone) of the current node with its hiearchy
  88093. */
  88094. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88095. doNotInstantiate: boolean;
  88096. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88097. /**
  88098. * Prevents the World matrix to be computed any longer
  88099. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88100. * @returns the TransformNode.
  88101. */
  88102. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88103. /**
  88104. * Allows back the World matrix computation.
  88105. * @returns the TransformNode.
  88106. */
  88107. unfreezeWorldMatrix(): this;
  88108. /**
  88109. * True if the World matrix has been frozen.
  88110. */
  88111. get isWorldMatrixFrozen(): boolean;
  88112. /**
  88113. * Retuns the mesh absolute position in the World.
  88114. * @returns a Vector3.
  88115. */
  88116. getAbsolutePosition(): Vector3;
  88117. /**
  88118. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88119. * @param absolutePosition the absolute position to set
  88120. * @returns the TransformNode.
  88121. */
  88122. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88123. /**
  88124. * Sets the mesh position in its local space.
  88125. * @param vector3 the position to set in localspace
  88126. * @returns the TransformNode.
  88127. */
  88128. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88129. /**
  88130. * Returns the mesh position in the local space from the current World matrix values.
  88131. * @returns a new Vector3.
  88132. */
  88133. getPositionExpressedInLocalSpace(): Vector3;
  88134. /**
  88135. * Translates the mesh along the passed Vector3 in its local space.
  88136. * @param vector3 the distance to translate in localspace
  88137. * @returns the TransformNode.
  88138. */
  88139. locallyTranslate(vector3: Vector3): TransformNode;
  88140. private static _lookAtVectorCache;
  88141. /**
  88142. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88143. * @param targetPoint the position (must be in same space as current mesh) to look at
  88144. * @param yawCor optional yaw (y-axis) correction in radians
  88145. * @param pitchCor optional pitch (x-axis) correction in radians
  88146. * @param rollCor optional roll (z-axis) correction in radians
  88147. * @param space the choosen space of the target
  88148. * @returns the TransformNode.
  88149. */
  88150. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88151. /**
  88152. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88153. * This Vector3 is expressed in the World space.
  88154. * @param localAxis axis to rotate
  88155. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88156. */
  88157. getDirection(localAxis: Vector3): Vector3;
  88158. /**
  88159. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88160. * localAxis is expressed in the mesh local space.
  88161. * result is computed in the Wordl space from the mesh World matrix.
  88162. * @param localAxis axis to rotate
  88163. * @param result the resulting transformnode
  88164. * @returns this TransformNode.
  88165. */
  88166. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88167. /**
  88168. * Sets this transform node rotation to the given local axis.
  88169. * @param localAxis the axis in local space
  88170. * @param yawCor optional yaw (y-axis) correction in radians
  88171. * @param pitchCor optional pitch (x-axis) correction in radians
  88172. * @param rollCor optional roll (z-axis) correction in radians
  88173. * @returns this TransformNode
  88174. */
  88175. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88176. /**
  88177. * Sets a new pivot point to the current node
  88178. * @param point defines the new pivot point to use
  88179. * @param space defines if the point is in world or local space (local by default)
  88180. * @returns the current TransformNode
  88181. */
  88182. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88183. /**
  88184. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88185. * @returns the pivot point
  88186. */
  88187. getPivotPoint(): Vector3;
  88188. /**
  88189. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88190. * @param result the vector3 to store the result
  88191. * @returns this TransformNode.
  88192. */
  88193. getPivotPointToRef(result: Vector3): TransformNode;
  88194. /**
  88195. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88196. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88197. */
  88198. getAbsolutePivotPoint(): Vector3;
  88199. /**
  88200. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88201. * @param result vector3 to store the result
  88202. * @returns this TransformNode.
  88203. */
  88204. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88205. /**
  88206. * Defines the passed node as the parent of the current node.
  88207. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88208. * @see https://doc.babylonjs.com/how_to/parenting
  88209. * @param node the node ot set as the parent
  88210. * @returns this TransformNode.
  88211. */
  88212. setParent(node: Nullable<Node>): TransformNode;
  88213. private _nonUniformScaling;
  88214. /**
  88215. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88216. */
  88217. get nonUniformScaling(): boolean;
  88218. /** @hidden */
  88219. _updateNonUniformScalingState(value: boolean): boolean;
  88220. /**
  88221. * Attach the current TransformNode to another TransformNode associated with a bone
  88222. * @param bone Bone affecting the TransformNode
  88223. * @param affectedTransformNode TransformNode associated with the bone
  88224. * @returns this object
  88225. */
  88226. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88227. /**
  88228. * Detach the transform node if its associated with a bone
  88229. * @returns this object
  88230. */
  88231. detachFromBone(): TransformNode;
  88232. private static _rotationAxisCache;
  88233. /**
  88234. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88235. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88236. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88237. * The passed axis is also normalized.
  88238. * @param axis the axis to rotate around
  88239. * @param amount the amount to rotate in radians
  88240. * @param space Space to rotate in (Default: local)
  88241. * @returns the TransformNode.
  88242. */
  88243. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88244. /**
  88245. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88246. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88247. * The passed axis is also normalized. .
  88248. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88249. * @param point the point to rotate around
  88250. * @param axis the axis to rotate around
  88251. * @param amount the amount to rotate in radians
  88252. * @returns the TransformNode
  88253. */
  88254. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88255. /**
  88256. * Translates the mesh along the axis vector for the passed distance in the given space.
  88257. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88258. * @param axis the axis to translate in
  88259. * @param distance the distance to translate
  88260. * @param space Space to rotate in (Default: local)
  88261. * @returns the TransformNode.
  88262. */
  88263. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88264. /**
  88265. * Adds a rotation step to the mesh current rotation.
  88266. * x, y, z are Euler angles expressed in radians.
  88267. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88268. * This means this rotation is made in the mesh local space only.
  88269. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88270. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88271. * ```javascript
  88272. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88273. * ```
  88274. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88275. * 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.
  88276. * @param x Rotation to add
  88277. * @param y Rotation to add
  88278. * @param z Rotation to add
  88279. * @returns the TransformNode.
  88280. */
  88281. addRotation(x: number, y: number, z: number): TransformNode;
  88282. /**
  88283. * @hidden
  88284. */
  88285. protected _getEffectiveParent(): Nullable<Node>;
  88286. /**
  88287. * Computes the world matrix of the node
  88288. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88289. * @returns the world matrix
  88290. */
  88291. computeWorldMatrix(force?: boolean): Matrix;
  88292. /**
  88293. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88294. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88295. */
  88296. resetLocalMatrix(independentOfChildren?: boolean): void;
  88297. protected _afterComputeWorldMatrix(): void;
  88298. /**
  88299. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88300. * @param func callback function to add
  88301. *
  88302. * @returns the TransformNode.
  88303. */
  88304. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88305. /**
  88306. * Removes a registered callback function.
  88307. * @param func callback function to remove
  88308. * @returns the TransformNode.
  88309. */
  88310. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88311. /**
  88312. * Gets the position of the current mesh in camera space
  88313. * @param camera defines the camera to use
  88314. * @returns a position
  88315. */
  88316. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88317. /**
  88318. * Returns the distance from the mesh to the active camera
  88319. * @param camera defines the camera to use
  88320. * @returns the distance
  88321. */
  88322. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88323. /**
  88324. * Clone the current transform node
  88325. * @param name Name of the new clone
  88326. * @param newParent New parent for the clone
  88327. * @param doNotCloneChildren Do not clone children hierarchy
  88328. * @returns the new transform node
  88329. */
  88330. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88331. /**
  88332. * Serializes the objects information.
  88333. * @param currentSerializationObject defines the object to serialize in
  88334. * @returns the serialized object
  88335. */
  88336. serialize(currentSerializationObject?: any): any;
  88337. /**
  88338. * Returns a new TransformNode object parsed from the source provided.
  88339. * @param parsedTransformNode is the source.
  88340. * @param scene the scne the object belongs to
  88341. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88342. * @returns a new TransformNode object parsed from the source provided.
  88343. */
  88344. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88345. /**
  88346. * Get all child-transformNodes of this node
  88347. * @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
  88348. * @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
  88349. * @returns an array of TransformNode
  88350. */
  88351. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88352. /**
  88353. * Releases resources associated with this transform node.
  88354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88356. */
  88357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88358. /**
  88359. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88360. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88361. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88362. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88363. * @returns the current mesh
  88364. */
  88365. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88366. private _syncAbsoluteScalingAndRotation;
  88367. }
  88368. }
  88369. declare module BABYLON {
  88370. /**
  88371. * Class used to override all child animations of a given target
  88372. */
  88373. export class AnimationPropertiesOverride {
  88374. /**
  88375. * Gets or sets a value indicating if animation blending must be used
  88376. */
  88377. enableBlending: boolean;
  88378. /**
  88379. * Gets or sets the blending speed to use when enableBlending is true
  88380. */
  88381. blendingSpeed: number;
  88382. /**
  88383. * Gets or sets the default loop mode to use
  88384. */
  88385. loopMode: number;
  88386. }
  88387. }
  88388. declare module BABYLON {
  88389. /**
  88390. * Class used to store bone information
  88391. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88392. */
  88393. export class Bone extends Node {
  88394. /**
  88395. * defines the bone name
  88396. */
  88397. name: string;
  88398. private static _tmpVecs;
  88399. private static _tmpQuat;
  88400. private static _tmpMats;
  88401. /**
  88402. * Gets the list of child bones
  88403. */
  88404. children: Bone[];
  88405. /** Gets the animations associated with this bone */
  88406. animations: Animation[];
  88407. /**
  88408. * Gets or sets bone length
  88409. */
  88410. length: number;
  88411. /**
  88412. * @hidden Internal only
  88413. * Set this value to map this bone to a different index in the transform matrices
  88414. * Set this value to -1 to exclude the bone from the transform matrices
  88415. */
  88416. _index: Nullable<number>;
  88417. private _skeleton;
  88418. private _localMatrix;
  88419. private _restPose;
  88420. private _baseMatrix;
  88421. private _absoluteTransform;
  88422. private _invertedAbsoluteTransform;
  88423. private _parent;
  88424. private _scalingDeterminant;
  88425. private _worldTransform;
  88426. private _localScaling;
  88427. private _localRotation;
  88428. private _localPosition;
  88429. private _needToDecompose;
  88430. private _needToCompose;
  88431. /** @hidden */
  88432. _linkedTransformNode: Nullable<TransformNode>;
  88433. /** @hidden */
  88434. _waitingTransformNodeId: Nullable<string>;
  88435. /** @hidden */
  88436. get _matrix(): Matrix;
  88437. /** @hidden */
  88438. set _matrix(value: Matrix);
  88439. /**
  88440. * Create a new bone
  88441. * @param name defines the bone name
  88442. * @param skeleton defines the parent skeleton
  88443. * @param parentBone defines the parent (can be null if the bone is the root)
  88444. * @param localMatrix defines the local matrix
  88445. * @param restPose defines the rest pose matrix
  88446. * @param baseMatrix defines the base matrix
  88447. * @param index defines index of the bone in the hiearchy
  88448. */
  88449. constructor(
  88450. /**
  88451. * defines the bone name
  88452. */
  88453. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88454. /**
  88455. * Gets the current object class name.
  88456. * @return the class name
  88457. */
  88458. getClassName(): string;
  88459. /**
  88460. * Gets the parent skeleton
  88461. * @returns a skeleton
  88462. */
  88463. getSkeleton(): Skeleton;
  88464. /**
  88465. * Gets parent bone
  88466. * @returns a bone or null if the bone is the root of the bone hierarchy
  88467. */
  88468. getParent(): Nullable<Bone>;
  88469. /**
  88470. * Returns an array containing the root bones
  88471. * @returns an array containing the root bones
  88472. */
  88473. getChildren(): Array<Bone>;
  88474. /**
  88475. * Gets the node index in matrix array generated for rendering
  88476. * @returns the node index
  88477. */
  88478. getIndex(): number;
  88479. /**
  88480. * Sets the parent bone
  88481. * @param parent defines the parent (can be null if the bone is the root)
  88482. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88483. */
  88484. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88485. /**
  88486. * Gets the local matrix
  88487. * @returns a matrix
  88488. */
  88489. getLocalMatrix(): Matrix;
  88490. /**
  88491. * Gets the base matrix (initial matrix which remains unchanged)
  88492. * @returns a matrix
  88493. */
  88494. getBaseMatrix(): Matrix;
  88495. /**
  88496. * Gets the rest pose matrix
  88497. * @returns a matrix
  88498. */
  88499. getRestPose(): Matrix;
  88500. /**
  88501. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88502. */
  88503. getWorldMatrix(): Matrix;
  88504. /**
  88505. * Sets the local matrix to rest pose matrix
  88506. */
  88507. returnToRest(): void;
  88508. /**
  88509. * Gets the inverse of the absolute transform matrix.
  88510. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88511. * @returns a matrix
  88512. */
  88513. getInvertedAbsoluteTransform(): Matrix;
  88514. /**
  88515. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88516. * @returns a matrix
  88517. */
  88518. getAbsoluteTransform(): Matrix;
  88519. /**
  88520. * Links with the given transform node.
  88521. * The local matrix of this bone is copied from the transform node every frame.
  88522. * @param transformNode defines the transform node to link to
  88523. */
  88524. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88525. /**
  88526. * Gets the node used to drive the bone's transformation
  88527. * @returns a transform node or null
  88528. */
  88529. getTransformNode(): Nullable<TransformNode>;
  88530. /** Gets or sets current position (in local space) */
  88531. get position(): Vector3;
  88532. set position(newPosition: Vector3);
  88533. /** Gets or sets current rotation (in local space) */
  88534. get rotation(): Vector3;
  88535. set rotation(newRotation: Vector3);
  88536. /** Gets or sets current rotation quaternion (in local space) */
  88537. get rotationQuaternion(): Quaternion;
  88538. set rotationQuaternion(newRotation: Quaternion);
  88539. /** Gets or sets current scaling (in local space) */
  88540. get scaling(): Vector3;
  88541. set scaling(newScaling: Vector3);
  88542. /**
  88543. * Gets the animation properties override
  88544. */
  88545. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88546. private _decompose;
  88547. private _compose;
  88548. /**
  88549. * Update the base and local matrices
  88550. * @param matrix defines the new base or local matrix
  88551. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88552. * @param updateLocalMatrix defines if the local matrix should be updated
  88553. */
  88554. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88555. /** @hidden */
  88556. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88557. /**
  88558. * Flag the bone as dirty (Forcing it to update everything)
  88559. */
  88560. markAsDirty(): void;
  88561. /** @hidden */
  88562. _markAsDirtyAndCompose(): void;
  88563. private _markAsDirtyAndDecompose;
  88564. /**
  88565. * Translate the bone in local or world space
  88566. * @param vec The amount to translate the bone
  88567. * @param space The space that the translation is in
  88568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88569. */
  88570. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88571. /**
  88572. * Set the postion of the bone in local or world space
  88573. * @param position The position to set the bone
  88574. * @param space The space that the position is in
  88575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88576. */
  88577. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88578. /**
  88579. * Set the absolute position of the bone (world space)
  88580. * @param position The position to set the bone
  88581. * @param mesh The mesh that this bone is attached to
  88582. */
  88583. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88584. /**
  88585. * Scale the bone on the x, y and z axes (in local space)
  88586. * @param x The amount to scale the bone on the x axis
  88587. * @param y The amount to scale the bone on the y axis
  88588. * @param z The amount to scale the bone on the z axis
  88589. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88590. */
  88591. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88592. /**
  88593. * Set the bone scaling in local space
  88594. * @param scale defines the scaling vector
  88595. */
  88596. setScale(scale: Vector3): void;
  88597. /**
  88598. * Gets the current scaling in local space
  88599. * @returns the current scaling vector
  88600. */
  88601. getScale(): Vector3;
  88602. /**
  88603. * Gets the current scaling in local space and stores it in a target vector
  88604. * @param result defines the target vector
  88605. */
  88606. getScaleToRef(result: Vector3): void;
  88607. /**
  88608. * Set the yaw, pitch, and roll of the bone in local or world space
  88609. * @param yaw The rotation of the bone on the y axis
  88610. * @param pitch The rotation of the bone on the x axis
  88611. * @param roll The rotation of the bone on the z axis
  88612. * @param space The space that the axes of rotation are in
  88613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88614. */
  88615. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88616. /**
  88617. * Add a rotation to the bone on an axis in local or world space
  88618. * @param axis The axis to rotate the bone on
  88619. * @param amount The amount to rotate the bone
  88620. * @param space The space that the axis is in
  88621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88622. */
  88623. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88624. /**
  88625. * Set the rotation of the bone to a particular axis angle in local or world space
  88626. * @param axis The axis to rotate the bone on
  88627. * @param angle The angle that the bone should be rotated to
  88628. * @param space The space that the axis is in
  88629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88630. */
  88631. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88632. /**
  88633. * Set the euler rotation of the bone in local of world space
  88634. * @param rotation The euler rotation that the bone should be set to
  88635. * @param space The space that the rotation is in
  88636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88637. */
  88638. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88639. /**
  88640. * Set the quaternion rotation of the bone in local of world space
  88641. * @param quat The quaternion rotation that the bone should be set to
  88642. * @param space The space that the rotation is in
  88643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88644. */
  88645. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88646. /**
  88647. * Set the rotation matrix of the bone in local of world space
  88648. * @param rotMat The rotation matrix that the bone should be set to
  88649. * @param space The space that the rotation is in
  88650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88651. */
  88652. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88653. private _rotateWithMatrix;
  88654. private _getNegativeRotationToRef;
  88655. /**
  88656. * Get the position of the bone in local or world space
  88657. * @param space The space that the returned position is in
  88658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88659. * @returns The position of the bone
  88660. */
  88661. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88662. /**
  88663. * Copy the position of the bone to a vector3 in local or world space
  88664. * @param space The space that the returned position is in
  88665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88666. * @param result The vector3 to copy the position to
  88667. */
  88668. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88669. /**
  88670. * Get the absolute position of the bone (world space)
  88671. * @param mesh The mesh that this bone is attached to
  88672. * @returns The absolute position of the bone
  88673. */
  88674. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88675. /**
  88676. * Copy the absolute position of the bone (world space) to the result param
  88677. * @param mesh The mesh that this bone is attached to
  88678. * @param result The vector3 to copy the absolute position to
  88679. */
  88680. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88681. /**
  88682. * Compute the absolute transforms of this bone and its children
  88683. */
  88684. computeAbsoluteTransforms(): void;
  88685. /**
  88686. * Get the world direction from an axis that is in the local space of the bone
  88687. * @param localAxis The local direction that is used to compute the world direction
  88688. * @param mesh The mesh that this bone is attached to
  88689. * @returns The world direction
  88690. */
  88691. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88692. /**
  88693. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88694. * @param localAxis The local direction that is used to compute the world direction
  88695. * @param mesh The mesh that this bone is attached to
  88696. * @param result The vector3 that the world direction will be copied to
  88697. */
  88698. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88699. /**
  88700. * Get the euler rotation of the bone in local or world space
  88701. * @param space The space that the rotation should be in
  88702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88703. * @returns The euler rotation
  88704. */
  88705. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88706. /**
  88707. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88708. * @param space The space that the rotation should be in
  88709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88710. * @param result The vector3 that the rotation should be copied to
  88711. */
  88712. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88713. /**
  88714. * Get the quaternion rotation of the bone in either local or world space
  88715. * @param space The space that the rotation should be in
  88716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88717. * @returns The quaternion rotation
  88718. */
  88719. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88720. /**
  88721. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88722. * @param space The space that the rotation should be in
  88723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88724. * @param result The quaternion that the rotation should be copied to
  88725. */
  88726. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88727. /**
  88728. * Get the rotation matrix of the bone in local or world space
  88729. * @param space The space that the rotation should be in
  88730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88731. * @returns The rotation matrix
  88732. */
  88733. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88734. /**
  88735. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  88736. * @param space The space that the rotation should be in
  88737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88738. * @param result The quaternion that the rotation should be copied to
  88739. */
  88740. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88741. /**
  88742. * Get the world position of a point that is in the local space of the bone
  88743. * @param position The local position
  88744. * @param mesh The mesh that this bone is attached to
  88745. * @returns The world position
  88746. */
  88747. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88748. /**
  88749. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88750. * @param position The local position
  88751. * @param mesh The mesh that this bone is attached to
  88752. * @param result The vector3 that the world position should be copied to
  88753. */
  88754. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88755. /**
  88756. * Get the local position of a point that is in world space
  88757. * @param position The world position
  88758. * @param mesh The mesh that this bone is attached to
  88759. * @returns The local position
  88760. */
  88761. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88762. /**
  88763. * Get the local position of a point that is in world space and copy it to the result param
  88764. * @param position The world position
  88765. * @param mesh The mesh that this bone is attached to
  88766. * @param result The vector3 that the local position should be copied to
  88767. */
  88768. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88769. }
  88770. }
  88771. declare module BABYLON {
  88772. /**
  88773. * Defines a runtime animation
  88774. */
  88775. export class RuntimeAnimation {
  88776. private _events;
  88777. /**
  88778. * The current frame of the runtime animation
  88779. */
  88780. private _currentFrame;
  88781. /**
  88782. * The animation used by the runtime animation
  88783. */
  88784. private _animation;
  88785. /**
  88786. * The target of the runtime animation
  88787. */
  88788. private _target;
  88789. /**
  88790. * The initiating animatable
  88791. */
  88792. private _host;
  88793. /**
  88794. * The original value of the runtime animation
  88795. */
  88796. private _originalValue;
  88797. /**
  88798. * The original blend value of the runtime animation
  88799. */
  88800. private _originalBlendValue;
  88801. /**
  88802. * The offsets cache of the runtime animation
  88803. */
  88804. private _offsetsCache;
  88805. /**
  88806. * The high limits cache of the runtime animation
  88807. */
  88808. private _highLimitsCache;
  88809. /**
  88810. * Specifies if the runtime animation has been stopped
  88811. */
  88812. private _stopped;
  88813. /**
  88814. * The blending factor of the runtime animation
  88815. */
  88816. private _blendingFactor;
  88817. /**
  88818. * The BabylonJS scene
  88819. */
  88820. private _scene;
  88821. /**
  88822. * The current value of the runtime animation
  88823. */
  88824. private _currentValue;
  88825. /** @hidden */
  88826. _animationState: _IAnimationState;
  88827. /**
  88828. * The active target of the runtime animation
  88829. */
  88830. private _activeTargets;
  88831. private _currentActiveTarget;
  88832. private _directTarget;
  88833. /**
  88834. * The target path of the runtime animation
  88835. */
  88836. private _targetPath;
  88837. /**
  88838. * The weight of the runtime animation
  88839. */
  88840. private _weight;
  88841. /**
  88842. * The ratio offset of the runtime animation
  88843. */
  88844. private _ratioOffset;
  88845. /**
  88846. * The previous delay of the runtime animation
  88847. */
  88848. private _previousDelay;
  88849. /**
  88850. * The previous ratio of the runtime animation
  88851. */
  88852. private _previousRatio;
  88853. private _enableBlending;
  88854. private _keys;
  88855. private _minFrame;
  88856. private _maxFrame;
  88857. private _minValue;
  88858. private _maxValue;
  88859. private _targetIsArray;
  88860. /**
  88861. * Gets the current frame of the runtime animation
  88862. */
  88863. get currentFrame(): number;
  88864. /**
  88865. * Gets the weight of the runtime animation
  88866. */
  88867. get weight(): number;
  88868. /**
  88869. * Gets the current value of the runtime animation
  88870. */
  88871. get currentValue(): any;
  88872. /**
  88873. * Gets the target path of the runtime animation
  88874. */
  88875. get targetPath(): string;
  88876. /**
  88877. * Gets the actual target of the runtime animation
  88878. */
  88879. get target(): any;
  88880. /**
  88881. * Gets the additive state of the runtime animation
  88882. */
  88883. get isAdditive(): boolean;
  88884. /** @hidden */
  88885. _onLoop: () => void;
  88886. /**
  88887. * Create a new RuntimeAnimation object
  88888. * @param target defines the target of the animation
  88889. * @param animation defines the source animation object
  88890. * @param scene defines the hosting scene
  88891. * @param host defines the initiating Animatable
  88892. */
  88893. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88894. private _preparePath;
  88895. /**
  88896. * Gets the animation from the runtime animation
  88897. */
  88898. get animation(): Animation;
  88899. /**
  88900. * Resets the runtime animation to the beginning
  88901. * @param restoreOriginal defines whether to restore the target property to the original value
  88902. */
  88903. reset(restoreOriginal?: boolean): void;
  88904. /**
  88905. * Specifies if the runtime animation is stopped
  88906. * @returns Boolean specifying if the runtime animation is stopped
  88907. */
  88908. isStopped(): boolean;
  88909. /**
  88910. * Disposes of the runtime animation
  88911. */
  88912. dispose(): void;
  88913. /**
  88914. * Apply the interpolated value to the target
  88915. * @param currentValue defines the value computed by the animation
  88916. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88917. */
  88918. setValue(currentValue: any, weight: number): void;
  88919. private _getOriginalValues;
  88920. private _setValue;
  88921. /**
  88922. * Gets the loop pmode of the runtime animation
  88923. * @returns Loop Mode
  88924. */
  88925. private _getCorrectLoopMode;
  88926. /**
  88927. * Move the current animation to a given frame
  88928. * @param frame defines the frame to move to
  88929. */
  88930. goToFrame(frame: number): void;
  88931. /**
  88932. * @hidden Internal use only
  88933. */
  88934. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88935. /**
  88936. * Execute the current animation
  88937. * @param delay defines the delay to add to the current frame
  88938. * @param from defines the lower bound of the animation range
  88939. * @param to defines the upper bound of the animation range
  88940. * @param loop defines if the current animation must loop
  88941. * @param speedRatio defines the current speed ratio
  88942. * @param weight defines the weight of the animation (default is -1 so no weight)
  88943. * @param onLoop optional callback called when animation loops
  88944. * @returns a boolean indicating if the animation is running
  88945. */
  88946. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88947. }
  88948. }
  88949. declare module BABYLON {
  88950. /**
  88951. * Class used to store an actual running animation
  88952. */
  88953. export class Animatable {
  88954. /** defines the target object */
  88955. target: any;
  88956. /** defines the starting frame number (default is 0) */
  88957. fromFrame: number;
  88958. /** defines the ending frame number (default is 100) */
  88959. toFrame: number;
  88960. /** defines if the animation must loop (default is false) */
  88961. loopAnimation: boolean;
  88962. /** defines a callback to call when animation ends if it is not looping */
  88963. onAnimationEnd?: (() => void) | null | undefined;
  88964. /** defines a callback to call when animation loops */
  88965. onAnimationLoop?: (() => void) | null | undefined;
  88966. /** defines whether the animation should be evaluated additively */
  88967. isAdditive: boolean;
  88968. private _localDelayOffset;
  88969. private _pausedDelay;
  88970. private _runtimeAnimations;
  88971. private _paused;
  88972. private _scene;
  88973. private _speedRatio;
  88974. private _weight;
  88975. private _syncRoot;
  88976. /**
  88977. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88978. * This will only apply for non looping animation (default is true)
  88979. */
  88980. disposeOnEnd: boolean;
  88981. /**
  88982. * Gets a boolean indicating if the animation has started
  88983. */
  88984. animationStarted: boolean;
  88985. /**
  88986. * Observer raised when the animation ends
  88987. */
  88988. onAnimationEndObservable: Observable<Animatable>;
  88989. /**
  88990. * Observer raised when the animation loops
  88991. */
  88992. onAnimationLoopObservable: Observable<Animatable>;
  88993. /**
  88994. * Gets the root Animatable used to synchronize and normalize animations
  88995. */
  88996. get syncRoot(): Nullable<Animatable>;
  88997. /**
  88998. * Gets the current frame of the first RuntimeAnimation
  88999. * Used to synchronize Animatables
  89000. */
  89001. get masterFrame(): number;
  89002. /**
  89003. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  89004. */
  89005. get weight(): number;
  89006. set weight(value: number);
  89007. /**
  89008. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  89009. */
  89010. get speedRatio(): number;
  89011. set speedRatio(value: number);
  89012. /**
  89013. * Creates a new Animatable
  89014. * @param scene defines the hosting scene
  89015. * @param target defines the target object
  89016. * @param fromFrame defines the starting frame number (default is 0)
  89017. * @param toFrame defines the ending frame number (default is 100)
  89018. * @param loopAnimation defines if the animation must loop (default is false)
  89019. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  89020. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  89021. * @param animations defines a group of animation to add to the new Animatable
  89022. * @param onAnimationLoop defines a callback to call when animation loops
  89023. * @param isAdditive defines whether the animation should be evaluated additively
  89024. */
  89025. constructor(scene: Scene,
  89026. /** defines the target object */
  89027. target: any,
  89028. /** defines the starting frame number (default is 0) */
  89029. fromFrame?: number,
  89030. /** defines the ending frame number (default is 100) */
  89031. toFrame?: number,
  89032. /** defines if the animation must loop (default is false) */
  89033. loopAnimation?: boolean, speedRatio?: number,
  89034. /** defines a callback to call when animation ends if it is not looping */
  89035. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89036. /** defines a callback to call when animation loops */
  89037. onAnimationLoop?: (() => void) | null | undefined,
  89038. /** defines whether the animation should be evaluated additively */
  89039. isAdditive?: boolean);
  89040. /**
  89041. * Synchronize and normalize current Animatable with a source Animatable
  89042. * This is useful when using animation weights and when animations are not of the same length
  89043. * @param root defines the root Animatable to synchronize with
  89044. * @returns the current Animatable
  89045. */
  89046. syncWith(root: Animatable): Animatable;
  89047. /**
  89048. * Gets the list of runtime animations
  89049. * @returns an array of RuntimeAnimation
  89050. */
  89051. getAnimations(): RuntimeAnimation[];
  89052. /**
  89053. * Adds more animations to the current animatable
  89054. * @param target defines the target of the animations
  89055. * @param animations defines the new animations to add
  89056. */
  89057. appendAnimations(target: any, animations: Animation[]): void;
  89058. /**
  89059. * Gets the source animation for a specific property
  89060. * @param property defines the propertyu to look for
  89061. * @returns null or the source animation for the given property
  89062. */
  89063. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89064. /**
  89065. * Gets the runtime animation for a specific property
  89066. * @param property defines the propertyu to look for
  89067. * @returns null or the runtime animation for the given property
  89068. */
  89069. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89070. /**
  89071. * Resets the animatable to its original state
  89072. */
  89073. reset(): void;
  89074. /**
  89075. * Allows the animatable to blend with current running animations
  89076. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89077. * @param blendingSpeed defines the blending speed to use
  89078. */
  89079. enableBlending(blendingSpeed: number): void;
  89080. /**
  89081. * Disable animation blending
  89082. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89083. */
  89084. disableBlending(): void;
  89085. /**
  89086. * Jump directly to a given frame
  89087. * @param frame defines the frame to jump to
  89088. */
  89089. goToFrame(frame: number): void;
  89090. /**
  89091. * Pause the animation
  89092. */
  89093. pause(): void;
  89094. /**
  89095. * Restart the animation
  89096. */
  89097. restart(): void;
  89098. private _raiseOnAnimationEnd;
  89099. /**
  89100. * Stop and delete the current animation
  89101. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89102. * @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)
  89103. */
  89104. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89105. /**
  89106. * Wait asynchronously for the animation to end
  89107. * @returns a promise which will be fullfilled when the animation ends
  89108. */
  89109. waitAsync(): Promise<Animatable>;
  89110. /** @hidden */
  89111. _animate(delay: number): boolean;
  89112. }
  89113. interface Scene {
  89114. /** @hidden */
  89115. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89116. /** @hidden */
  89117. _processLateAnimationBindingsForMatrices(holder: {
  89118. totalWeight: number;
  89119. totalAdditiveWeight: number;
  89120. animations: RuntimeAnimation[];
  89121. additiveAnimations: RuntimeAnimation[];
  89122. originalValue: Matrix;
  89123. }): any;
  89124. /** @hidden */
  89125. _processLateAnimationBindingsForQuaternions(holder: {
  89126. totalWeight: number;
  89127. totalAdditiveWeight: number;
  89128. animations: RuntimeAnimation[];
  89129. additiveAnimations: RuntimeAnimation[];
  89130. originalValue: Quaternion;
  89131. }, refQuaternion: Quaternion): Quaternion;
  89132. /** @hidden */
  89133. _processLateAnimationBindings(): void;
  89134. /**
  89135. * Will start the animation sequence of a given target
  89136. * @param target defines the target
  89137. * @param from defines from which frame should animation start
  89138. * @param to defines until which frame should animation run.
  89139. * @param weight defines the weight to apply to the animation (1.0 by default)
  89140. * @param loop defines if the animation loops
  89141. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89142. * @param onAnimationEnd defines the function to be executed when the animation ends
  89143. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89144. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89145. * @param onAnimationLoop defines the callback to call when an animation loops
  89146. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89147. * @returns the animatable object created for this animation
  89148. */
  89149. 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;
  89150. /**
  89151. * Will start the animation sequence of a given target
  89152. * @param target defines the target
  89153. * @param from defines from which frame should animation start
  89154. * @param to defines until which frame should animation run.
  89155. * @param loop defines if the animation loops
  89156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89157. * @param onAnimationEnd defines the function to be executed when the animation ends
  89158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89159. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89160. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89161. * @param onAnimationLoop defines the callback to call when an animation loops
  89162. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89163. * @returns the animatable object created for this animation
  89164. */
  89165. 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;
  89166. /**
  89167. * Will start the animation sequence of a given target and its hierarchy
  89168. * @param target defines the target
  89169. * @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.
  89170. * @param from defines from which frame should animation start
  89171. * @param to defines until which frame should animation run.
  89172. * @param loop defines if the animation loops
  89173. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89174. * @param onAnimationEnd defines the function to be executed when the animation ends
  89175. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89176. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89177. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89178. * @param onAnimationLoop defines the callback to call when an animation loops
  89179. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89180. * @returns the list of created animatables
  89181. */
  89182. 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[];
  89183. /**
  89184. * Begin a new animation on a given node
  89185. * @param target defines the target where the animation will take place
  89186. * @param animations defines the list of animations to start
  89187. * @param from defines the initial value
  89188. * @param to defines the final value
  89189. * @param loop defines if you want animation to loop (off by default)
  89190. * @param speedRatio defines the speed ratio to apply to all animations
  89191. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89192. * @param onAnimationLoop defines the callback to call when an animation loops
  89193. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89194. * @returns the list of created animatables
  89195. */
  89196. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89197. /**
  89198. * Begin a new animation on a given node and its hierarchy
  89199. * @param target defines the root node where the animation will take place
  89200. * @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.
  89201. * @param animations defines the list of animations to start
  89202. * @param from defines the initial value
  89203. * @param to defines the final value
  89204. * @param loop defines if you want animation to loop (off by default)
  89205. * @param speedRatio defines the speed ratio to apply to all animations
  89206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89207. * @param onAnimationLoop defines the callback to call when an animation loops
  89208. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89209. * @returns the list of animatables created for all nodes
  89210. */
  89211. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89212. /**
  89213. * Gets the animatable associated with a specific target
  89214. * @param target defines the target of the animatable
  89215. * @returns the required animatable if found
  89216. */
  89217. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89218. /**
  89219. * Gets all animatables associated with a given target
  89220. * @param target defines the target to look animatables for
  89221. * @returns an array of Animatables
  89222. */
  89223. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89224. /**
  89225. * Stops and removes all animations that have been applied to the scene
  89226. */
  89227. stopAllAnimations(): void;
  89228. /**
  89229. * Gets the current delta time used by animation engine
  89230. */
  89231. deltaTime: number;
  89232. }
  89233. interface Bone {
  89234. /**
  89235. * Copy an animation range from another bone
  89236. * @param source defines the source bone
  89237. * @param rangeName defines the range name to copy
  89238. * @param frameOffset defines the frame offset
  89239. * @param rescaleAsRequired defines if rescaling must be applied if required
  89240. * @param skelDimensionsRatio defines the scaling ratio
  89241. * @returns true if operation was successful
  89242. */
  89243. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89244. }
  89245. }
  89246. declare module BABYLON {
  89247. /**
  89248. * Class used to handle skinning animations
  89249. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89250. */
  89251. export class Skeleton implements IAnimatable {
  89252. /** defines the skeleton name */
  89253. name: string;
  89254. /** defines the skeleton Id */
  89255. id: string;
  89256. /**
  89257. * Defines the list of child bones
  89258. */
  89259. bones: Bone[];
  89260. /**
  89261. * Defines an estimate of the dimension of the skeleton at rest
  89262. */
  89263. dimensionsAtRest: Vector3;
  89264. /**
  89265. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89266. */
  89267. needInitialSkinMatrix: boolean;
  89268. /**
  89269. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89270. */
  89271. overrideMesh: Nullable<AbstractMesh>;
  89272. /**
  89273. * Gets the list of animations attached to this skeleton
  89274. */
  89275. animations: Array<Animation>;
  89276. private _scene;
  89277. private _isDirty;
  89278. private _transformMatrices;
  89279. private _transformMatrixTexture;
  89280. private _meshesWithPoseMatrix;
  89281. private _animatables;
  89282. private _identity;
  89283. private _synchronizedWithMesh;
  89284. private _ranges;
  89285. private _lastAbsoluteTransformsUpdateId;
  89286. private _canUseTextureForBones;
  89287. private _uniqueId;
  89288. /** @hidden */
  89289. _numBonesWithLinkedTransformNode: number;
  89290. /** @hidden */
  89291. _hasWaitingData: Nullable<boolean>;
  89292. /**
  89293. * Specifies if the skeleton should be serialized
  89294. */
  89295. doNotSerialize: boolean;
  89296. private _useTextureToStoreBoneMatrices;
  89297. /**
  89298. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89299. * Please note that this option is not available if the hardware does not support it
  89300. */
  89301. get useTextureToStoreBoneMatrices(): boolean;
  89302. set useTextureToStoreBoneMatrices(value: boolean);
  89303. private _animationPropertiesOverride;
  89304. /**
  89305. * Gets or sets the animation properties override
  89306. */
  89307. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89308. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89309. /**
  89310. * List of inspectable custom properties (used by the Inspector)
  89311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89312. */
  89313. inspectableCustomProperties: IInspectable[];
  89314. /**
  89315. * An observable triggered before computing the skeleton's matrices
  89316. */
  89317. onBeforeComputeObservable: Observable<Skeleton>;
  89318. /**
  89319. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89320. */
  89321. get isUsingTextureForMatrices(): boolean;
  89322. /**
  89323. * Gets the unique ID of this skeleton
  89324. */
  89325. get uniqueId(): number;
  89326. /**
  89327. * Creates a new skeleton
  89328. * @param name defines the skeleton name
  89329. * @param id defines the skeleton Id
  89330. * @param scene defines the hosting scene
  89331. */
  89332. constructor(
  89333. /** defines the skeleton name */
  89334. name: string,
  89335. /** defines the skeleton Id */
  89336. id: string, scene: Scene);
  89337. /**
  89338. * Gets the current object class name.
  89339. * @return the class name
  89340. */
  89341. getClassName(): string;
  89342. /**
  89343. * Returns an array containing the root bones
  89344. * @returns an array containing the root bones
  89345. */
  89346. getChildren(): Array<Bone>;
  89347. /**
  89348. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89349. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89350. * @returns a Float32Array containing matrices data
  89351. */
  89352. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89353. /**
  89354. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89355. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89356. * @returns a raw texture containing the data
  89357. */
  89358. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89359. /**
  89360. * Gets the current hosting scene
  89361. * @returns a scene object
  89362. */
  89363. getScene(): Scene;
  89364. /**
  89365. * Gets a string representing the current skeleton data
  89366. * @param fullDetails defines a boolean indicating if we want a verbose version
  89367. * @returns a string representing the current skeleton data
  89368. */
  89369. toString(fullDetails?: boolean): string;
  89370. /**
  89371. * Get bone's index searching by name
  89372. * @param name defines bone's name to search for
  89373. * @return the indice of the bone. Returns -1 if not found
  89374. */
  89375. getBoneIndexByName(name: string): number;
  89376. /**
  89377. * Creater a new animation range
  89378. * @param name defines the name of the range
  89379. * @param from defines the start key
  89380. * @param to defines the end key
  89381. */
  89382. createAnimationRange(name: string, from: number, to: number): void;
  89383. /**
  89384. * Delete a specific animation range
  89385. * @param name defines the name of the range
  89386. * @param deleteFrames defines if frames must be removed as well
  89387. */
  89388. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89389. /**
  89390. * Gets a specific animation range
  89391. * @param name defines the name of the range to look for
  89392. * @returns the requested animation range or null if not found
  89393. */
  89394. getAnimationRange(name: string): Nullable<AnimationRange>;
  89395. /**
  89396. * Gets the list of all animation ranges defined on this skeleton
  89397. * @returns an array
  89398. */
  89399. getAnimationRanges(): Nullable<AnimationRange>[];
  89400. /**
  89401. * Copy animation range from a source skeleton.
  89402. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89403. * @param source defines the source skeleton
  89404. * @param name defines the name of the range to copy
  89405. * @param rescaleAsRequired defines if rescaling must be applied if required
  89406. * @returns true if operation was successful
  89407. */
  89408. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89409. /**
  89410. * Forces the skeleton to go to rest pose
  89411. */
  89412. returnToRest(): void;
  89413. private _getHighestAnimationFrame;
  89414. /**
  89415. * Begin a specific animation range
  89416. * @param name defines the name of the range to start
  89417. * @param loop defines if looping must be turned on (false by default)
  89418. * @param speedRatio defines the speed ratio to apply (1 by default)
  89419. * @param onAnimationEnd defines a callback which will be called when animation will end
  89420. * @returns a new animatable
  89421. */
  89422. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89423. /**
  89424. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89425. * @param skeleton defines the Skeleton containing the animation range to convert
  89426. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89427. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89428. * @returns the original skeleton
  89429. */
  89430. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89431. /** @hidden */
  89432. _markAsDirty(): void;
  89433. /** @hidden */
  89434. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89435. /** @hidden */
  89436. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89437. private _computeTransformMatrices;
  89438. /**
  89439. * Build all resources required to render a skeleton
  89440. */
  89441. prepare(): void;
  89442. /**
  89443. * Gets the list of animatables currently running for this skeleton
  89444. * @returns an array of animatables
  89445. */
  89446. getAnimatables(): IAnimatable[];
  89447. /**
  89448. * Clone the current skeleton
  89449. * @param name defines the name of the new skeleton
  89450. * @param id defines the id of the new skeleton
  89451. * @returns the new skeleton
  89452. */
  89453. clone(name: string, id?: string): Skeleton;
  89454. /**
  89455. * Enable animation blending for this skeleton
  89456. * @param blendingSpeed defines the blending speed to apply
  89457. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89458. */
  89459. enableBlending(blendingSpeed?: number): void;
  89460. /**
  89461. * Releases all resources associated with the current skeleton
  89462. */
  89463. dispose(): void;
  89464. /**
  89465. * Serialize the skeleton in a JSON object
  89466. * @returns a JSON object
  89467. */
  89468. serialize(): any;
  89469. /**
  89470. * Creates a new skeleton from serialized data
  89471. * @param parsedSkeleton defines the serialized data
  89472. * @param scene defines the hosting scene
  89473. * @returns a new skeleton
  89474. */
  89475. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89476. /**
  89477. * Compute all node absolute transforms
  89478. * @param forceUpdate defines if computation must be done even if cache is up to date
  89479. */
  89480. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89481. /**
  89482. * Gets the root pose matrix
  89483. * @returns a matrix
  89484. */
  89485. getPoseMatrix(): Nullable<Matrix>;
  89486. /**
  89487. * Sorts bones per internal index
  89488. */
  89489. sortBones(): void;
  89490. private _sortBones;
  89491. }
  89492. }
  89493. declare module BABYLON {
  89494. /**
  89495. * Creates an instance based on a source mesh.
  89496. */
  89497. export class InstancedMesh extends AbstractMesh {
  89498. private _sourceMesh;
  89499. private _currentLOD;
  89500. /** @hidden */
  89501. _indexInSourceMeshInstanceArray: number;
  89502. constructor(name: string, source: Mesh);
  89503. /**
  89504. * Returns the string "InstancedMesh".
  89505. */
  89506. getClassName(): string;
  89507. /** Gets the list of lights affecting that mesh */
  89508. get lightSources(): Light[];
  89509. _resyncLightSources(): void;
  89510. _resyncLightSource(light: Light): void;
  89511. _removeLightSource(light: Light, dispose: boolean): void;
  89512. /**
  89513. * If the source mesh receives shadows
  89514. */
  89515. get receiveShadows(): boolean;
  89516. /**
  89517. * The material of the source mesh
  89518. */
  89519. get material(): Nullable<Material>;
  89520. /**
  89521. * Visibility of the source mesh
  89522. */
  89523. get visibility(): number;
  89524. /**
  89525. * Skeleton of the source mesh
  89526. */
  89527. get skeleton(): Nullable<Skeleton>;
  89528. /**
  89529. * Rendering ground id of the source mesh
  89530. */
  89531. get renderingGroupId(): number;
  89532. set renderingGroupId(value: number);
  89533. /**
  89534. * Returns the total number of vertices (integer).
  89535. */
  89536. getTotalVertices(): number;
  89537. /**
  89538. * Returns a positive integer : the total number of indices in this mesh geometry.
  89539. * @returns the numner of indices or zero if the mesh has no geometry.
  89540. */
  89541. getTotalIndices(): number;
  89542. /**
  89543. * The source mesh of the instance
  89544. */
  89545. get sourceMesh(): Mesh;
  89546. /**
  89547. * Is this node ready to be used/rendered
  89548. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89549. * @return {boolean} is it ready
  89550. */
  89551. isReady(completeCheck?: boolean): boolean;
  89552. /**
  89553. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89554. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89555. * @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.
  89556. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89557. */
  89558. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89559. /**
  89560. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89561. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89562. * The `data` are either a numeric array either a Float32Array.
  89563. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89564. * 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).
  89565. * Note that a new underlying VertexBuffer object is created each call.
  89566. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89567. *
  89568. * Possible `kind` values :
  89569. * - VertexBuffer.PositionKind
  89570. * - VertexBuffer.UVKind
  89571. * - VertexBuffer.UV2Kind
  89572. * - VertexBuffer.UV3Kind
  89573. * - VertexBuffer.UV4Kind
  89574. * - VertexBuffer.UV5Kind
  89575. * - VertexBuffer.UV6Kind
  89576. * - VertexBuffer.ColorKind
  89577. * - VertexBuffer.MatricesIndicesKind
  89578. * - VertexBuffer.MatricesIndicesExtraKind
  89579. * - VertexBuffer.MatricesWeightsKind
  89580. * - VertexBuffer.MatricesWeightsExtraKind
  89581. *
  89582. * Returns the Mesh.
  89583. */
  89584. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89585. /**
  89586. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89587. * If the mesh has no geometry, it is simply returned as it is.
  89588. * The `data` are either a numeric array either a Float32Array.
  89589. * No new underlying VertexBuffer object is created.
  89590. * 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.
  89591. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89592. *
  89593. * Possible `kind` values :
  89594. * - VertexBuffer.PositionKind
  89595. * - VertexBuffer.UVKind
  89596. * - VertexBuffer.UV2Kind
  89597. * - VertexBuffer.UV3Kind
  89598. * - VertexBuffer.UV4Kind
  89599. * - VertexBuffer.UV5Kind
  89600. * - VertexBuffer.UV6Kind
  89601. * - VertexBuffer.ColorKind
  89602. * - VertexBuffer.MatricesIndicesKind
  89603. * - VertexBuffer.MatricesIndicesExtraKind
  89604. * - VertexBuffer.MatricesWeightsKind
  89605. * - VertexBuffer.MatricesWeightsExtraKind
  89606. *
  89607. * Returns the Mesh.
  89608. */
  89609. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89610. /**
  89611. * Sets the mesh indices.
  89612. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89613. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89614. * This method creates a new index buffer each call.
  89615. * Returns the Mesh.
  89616. */
  89617. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89618. /**
  89619. * Boolean : True if the mesh owns the requested kind of data.
  89620. */
  89621. isVerticesDataPresent(kind: string): boolean;
  89622. /**
  89623. * Returns an array of indices (IndicesArray).
  89624. */
  89625. getIndices(): Nullable<IndicesArray>;
  89626. get _positions(): Nullable<Vector3[]>;
  89627. /**
  89628. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89629. * This means the mesh underlying bounding box and sphere are recomputed.
  89630. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89631. * @returns the current mesh
  89632. */
  89633. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89634. /** @hidden */
  89635. _preActivate(): InstancedMesh;
  89636. /** @hidden */
  89637. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89638. /** @hidden */
  89639. _postActivate(): void;
  89640. getWorldMatrix(): Matrix;
  89641. get isAnInstance(): boolean;
  89642. /**
  89643. * Returns the current associated LOD AbstractMesh.
  89644. */
  89645. getLOD(camera: Camera): AbstractMesh;
  89646. /** @hidden */
  89647. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89648. /** @hidden */
  89649. _syncSubMeshes(): InstancedMesh;
  89650. /** @hidden */
  89651. _generatePointsArray(): boolean;
  89652. /**
  89653. * Creates a new InstancedMesh from the current mesh.
  89654. * - name (string) : the cloned mesh name
  89655. * - newParent (optional Node) : the optional Node to parent the clone to.
  89656. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89657. *
  89658. * Returns the clone.
  89659. */
  89660. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89661. /**
  89662. * Disposes the InstancedMesh.
  89663. * Returns nothing.
  89664. */
  89665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89666. }
  89667. interface Mesh {
  89668. /**
  89669. * Register a custom buffer that will be instanced
  89670. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89671. * @param kind defines the buffer kind
  89672. * @param stride defines the stride in floats
  89673. */
  89674. registerInstancedBuffer(kind: string, stride: number): void;
  89675. /** @hidden */
  89676. _userInstancedBuffersStorage: {
  89677. data: {
  89678. [key: string]: Float32Array;
  89679. };
  89680. sizes: {
  89681. [key: string]: number;
  89682. };
  89683. vertexBuffers: {
  89684. [key: string]: Nullable<VertexBuffer>;
  89685. };
  89686. strides: {
  89687. [key: string]: number;
  89688. };
  89689. };
  89690. }
  89691. interface AbstractMesh {
  89692. /**
  89693. * Object used to store instanced buffers defined by user
  89694. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89695. */
  89696. instancedBuffers: {
  89697. [key: string]: any;
  89698. };
  89699. }
  89700. }
  89701. declare module BABYLON {
  89702. /**
  89703. * Defines the options associated with the creation of a shader material.
  89704. */
  89705. export interface IShaderMaterialOptions {
  89706. /**
  89707. * Does the material work in alpha blend mode
  89708. */
  89709. needAlphaBlending: boolean;
  89710. /**
  89711. * Does the material work in alpha test mode
  89712. */
  89713. needAlphaTesting: boolean;
  89714. /**
  89715. * The list of attribute names used in the shader
  89716. */
  89717. attributes: string[];
  89718. /**
  89719. * The list of unifrom names used in the shader
  89720. */
  89721. uniforms: string[];
  89722. /**
  89723. * The list of UBO names used in the shader
  89724. */
  89725. uniformBuffers: string[];
  89726. /**
  89727. * The list of sampler names used in the shader
  89728. */
  89729. samplers: string[];
  89730. /**
  89731. * The list of defines used in the shader
  89732. */
  89733. defines: string[];
  89734. }
  89735. /**
  89736. * 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.
  89737. *
  89738. * This returned material effects how the mesh will look based on the code in the shaders.
  89739. *
  89740. * @see http://doc.babylonjs.com/how_to/shader_material
  89741. */
  89742. export class ShaderMaterial extends Material {
  89743. private _shaderPath;
  89744. private _options;
  89745. private _textures;
  89746. private _textureArrays;
  89747. private _floats;
  89748. private _ints;
  89749. private _floatsArrays;
  89750. private _colors3;
  89751. private _colors3Arrays;
  89752. private _colors4;
  89753. private _colors4Arrays;
  89754. private _vectors2;
  89755. private _vectors3;
  89756. private _vectors4;
  89757. private _matrices;
  89758. private _matrixArrays;
  89759. private _matrices3x3;
  89760. private _matrices2x2;
  89761. private _vectors2Arrays;
  89762. private _vectors3Arrays;
  89763. private _vectors4Arrays;
  89764. private _cachedWorldViewMatrix;
  89765. private _cachedWorldViewProjectionMatrix;
  89766. private _renderId;
  89767. private _multiview;
  89768. /**
  89769. * Instantiate a new shader material.
  89770. * 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.
  89771. * This returned material effects how the mesh will look based on the code in the shaders.
  89772. * @see http://doc.babylonjs.com/how_to/shader_material
  89773. * @param name Define the name of the material in the scene
  89774. * @param scene Define the scene the material belongs to
  89775. * @param shaderPath Defines the route to the shader code in one of three ways:
  89776. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89777. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89778. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89779. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89780. * @param options Define the options used to create the shader
  89781. */
  89782. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89783. /**
  89784. * Gets the shader path used to define the shader code
  89785. * It can be modified to trigger a new compilation
  89786. */
  89787. get shaderPath(): any;
  89788. /**
  89789. * Sets the shader path used to define the shader code
  89790. * It can be modified to trigger a new compilation
  89791. */
  89792. set shaderPath(shaderPath: any);
  89793. /**
  89794. * Gets the options used to compile the shader.
  89795. * They can be modified to trigger a new compilation
  89796. */
  89797. get options(): IShaderMaterialOptions;
  89798. /**
  89799. * Gets the current class name of the material e.g. "ShaderMaterial"
  89800. * Mainly use in serialization.
  89801. * @returns the class name
  89802. */
  89803. getClassName(): string;
  89804. /**
  89805. * Specifies if the material will require alpha blending
  89806. * @returns a boolean specifying if alpha blending is needed
  89807. */
  89808. needAlphaBlending(): boolean;
  89809. /**
  89810. * Specifies if this material should be rendered in alpha test mode
  89811. * @returns a boolean specifying if an alpha test is needed.
  89812. */
  89813. needAlphaTesting(): boolean;
  89814. private _checkUniform;
  89815. /**
  89816. * Set a texture in the shader.
  89817. * @param name Define the name of the uniform samplers as defined in the shader
  89818. * @param texture Define the texture to bind to this sampler
  89819. * @return the material itself allowing "fluent" like uniform updates
  89820. */
  89821. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89822. /**
  89823. * Set a texture array in the shader.
  89824. * @param name Define the name of the uniform sampler array as defined in the shader
  89825. * @param textures Define the list of textures to bind to this sampler
  89826. * @return the material itself allowing "fluent" like uniform updates
  89827. */
  89828. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89829. /**
  89830. * Set a float in the shader.
  89831. * @param name Define the name of the uniform as defined in the shader
  89832. * @param value Define the value to give to the uniform
  89833. * @return the material itself allowing "fluent" like uniform updates
  89834. */
  89835. setFloat(name: string, value: number): ShaderMaterial;
  89836. /**
  89837. * Set a int in the shader.
  89838. * @param name Define the name of the uniform as defined in the shader
  89839. * @param value Define the value to give to the uniform
  89840. * @return the material itself allowing "fluent" like uniform updates
  89841. */
  89842. setInt(name: string, value: number): ShaderMaterial;
  89843. /**
  89844. * Set an array of floats in the shader.
  89845. * @param name Define the name of the uniform as defined in the shader
  89846. * @param value Define the value to give to the uniform
  89847. * @return the material itself allowing "fluent" like uniform updates
  89848. */
  89849. setFloats(name: string, value: number[]): ShaderMaterial;
  89850. /**
  89851. * Set a vec3 in the shader from a Color3.
  89852. * @param name Define the name of the uniform as defined in the shader
  89853. * @param value Define the value to give to the uniform
  89854. * @return the material itself allowing "fluent" like uniform updates
  89855. */
  89856. setColor3(name: string, value: Color3): ShaderMaterial;
  89857. /**
  89858. * Set a vec3 array in the shader from a Color3 array.
  89859. * @param name Define the name of the uniform as defined in the shader
  89860. * @param value Define the value to give to the uniform
  89861. * @return the material itself allowing "fluent" like uniform updates
  89862. */
  89863. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89864. /**
  89865. * Set a vec4 in the shader from a Color4.
  89866. * @param name Define the name of the uniform as defined in the shader
  89867. * @param value Define the value to give to the uniform
  89868. * @return the material itself allowing "fluent" like uniform updates
  89869. */
  89870. setColor4(name: string, value: Color4): ShaderMaterial;
  89871. /**
  89872. * Set a vec4 array in the shader from a Color4 array.
  89873. * @param name Define the name of the uniform as defined in the shader
  89874. * @param value Define the value to give to the uniform
  89875. * @return the material itself allowing "fluent" like uniform updates
  89876. */
  89877. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89878. /**
  89879. * Set a vec2 in the shader from a Vector2.
  89880. * @param name Define the name of the uniform as defined in the shader
  89881. * @param value Define the value to give to the uniform
  89882. * @return the material itself allowing "fluent" like uniform updates
  89883. */
  89884. setVector2(name: string, value: Vector2): ShaderMaterial;
  89885. /**
  89886. * Set a vec3 in the shader from a Vector3.
  89887. * @param name Define the name of the uniform as defined in the shader
  89888. * @param value Define the value to give to the uniform
  89889. * @return the material itself allowing "fluent" like uniform updates
  89890. */
  89891. setVector3(name: string, value: Vector3): ShaderMaterial;
  89892. /**
  89893. * Set a vec4 in the shader from a Vector4.
  89894. * @param name Define the name of the uniform as defined in the shader
  89895. * @param value Define the value to give to the uniform
  89896. * @return the material itself allowing "fluent" like uniform updates
  89897. */
  89898. setVector4(name: string, value: Vector4): ShaderMaterial;
  89899. /**
  89900. * Set a mat4 in the shader from a Matrix.
  89901. * @param name Define the name of the uniform as defined in the shader
  89902. * @param value Define the value to give to the uniform
  89903. * @return the material itself allowing "fluent" like uniform updates
  89904. */
  89905. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89906. /**
  89907. * Set a float32Array in the shader from a matrix array.
  89908. * @param name Define the name of the uniform as defined in the shader
  89909. * @param value Define the value to give to the uniform
  89910. * @return the material itself allowing "fluent" like uniform updates
  89911. */
  89912. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89913. /**
  89914. * Set a mat3 in the shader from a Float32Array.
  89915. * @param name Define the name of the uniform as defined in the shader
  89916. * @param value Define the value to give to the uniform
  89917. * @return the material itself allowing "fluent" like uniform updates
  89918. */
  89919. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89920. /**
  89921. * Set a mat2 in the shader from a Float32Array.
  89922. * @param name Define the name of the uniform as defined in the shader
  89923. * @param value Define the value to give to the uniform
  89924. * @return the material itself allowing "fluent" like uniform updates
  89925. */
  89926. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89927. /**
  89928. * Set a vec2 array in the shader from a number array.
  89929. * @param name Define the name of the uniform as defined in the shader
  89930. * @param value Define the value to give to the uniform
  89931. * @return the material itself allowing "fluent" like uniform updates
  89932. */
  89933. setArray2(name: string, value: number[]): ShaderMaterial;
  89934. /**
  89935. * Set a vec3 array in the shader from a number array.
  89936. * @param name Define the name of the uniform as defined in the shader
  89937. * @param value Define the value to give to the uniform
  89938. * @return the material itself allowing "fluent" like uniform updates
  89939. */
  89940. setArray3(name: string, value: number[]): ShaderMaterial;
  89941. /**
  89942. * Set a vec4 array in the shader from a number array.
  89943. * @param name Define the name of the uniform as defined in the shader
  89944. * @param value Define the value to give to the uniform
  89945. * @return the material itself allowing "fluent" like uniform updates
  89946. */
  89947. setArray4(name: string, value: number[]): ShaderMaterial;
  89948. private _checkCache;
  89949. /**
  89950. * Specifies that the submesh is ready to be used
  89951. * @param mesh defines the mesh to check
  89952. * @param subMesh defines which submesh to check
  89953. * @param useInstances specifies that instances should be used
  89954. * @returns a boolean indicating that the submesh is ready or not
  89955. */
  89956. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89957. /**
  89958. * Checks if the material is ready to render the requested mesh
  89959. * @param mesh Define the mesh to render
  89960. * @param useInstances Define whether or not the material is used with instances
  89961. * @returns true if ready, otherwise false
  89962. */
  89963. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89964. /**
  89965. * Binds the world matrix to the material
  89966. * @param world defines the world transformation matrix
  89967. */
  89968. bindOnlyWorldMatrix(world: Matrix): void;
  89969. /**
  89970. * Binds the material to the mesh
  89971. * @param world defines the world transformation matrix
  89972. * @param mesh defines the mesh to bind the material to
  89973. */
  89974. bind(world: Matrix, mesh?: Mesh): void;
  89975. /**
  89976. * Gets the active textures from the material
  89977. * @returns an array of textures
  89978. */
  89979. getActiveTextures(): BaseTexture[];
  89980. /**
  89981. * Specifies if the material uses a texture
  89982. * @param texture defines the texture to check against the material
  89983. * @returns a boolean specifying if the material uses the texture
  89984. */
  89985. hasTexture(texture: BaseTexture): boolean;
  89986. /**
  89987. * Makes a duplicate of the material, and gives it a new name
  89988. * @param name defines the new name for the duplicated material
  89989. * @returns the cloned material
  89990. */
  89991. clone(name: string): ShaderMaterial;
  89992. /**
  89993. * Disposes the material
  89994. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89995. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89996. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89997. */
  89998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89999. /**
  90000. * Serializes this material in a JSON representation
  90001. * @returns the serialized material object
  90002. */
  90003. serialize(): any;
  90004. /**
  90005. * Creates a shader material from parsed shader material data
  90006. * @param source defines the JSON represnetation of the material
  90007. * @param scene defines the hosting scene
  90008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90009. * @returns a new material
  90010. */
  90011. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90012. }
  90013. }
  90014. declare module BABYLON {
  90015. /** @hidden */
  90016. export var colorPixelShader: {
  90017. name: string;
  90018. shader: string;
  90019. };
  90020. }
  90021. declare module BABYLON {
  90022. /** @hidden */
  90023. export var colorVertexShader: {
  90024. name: string;
  90025. shader: string;
  90026. };
  90027. }
  90028. declare module BABYLON {
  90029. /**
  90030. * Line mesh
  90031. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90032. */
  90033. export class LinesMesh extends Mesh {
  90034. /**
  90035. * If vertex color should be applied to the mesh
  90036. */
  90037. readonly useVertexColor?: boolean | undefined;
  90038. /**
  90039. * If vertex alpha should be applied to the mesh
  90040. */
  90041. readonly useVertexAlpha?: boolean | undefined;
  90042. /**
  90043. * Color of the line (Default: White)
  90044. */
  90045. color: Color3;
  90046. /**
  90047. * Alpha of the line (Default: 1)
  90048. */
  90049. alpha: number;
  90050. /**
  90051. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90052. * This margin is expressed in world space coordinates, so its value may vary.
  90053. * Default value is 0.1
  90054. */
  90055. intersectionThreshold: number;
  90056. private _colorShader;
  90057. private color4;
  90058. /**
  90059. * Creates a new LinesMesh
  90060. * @param name defines the name
  90061. * @param scene defines the hosting scene
  90062. * @param parent defines the parent mesh if any
  90063. * @param source defines the optional source LinesMesh used to clone data from
  90064. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90065. * When false, achieved by calling a clone(), also passing False.
  90066. * This will make creation of children, recursive.
  90067. * @param useVertexColor defines if this LinesMesh supports vertex color
  90068. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90069. */
  90070. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90071. /**
  90072. * If vertex color should be applied to the mesh
  90073. */
  90074. useVertexColor?: boolean | undefined,
  90075. /**
  90076. * If vertex alpha should be applied to the mesh
  90077. */
  90078. useVertexAlpha?: boolean | undefined);
  90079. private _addClipPlaneDefine;
  90080. private _removeClipPlaneDefine;
  90081. isReady(): boolean;
  90082. /**
  90083. * Returns the string "LineMesh"
  90084. */
  90085. getClassName(): string;
  90086. /**
  90087. * @hidden
  90088. */
  90089. get material(): Material;
  90090. /**
  90091. * @hidden
  90092. */
  90093. set material(value: Material);
  90094. /**
  90095. * @hidden
  90096. */
  90097. get checkCollisions(): boolean;
  90098. /** @hidden */
  90099. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90100. /** @hidden */
  90101. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90102. /**
  90103. * Disposes of the line mesh
  90104. * @param doNotRecurse If children should be disposed
  90105. */
  90106. dispose(doNotRecurse?: boolean): void;
  90107. /**
  90108. * Returns a new LineMesh object cloned from the current one.
  90109. */
  90110. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90111. /**
  90112. * Creates a new InstancedLinesMesh object from the mesh model.
  90113. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90114. * @param name defines the name of the new instance
  90115. * @returns a new InstancedLinesMesh
  90116. */
  90117. createInstance(name: string): InstancedLinesMesh;
  90118. }
  90119. /**
  90120. * Creates an instance based on a source LinesMesh
  90121. */
  90122. export class InstancedLinesMesh extends InstancedMesh {
  90123. /**
  90124. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90125. * This margin is expressed in world space coordinates, so its value may vary.
  90126. * Initilized with the intersectionThreshold value of the source LinesMesh
  90127. */
  90128. intersectionThreshold: number;
  90129. constructor(name: string, source: LinesMesh);
  90130. /**
  90131. * Returns the string "InstancedLinesMesh".
  90132. */
  90133. getClassName(): string;
  90134. }
  90135. }
  90136. declare module BABYLON {
  90137. /** @hidden */
  90138. export var linePixelShader: {
  90139. name: string;
  90140. shader: string;
  90141. };
  90142. }
  90143. declare module BABYLON {
  90144. /** @hidden */
  90145. export var lineVertexShader: {
  90146. name: string;
  90147. shader: string;
  90148. };
  90149. }
  90150. declare module BABYLON {
  90151. interface AbstractMesh {
  90152. /**
  90153. * Gets the edgesRenderer associated with the mesh
  90154. */
  90155. edgesRenderer: Nullable<EdgesRenderer>;
  90156. }
  90157. interface LinesMesh {
  90158. /**
  90159. * Enables the edge rendering mode on the mesh.
  90160. * This mode makes the mesh edges visible
  90161. * @param epsilon defines the maximal distance between two angles to detect a face
  90162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90163. * @returns the currentAbstractMesh
  90164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90165. */
  90166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90167. }
  90168. interface InstancedLinesMesh {
  90169. /**
  90170. * Enables the edge rendering mode on the mesh.
  90171. * This mode makes the mesh edges visible
  90172. * @param epsilon defines the maximal distance between two angles to detect a face
  90173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90174. * @returns the current InstancedLinesMesh
  90175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90176. */
  90177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90178. }
  90179. /**
  90180. * Defines the minimum contract an Edges renderer should follow.
  90181. */
  90182. export interface IEdgesRenderer extends IDisposable {
  90183. /**
  90184. * Gets or sets a boolean indicating if the edgesRenderer is active
  90185. */
  90186. isEnabled: boolean;
  90187. /**
  90188. * Renders the edges of the attached mesh,
  90189. */
  90190. render(): void;
  90191. /**
  90192. * Checks wether or not the edges renderer is ready to render.
  90193. * @return true if ready, otherwise false.
  90194. */
  90195. isReady(): boolean;
  90196. }
  90197. /**
  90198. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90199. */
  90200. export class EdgesRenderer implements IEdgesRenderer {
  90201. /**
  90202. * Define the size of the edges with an orthographic camera
  90203. */
  90204. edgesWidthScalerForOrthographic: number;
  90205. /**
  90206. * Define the size of the edges with a perspective camera
  90207. */
  90208. edgesWidthScalerForPerspective: number;
  90209. protected _source: AbstractMesh;
  90210. protected _linesPositions: number[];
  90211. protected _linesNormals: number[];
  90212. protected _linesIndices: number[];
  90213. protected _epsilon: number;
  90214. protected _indicesCount: number;
  90215. protected _lineShader: ShaderMaterial;
  90216. protected _ib: DataBuffer;
  90217. protected _buffers: {
  90218. [key: string]: Nullable<VertexBuffer>;
  90219. };
  90220. protected _checkVerticesInsteadOfIndices: boolean;
  90221. private _meshRebuildObserver;
  90222. private _meshDisposeObserver;
  90223. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90224. isEnabled: boolean;
  90225. /**
  90226. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90227. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90228. * @param source Mesh used to create edges
  90229. * @param epsilon sum of angles in adjacency to check for edge
  90230. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90231. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90232. */
  90233. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90234. protected _prepareRessources(): void;
  90235. /** @hidden */
  90236. _rebuild(): void;
  90237. /**
  90238. * Releases the required resources for the edges renderer
  90239. */
  90240. dispose(): void;
  90241. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90242. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90243. /**
  90244. * Checks if the pair of p0 and p1 is en edge
  90245. * @param faceIndex
  90246. * @param edge
  90247. * @param faceNormals
  90248. * @param p0
  90249. * @param p1
  90250. * @private
  90251. */
  90252. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90253. /**
  90254. * push line into the position, normal and index buffer
  90255. * @protected
  90256. */
  90257. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90258. /**
  90259. * Generates lines edges from adjacencjes
  90260. * @private
  90261. */
  90262. _generateEdgesLines(): void;
  90263. /**
  90264. * Checks wether or not the edges renderer is ready to render.
  90265. * @return true if ready, otherwise false.
  90266. */
  90267. isReady(): boolean;
  90268. /**
  90269. * Renders the edges of the attached mesh,
  90270. */
  90271. render(): void;
  90272. }
  90273. /**
  90274. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90275. */
  90276. export class LineEdgesRenderer extends EdgesRenderer {
  90277. /**
  90278. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90279. * @param source LineMesh used to generate edges
  90280. * @param epsilon not important (specified angle for edge detection)
  90281. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90282. */
  90283. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90284. /**
  90285. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90286. */
  90287. _generateEdgesLines(): void;
  90288. }
  90289. }
  90290. declare module BABYLON {
  90291. /**
  90292. * This represents the object necessary to create a rendering group.
  90293. * This is exclusively used and created by the rendering manager.
  90294. * To modify the behavior, you use the available helpers in your scene or meshes.
  90295. * @hidden
  90296. */
  90297. export class RenderingGroup {
  90298. index: number;
  90299. private static _zeroVector;
  90300. private _scene;
  90301. private _opaqueSubMeshes;
  90302. private _transparentSubMeshes;
  90303. private _alphaTestSubMeshes;
  90304. private _depthOnlySubMeshes;
  90305. private _particleSystems;
  90306. private _spriteManagers;
  90307. private _opaqueSortCompareFn;
  90308. private _alphaTestSortCompareFn;
  90309. private _transparentSortCompareFn;
  90310. private _renderOpaque;
  90311. private _renderAlphaTest;
  90312. private _renderTransparent;
  90313. /** @hidden */
  90314. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90315. onBeforeTransparentRendering: () => void;
  90316. /**
  90317. * Set the opaque sort comparison function.
  90318. * If null the sub meshes will be render in the order they were created
  90319. */
  90320. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90321. /**
  90322. * Set the alpha test sort comparison function.
  90323. * If null the sub meshes will be render in the order they were created
  90324. */
  90325. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90326. /**
  90327. * Set the transparent sort comparison function.
  90328. * If null the sub meshes will be render in the order they were created
  90329. */
  90330. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90331. /**
  90332. * Creates a new rendering group.
  90333. * @param index The rendering group index
  90334. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90335. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90336. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90337. */
  90338. 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>);
  90339. /**
  90340. * Render all the sub meshes contained in the group.
  90341. * @param customRenderFunction Used to override the default render behaviour of the group.
  90342. * @returns true if rendered some submeshes.
  90343. */
  90344. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90345. /**
  90346. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90347. * @param subMeshes The submeshes to render
  90348. */
  90349. private renderOpaqueSorted;
  90350. /**
  90351. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90352. * @param subMeshes The submeshes to render
  90353. */
  90354. private renderAlphaTestSorted;
  90355. /**
  90356. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90357. * @param subMeshes The submeshes to render
  90358. */
  90359. private renderTransparentSorted;
  90360. /**
  90361. * Renders the submeshes in a specified order.
  90362. * @param subMeshes The submeshes to sort before render
  90363. * @param sortCompareFn The comparison function use to sort
  90364. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90365. * @param transparent Specifies to activate blending if true
  90366. */
  90367. private static renderSorted;
  90368. /**
  90369. * Renders the submeshes in the order they were dispatched (no sort applied).
  90370. * @param subMeshes The submeshes to render
  90371. */
  90372. private static renderUnsorted;
  90373. /**
  90374. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90375. * are rendered back to front if in the same alpha index.
  90376. *
  90377. * @param a The first submesh
  90378. * @param b The second submesh
  90379. * @returns The result of the comparison
  90380. */
  90381. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90382. /**
  90383. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90384. * are rendered back to front.
  90385. *
  90386. * @param a The first submesh
  90387. * @param b The second submesh
  90388. * @returns The result of the comparison
  90389. */
  90390. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90391. /**
  90392. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90393. * are rendered front to back (prevent overdraw).
  90394. *
  90395. * @param a The first submesh
  90396. * @param b The second submesh
  90397. * @returns The result of the comparison
  90398. */
  90399. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90400. /**
  90401. * Resets the different lists of submeshes to prepare a new frame.
  90402. */
  90403. prepare(): void;
  90404. dispose(): void;
  90405. /**
  90406. * Inserts the submesh in its correct queue depending on its material.
  90407. * @param subMesh The submesh to dispatch
  90408. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90409. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90410. */
  90411. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90412. dispatchSprites(spriteManager: ISpriteManager): void;
  90413. dispatchParticles(particleSystem: IParticleSystem): void;
  90414. private _renderParticles;
  90415. private _renderSprites;
  90416. }
  90417. }
  90418. declare module BABYLON {
  90419. /**
  90420. * Interface describing the different options available in the rendering manager
  90421. * regarding Auto Clear between groups.
  90422. */
  90423. export interface IRenderingManagerAutoClearSetup {
  90424. /**
  90425. * Defines whether or not autoclear is enable.
  90426. */
  90427. autoClear: boolean;
  90428. /**
  90429. * Defines whether or not to autoclear the depth buffer.
  90430. */
  90431. depth: boolean;
  90432. /**
  90433. * Defines whether or not to autoclear the stencil buffer.
  90434. */
  90435. stencil: boolean;
  90436. }
  90437. /**
  90438. * This class is used by the onRenderingGroupObservable
  90439. */
  90440. export class RenderingGroupInfo {
  90441. /**
  90442. * The Scene that being rendered
  90443. */
  90444. scene: Scene;
  90445. /**
  90446. * The camera currently used for the rendering pass
  90447. */
  90448. camera: Nullable<Camera>;
  90449. /**
  90450. * The ID of the renderingGroup being processed
  90451. */
  90452. renderingGroupId: number;
  90453. }
  90454. /**
  90455. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90456. * It is enable to manage the different groups as well as the different necessary sort functions.
  90457. * This should not be used directly aside of the few static configurations
  90458. */
  90459. export class RenderingManager {
  90460. /**
  90461. * The max id used for rendering groups (not included)
  90462. */
  90463. static MAX_RENDERINGGROUPS: number;
  90464. /**
  90465. * The min id used for rendering groups (included)
  90466. */
  90467. static MIN_RENDERINGGROUPS: number;
  90468. /**
  90469. * Used to globally prevent autoclearing scenes.
  90470. */
  90471. static AUTOCLEAR: boolean;
  90472. /**
  90473. * @hidden
  90474. */
  90475. _useSceneAutoClearSetup: boolean;
  90476. private _scene;
  90477. private _renderingGroups;
  90478. private _depthStencilBufferAlreadyCleaned;
  90479. private _autoClearDepthStencil;
  90480. private _customOpaqueSortCompareFn;
  90481. private _customAlphaTestSortCompareFn;
  90482. private _customTransparentSortCompareFn;
  90483. private _renderingGroupInfo;
  90484. /**
  90485. * Instantiates a new rendering group for a particular scene
  90486. * @param scene Defines the scene the groups belongs to
  90487. */
  90488. constructor(scene: Scene);
  90489. private _clearDepthStencilBuffer;
  90490. /**
  90491. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90492. * @hidden
  90493. */
  90494. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90495. /**
  90496. * Resets the different information of the group to prepare a new frame
  90497. * @hidden
  90498. */
  90499. reset(): void;
  90500. /**
  90501. * Dispose and release the group and its associated resources.
  90502. * @hidden
  90503. */
  90504. dispose(): void;
  90505. /**
  90506. * Clear the info related to rendering groups preventing retention points during dispose.
  90507. */
  90508. freeRenderingGroups(): void;
  90509. private _prepareRenderingGroup;
  90510. /**
  90511. * Add a sprite manager to the rendering manager in order to render it this frame.
  90512. * @param spriteManager Define the sprite manager to render
  90513. */
  90514. dispatchSprites(spriteManager: ISpriteManager): void;
  90515. /**
  90516. * Add a particle system to the rendering manager in order to render it this frame.
  90517. * @param particleSystem Define the particle system to render
  90518. */
  90519. dispatchParticles(particleSystem: IParticleSystem): void;
  90520. /**
  90521. * Add a submesh to the manager in order to render it this frame
  90522. * @param subMesh The submesh to dispatch
  90523. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90524. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90525. */
  90526. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90527. /**
  90528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90529. * This allowed control for front to back rendering or reversly depending of the special needs.
  90530. *
  90531. * @param renderingGroupId The rendering group id corresponding to its index
  90532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90535. */
  90536. 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;
  90537. /**
  90538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90539. *
  90540. * @param renderingGroupId The rendering group id corresponding to its index
  90541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90542. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90543. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90544. */
  90545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90546. /**
  90547. * Gets the current auto clear configuration for one rendering group of the rendering
  90548. * manager.
  90549. * @param index the rendering group index to get the information for
  90550. * @returns The auto clear setup for the requested rendering group
  90551. */
  90552. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90553. }
  90554. }
  90555. declare module BABYLON {
  90556. /**
  90557. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90558. */
  90559. export interface ICustomShaderOptions {
  90560. /**
  90561. * Gets or sets the custom shader name to use
  90562. */
  90563. shaderName: string;
  90564. /**
  90565. * The list of attribute names used in the shader
  90566. */
  90567. attributes?: string[];
  90568. /**
  90569. * The list of unifrom names used in the shader
  90570. */
  90571. uniforms?: string[];
  90572. /**
  90573. * The list of sampler names used in the shader
  90574. */
  90575. samplers?: string[];
  90576. /**
  90577. * The list of defines used in the shader
  90578. */
  90579. defines?: string[];
  90580. }
  90581. /**
  90582. * Interface to implement to create a shadow generator compatible with BJS.
  90583. */
  90584. export interface IShadowGenerator {
  90585. /**
  90586. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90587. * @returns The render target texture if present otherwise, null
  90588. */
  90589. getShadowMap(): Nullable<RenderTargetTexture>;
  90590. /**
  90591. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90592. * @param subMesh The submesh we want to render in the shadow map
  90593. * @param useInstances Defines wether will draw in the map using instances
  90594. * @returns true if ready otherwise, false
  90595. */
  90596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90597. /**
  90598. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90599. * @param defines Defines of the material we want to update
  90600. * @param lightIndex Index of the light in the enabled light list of the material
  90601. */
  90602. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90603. /**
  90604. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90605. * defined in the generator but impacting the effect).
  90606. * It implies the unifroms available on the materials are the standard BJS ones.
  90607. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90608. * @param effect The effect we are binfing the information for
  90609. */
  90610. bindShadowLight(lightIndex: string, effect: Effect): void;
  90611. /**
  90612. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90613. * (eq to shadow prjection matrix * light transform matrix)
  90614. * @returns The transform matrix used to create the shadow map
  90615. */
  90616. getTransformMatrix(): Matrix;
  90617. /**
  90618. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90619. * Cube and 2D textures for instance.
  90620. */
  90621. recreateShadowMap(): void;
  90622. /**
  90623. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90624. * @param onCompiled Callback triggered at the and of the effects compilation
  90625. * @param options Sets of optional options forcing the compilation with different modes
  90626. */
  90627. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90628. useInstances: boolean;
  90629. }>): void;
  90630. /**
  90631. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90632. * @param options Sets of optional options forcing the compilation with different modes
  90633. * @returns A promise that resolves when the compilation completes
  90634. */
  90635. forceCompilationAsync(options?: Partial<{
  90636. useInstances: boolean;
  90637. }>): Promise<void>;
  90638. /**
  90639. * Serializes the shadow generator setup to a json object.
  90640. * @returns The serialized JSON object
  90641. */
  90642. serialize(): any;
  90643. /**
  90644. * Disposes the Shadow map and related Textures and effects.
  90645. */
  90646. dispose(): void;
  90647. }
  90648. /**
  90649. * Default implementation IShadowGenerator.
  90650. * This is the main object responsible of generating shadows in the framework.
  90651. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90652. */
  90653. export class ShadowGenerator implements IShadowGenerator {
  90654. /**
  90655. * Name of the shadow generator class
  90656. */
  90657. static CLASSNAME: string;
  90658. /**
  90659. * Shadow generator mode None: no filtering applied.
  90660. */
  90661. static readonly FILTER_NONE: number;
  90662. /**
  90663. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90664. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90665. */
  90666. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90667. /**
  90668. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90669. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90670. */
  90671. static readonly FILTER_POISSONSAMPLING: number;
  90672. /**
  90673. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90674. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90675. */
  90676. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90677. /**
  90678. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90679. * edge artifacts on steep falloff.
  90680. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90681. */
  90682. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90683. /**
  90684. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90685. * edge artifacts on steep falloff.
  90686. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90687. */
  90688. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90689. /**
  90690. * Shadow generator mode PCF: Percentage Closer Filtering
  90691. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90692. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90693. */
  90694. static readonly FILTER_PCF: number;
  90695. /**
  90696. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90697. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90698. * Contact Hardening
  90699. */
  90700. static readonly FILTER_PCSS: number;
  90701. /**
  90702. * Reserved for PCF and PCSS
  90703. * Highest Quality.
  90704. *
  90705. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90706. *
  90707. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90708. */
  90709. static readonly QUALITY_HIGH: number;
  90710. /**
  90711. * Reserved for PCF and PCSS
  90712. * Good tradeoff for quality/perf cross devices
  90713. *
  90714. * Execute PCF on a 3*3 kernel.
  90715. *
  90716. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90717. */
  90718. static readonly QUALITY_MEDIUM: number;
  90719. /**
  90720. * Reserved for PCF and PCSS
  90721. * The lowest quality but the fastest.
  90722. *
  90723. * Execute PCF on a 1*1 kernel.
  90724. *
  90725. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90726. */
  90727. static readonly QUALITY_LOW: number;
  90728. /** Gets or sets the custom shader name to use */
  90729. customShaderOptions: ICustomShaderOptions;
  90730. /**
  90731. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90732. */
  90733. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90734. /**
  90735. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90736. */
  90737. onAfterShadowMapRenderObservable: Observable<Effect>;
  90738. /**
  90739. * Observable triggered before a mesh is rendered in the shadow map.
  90740. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90741. */
  90742. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90743. /**
  90744. * Observable triggered after a mesh is rendered in the shadow map.
  90745. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90746. */
  90747. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90748. protected _bias: number;
  90749. /**
  90750. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90751. */
  90752. get bias(): number;
  90753. /**
  90754. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90755. */
  90756. set bias(bias: number);
  90757. protected _normalBias: number;
  90758. /**
  90759. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90760. */
  90761. get normalBias(): number;
  90762. /**
  90763. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90764. */
  90765. set normalBias(normalBias: number);
  90766. protected _blurBoxOffset: number;
  90767. /**
  90768. * Gets the blur box offset: offset applied during the blur pass.
  90769. * Only useful if useKernelBlur = false
  90770. */
  90771. get blurBoxOffset(): number;
  90772. /**
  90773. * Sets the blur box offset: offset applied during the blur pass.
  90774. * Only useful if useKernelBlur = false
  90775. */
  90776. set blurBoxOffset(value: number);
  90777. protected _blurScale: number;
  90778. /**
  90779. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90780. * 2 means half of the size.
  90781. */
  90782. get blurScale(): number;
  90783. /**
  90784. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90785. * 2 means half of the size.
  90786. */
  90787. set blurScale(value: number);
  90788. protected _blurKernel: number;
  90789. /**
  90790. * Gets the blur kernel: kernel size of the blur pass.
  90791. * Only useful if useKernelBlur = true
  90792. */
  90793. get blurKernel(): number;
  90794. /**
  90795. * Sets the blur kernel: kernel size of the blur pass.
  90796. * Only useful if useKernelBlur = true
  90797. */
  90798. set blurKernel(value: number);
  90799. protected _useKernelBlur: boolean;
  90800. /**
  90801. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90802. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90803. */
  90804. get useKernelBlur(): boolean;
  90805. /**
  90806. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90807. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90808. */
  90809. set useKernelBlur(value: boolean);
  90810. protected _depthScale: number;
  90811. /**
  90812. * Gets the depth scale used in ESM mode.
  90813. */
  90814. get depthScale(): number;
  90815. /**
  90816. * Sets the depth scale used in ESM mode.
  90817. * This can override the scale stored on the light.
  90818. */
  90819. set depthScale(value: number);
  90820. protected _validateFilter(filter: number): number;
  90821. protected _filter: number;
  90822. /**
  90823. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90824. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90825. */
  90826. get filter(): number;
  90827. /**
  90828. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90829. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90830. */
  90831. set filter(value: number);
  90832. /**
  90833. * Gets if the current filter is set to Poisson Sampling.
  90834. */
  90835. get usePoissonSampling(): boolean;
  90836. /**
  90837. * Sets the current filter to Poisson Sampling.
  90838. */
  90839. set usePoissonSampling(value: boolean);
  90840. /**
  90841. * Gets if the current filter is set to ESM.
  90842. */
  90843. get useExponentialShadowMap(): boolean;
  90844. /**
  90845. * Sets the current filter is to ESM.
  90846. */
  90847. set useExponentialShadowMap(value: boolean);
  90848. /**
  90849. * Gets if the current filter is set to filtered ESM.
  90850. */
  90851. get useBlurExponentialShadowMap(): boolean;
  90852. /**
  90853. * Gets if the current filter is set to filtered ESM.
  90854. */
  90855. set useBlurExponentialShadowMap(value: boolean);
  90856. /**
  90857. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90858. * exponential to prevent steep falloff artifacts).
  90859. */
  90860. get useCloseExponentialShadowMap(): boolean;
  90861. /**
  90862. * Sets the current filter to "close ESM" (using the inverse of the
  90863. * exponential to prevent steep falloff artifacts).
  90864. */
  90865. set useCloseExponentialShadowMap(value: boolean);
  90866. /**
  90867. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90868. * exponential to prevent steep falloff artifacts).
  90869. */
  90870. get useBlurCloseExponentialShadowMap(): boolean;
  90871. /**
  90872. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90873. * exponential to prevent steep falloff artifacts).
  90874. */
  90875. set useBlurCloseExponentialShadowMap(value: boolean);
  90876. /**
  90877. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90878. */
  90879. get usePercentageCloserFiltering(): boolean;
  90880. /**
  90881. * Sets the current filter to "PCF" (percentage closer filtering).
  90882. */
  90883. set usePercentageCloserFiltering(value: boolean);
  90884. protected _filteringQuality: number;
  90885. /**
  90886. * Gets the PCF or PCSS Quality.
  90887. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90888. */
  90889. get filteringQuality(): number;
  90890. /**
  90891. * Sets the PCF or PCSS Quality.
  90892. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90893. */
  90894. set filteringQuality(filteringQuality: number);
  90895. /**
  90896. * Gets if the current filter is set to "PCSS" (contact hardening).
  90897. */
  90898. get useContactHardeningShadow(): boolean;
  90899. /**
  90900. * Sets the current filter to "PCSS" (contact hardening).
  90901. */
  90902. set useContactHardeningShadow(value: boolean);
  90903. protected _contactHardeningLightSizeUVRatio: number;
  90904. /**
  90905. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90906. * Using a ratio helps keeping shape stability independently of the map size.
  90907. *
  90908. * It does not account for the light projection as it was having too much
  90909. * instability during the light setup or during light position changes.
  90910. *
  90911. * Only valid if useContactHardeningShadow is true.
  90912. */
  90913. get contactHardeningLightSizeUVRatio(): number;
  90914. /**
  90915. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90916. * Using a ratio helps keeping shape stability independently of the map size.
  90917. *
  90918. * It does not account for the light projection as it was having too much
  90919. * instability during the light setup or during light position changes.
  90920. *
  90921. * Only valid if useContactHardeningShadow is true.
  90922. */
  90923. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90924. protected _darkness: number;
  90925. /** Gets or sets the actual darkness of a shadow */
  90926. get darkness(): number;
  90927. set darkness(value: number);
  90928. /**
  90929. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90930. * 0 means strongest and 1 would means no shadow.
  90931. * @returns the darkness.
  90932. */
  90933. getDarkness(): number;
  90934. /**
  90935. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90936. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90937. * @returns the shadow generator allowing fluent coding.
  90938. */
  90939. setDarkness(darkness: number): ShadowGenerator;
  90940. protected _transparencyShadow: boolean;
  90941. /** Gets or sets the ability to have transparent shadow */
  90942. get transparencyShadow(): boolean;
  90943. set transparencyShadow(value: boolean);
  90944. /**
  90945. * Sets the ability to have transparent shadow (boolean).
  90946. * @param transparent True if transparent else False
  90947. * @returns the shadow generator allowing fluent coding
  90948. */
  90949. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90950. protected _shadowMap: Nullable<RenderTargetTexture>;
  90951. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90952. /**
  90953. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90954. * @returns The render target texture if present otherwise, null
  90955. */
  90956. getShadowMap(): Nullable<RenderTargetTexture>;
  90957. /**
  90958. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90959. * @returns The render target texture if the shadow map is present otherwise, null
  90960. */
  90961. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90962. /**
  90963. * Gets the class name of that object
  90964. * @returns "ShadowGenerator"
  90965. */
  90966. getClassName(): string;
  90967. /**
  90968. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90969. * @param mesh Mesh to add
  90970. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90971. * @returns the Shadow Generator itself
  90972. */
  90973. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90974. /**
  90975. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90976. * @param mesh Mesh to remove
  90977. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90978. * @returns the Shadow Generator itself
  90979. */
  90980. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90981. /**
  90982. * Controls the extent to which the shadows fade out at the edge of the frustum
  90983. */
  90984. frustumEdgeFalloff: number;
  90985. protected _light: IShadowLight;
  90986. /**
  90987. * Returns the associated light object.
  90988. * @returns the light generating the shadow
  90989. */
  90990. getLight(): IShadowLight;
  90991. /**
  90992. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90993. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90994. * It might on the other hand introduce peter panning.
  90995. */
  90996. forceBackFacesOnly: boolean;
  90997. protected _scene: Scene;
  90998. protected _lightDirection: Vector3;
  90999. protected _effect: Effect;
  91000. protected _viewMatrix: Matrix;
  91001. protected _projectionMatrix: Matrix;
  91002. protected _transformMatrix: Matrix;
  91003. protected _cachedPosition: Vector3;
  91004. protected _cachedDirection: Vector3;
  91005. protected _cachedDefines: string;
  91006. protected _currentRenderID: number;
  91007. protected _boxBlurPostprocess: Nullable<PostProcess>;
  91008. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  91009. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  91010. protected _blurPostProcesses: PostProcess[];
  91011. protected _mapSize: number;
  91012. protected _currentFaceIndex: number;
  91013. protected _currentFaceIndexCache: number;
  91014. protected _textureType: number;
  91015. protected _defaultTextureMatrix: Matrix;
  91016. protected _storedUniqueId: Nullable<number>;
  91017. /** @hidden */
  91018. static _SceneComponentInitialization: (scene: Scene) => void;
  91019. /**
  91020. * Creates a ShadowGenerator object.
  91021. * A ShadowGenerator is the required tool to use the shadows.
  91022. * Each light casting shadows needs to use its own ShadowGenerator.
  91023. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  91024. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  91025. * @param light The light object generating the shadows.
  91026. * @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.
  91027. */
  91028. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91029. protected _initializeGenerator(): void;
  91030. protected _createTargetRenderTexture(): void;
  91031. protected _initializeShadowMap(): void;
  91032. protected _initializeBlurRTTAndPostProcesses(): void;
  91033. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91034. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  91035. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91036. protected _applyFilterValues(): void;
  91037. /**
  91038. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91039. * @param onCompiled Callback triggered at the and of the effects compilation
  91040. * @param options Sets of optional options forcing the compilation with different modes
  91041. */
  91042. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91043. useInstances: boolean;
  91044. }>): void;
  91045. /**
  91046. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91047. * @param options Sets of optional options forcing the compilation with different modes
  91048. * @returns A promise that resolves when the compilation completes
  91049. */
  91050. forceCompilationAsync(options?: Partial<{
  91051. useInstances: boolean;
  91052. }>): Promise<void>;
  91053. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91054. /**
  91055. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91056. * @param subMesh The submesh we want to render in the shadow map
  91057. * @param useInstances Defines wether will draw in the map using instances
  91058. * @returns true if ready otherwise, false
  91059. */
  91060. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91061. /**
  91062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91063. * @param defines Defines of the material we want to update
  91064. * @param lightIndex Index of the light in the enabled light list of the material
  91065. */
  91066. prepareDefines(defines: any, lightIndex: number): void;
  91067. /**
  91068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91069. * defined in the generator but impacting the effect).
  91070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91071. * @param effect The effect we are binfing the information for
  91072. */
  91073. bindShadowLight(lightIndex: string, effect: Effect): void;
  91074. /**
  91075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91076. * (eq to shadow prjection matrix * light transform matrix)
  91077. * @returns The transform matrix used to create the shadow map
  91078. */
  91079. getTransformMatrix(): Matrix;
  91080. /**
  91081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91082. * Cube and 2D textures for instance.
  91083. */
  91084. recreateShadowMap(): void;
  91085. protected _disposeBlurPostProcesses(): void;
  91086. protected _disposeRTTandPostProcesses(): void;
  91087. /**
  91088. * Disposes the ShadowGenerator.
  91089. * Returns nothing.
  91090. */
  91091. dispose(): void;
  91092. /**
  91093. * Serializes the shadow generator setup to a json object.
  91094. * @returns The serialized JSON object
  91095. */
  91096. serialize(): any;
  91097. /**
  91098. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91099. * @param parsedShadowGenerator The JSON object to parse
  91100. * @param scene The scene to create the shadow map for
  91101. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91102. * @returns The parsed shadow generator
  91103. */
  91104. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91105. }
  91106. }
  91107. declare module BABYLON {
  91108. /**
  91109. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91110. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91111. * 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.
  91112. */
  91113. export abstract class Light extends Node {
  91114. /**
  91115. * Falloff Default: light is falling off following the material specification:
  91116. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91117. */
  91118. static readonly FALLOFF_DEFAULT: number;
  91119. /**
  91120. * Falloff Physical: light is falling off following the inverse squared distance law.
  91121. */
  91122. static readonly FALLOFF_PHYSICAL: number;
  91123. /**
  91124. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91125. * to enhance interoperability with other engines.
  91126. */
  91127. static readonly FALLOFF_GLTF: number;
  91128. /**
  91129. * Falloff Standard: light is falling off like in the standard material
  91130. * to enhance interoperability with other materials.
  91131. */
  91132. static readonly FALLOFF_STANDARD: number;
  91133. /**
  91134. * If every light affecting the material is in this lightmapMode,
  91135. * material.lightmapTexture adds or multiplies
  91136. * (depends on material.useLightmapAsShadowmap)
  91137. * after every other light calculations.
  91138. */
  91139. static readonly LIGHTMAP_DEFAULT: number;
  91140. /**
  91141. * material.lightmapTexture as only diffuse lighting from this light
  91142. * adds only specular lighting from this light
  91143. * adds dynamic shadows
  91144. */
  91145. static readonly LIGHTMAP_SPECULAR: number;
  91146. /**
  91147. * material.lightmapTexture as only lighting
  91148. * no light calculation from this light
  91149. * only adds dynamic shadows from this light
  91150. */
  91151. static readonly LIGHTMAP_SHADOWSONLY: number;
  91152. /**
  91153. * Each light type uses the default quantity according to its type:
  91154. * point/spot lights use luminous intensity
  91155. * directional lights use illuminance
  91156. */
  91157. static readonly INTENSITYMODE_AUTOMATIC: number;
  91158. /**
  91159. * lumen (lm)
  91160. */
  91161. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91162. /**
  91163. * candela (lm/sr)
  91164. */
  91165. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91166. /**
  91167. * lux (lm/m^2)
  91168. */
  91169. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91170. /**
  91171. * nit (cd/m^2)
  91172. */
  91173. static readonly INTENSITYMODE_LUMINANCE: number;
  91174. /**
  91175. * Light type const id of the point light.
  91176. */
  91177. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91178. /**
  91179. * Light type const id of the directional light.
  91180. */
  91181. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91182. /**
  91183. * Light type const id of the spot light.
  91184. */
  91185. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91186. /**
  91187. * Light type const id of the hemispheric light.
  91188. */
  91189. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91190. /**
  91191. * Diffuse gives the basic color to an object.
  91192. */
  91193. diffuse: Color3;
  91194. /**
  91195. * Specular produces a highlight color on an object.
  91196. * Note: This is note affecting PBR materials.
  91197. */
  91198. specular: Color3;
  91199. /**
  91200. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91201. * falling off base on range or angle.
  91202. * This can be set to any values in Light.FALLOFF_x.
  91203. *
  91204. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91205. * other types of materials.
  91206. */
  91207. falloffType: number;
  91208. /**
  91209. * Strength of the light.
  91210. * Note: By default it is define in the framework own unit.
  91211. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91212. */
  91213. intensity: number;
  91214. private _range;
  91215. protected _inverseSquaredRange: number;
  91216. /**
  91217. * Defines how far from the source the light is impacting in scene units.
  91218. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91219. */
  91220. get range(): number;
  91221. /**
  91222. * Defines how far from the source the light is impacting in scene units.
  91223. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91224. */
  91225. set range(value: number);
  91226. /**
  91227. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91228. * of light.
  91229. */
  91230. private _photometricScale;
  91231. private _intensityMode;
  91232. /**
  91233. * Gets the photometric scale used to interpret the intensity.
  91234. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91235. */
  91236. get intensityMode(): number;
  91237. /**
  91238. * Sets the photometric scale used to interpret the intensity.
  91239. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91240. */
  91241. set intensityMode(value: number);
  91242. private _radius;
  91243. /**
  91244. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91245. */
  91246. get radius(): number;
  91247. /**
  91248. * sets the light radius used by PBR Materials to simulate soft area lights.
  91249. */
  91250. set radius(value: number);
  91251. private _renderPriority;
  91252. /**
  91253. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91254. * exceeding the number allowed of the materials.
  91255. */
  91256. renderPriority: number;
  91257. private _shadowEnabled;
  91258. /**
  91259. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91260. * the current shadow generator.
  91261. */
  91262. get shadowEnabled(): boolean;
  91263. /**
  91264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91265. * the current shadow generator.
  91266. */
  91267. set shadowEnabled(value: boolean);
  91268. private _includedOnlyMeshes;
  91269. /**
  91270. * Gets the only meshes impacted by this light.
  91271. */
  91272. get includedOnlyMeshes(): AbstractMesh[];
  91273. /**
  91274. * Sets the only meshes impacted by this light.
  91275. */
  91276. set includedOnlyMeshes(value: AbstractMesh[]);
  91277. private _excludedMeshes;
  91278. /**
  91279. * Gets the meshes not impacted by this light.
  91280. */
  91281. get excludedMeshes(): AbstractMesh[];
  91282. /**
  91283. * Sets the meshes not impacted by this light.
  91284. */
  91285. set excludedMeshes(value: AbstractMesh[]);
  91286. private _excludeWithLayerMask;
  91287. /**
  91288. * Gets the layer id use to find what meshes are not impacted by the light.
  91289. * Inactive if 0
  91290. */
  91291. get excludeWithLayerMask(): number;
  91292. /**
  91293. * Sets the layer id use to find what meshes are not impacted by the light.
  91294. * Inactive if 0
  91295. */
  91296. set excludeWithLayerMask(value: number);
  91297. private _includeOnlyWithLayerMask;
  91298. /**
  91299. * Gets the layer id use to find what meshes are impacted by the light.
  91300. * Inactive if 0
  91301. */
  91302. get includeOnlyWithLayerMask(): number;
  91303. /**
  91304. * Sets the layer id use to find what meshes are impacted by the light.
  91305. * Inactive if 0
  91306. */
  91307. set includeOnlyWithLayerMask(value: number);
  91308. private _lightmapMode;
  91309. /**
  91310. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91311. */
  91312. get lightmapMode(): number;
  91313. /**
  91314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91315. */
  91316. set lightmapMode(value: number);
  91317. /**
  91318. * Shadow generator associted to the light.
  91319. * @hidden Internal use only.
  91320. */
  91321. _shadowGenerator: Nullable<IShadowGenerator>;
  91322. /**
  91323. * @hidden Internal use only.
  91324. */
  91325. _excludedMeshesIds: string[];
  91326. /**
  91327. * @hidden Internal use only.
  91328. */
  91329. _includedOnlyMeshesIds: string[];
  91330. /**
  91331. * The current light unifom buffer.
  91332. * @hidden Internal use only.
  91333. */
  91334. _uniformBuffer: UniformBuffer;
  91335. /** @hidden */
  91336. _renderId: number;
  91337. /**
  91338. * Creates a Light object in the scene.
  91339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91340. * @param name The firendly name of the light
  91341. * @param scene The scene the light belongs too
  91342. */
  91343. constructor(name: string, scene: Scene);
  91344. protected abstract _buildUniformLayout(): void;
  91345. /**
  91346. * Sets the passed Effect "effect" with the Light information.
  91347. * @param effect The effect to update
  91348. * @param lightIndex The index of the light in the effect to update
  91349. * @returns The light
  91350. */
  91351. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91352. /**
  91353. * Sets the passed Effect "effect" with the Light textures.
  91354. * @param effect The effect to update
  91355. * @param lightIndex The index of the light in the effect to update
  91356. * @returns The light
  91357. */
  91358. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91359. /**
  91360. * Binds the lights information from the scene to the effect for the given mesh.
  91361. * @param lightIndex Light index
  91362. * @param scene The scene where the light belongs to
  91363. * @param effect The effect we are binding the data to
  91364. * @param useSpecular Defines if specular is supported
  91365. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91366. */
  91367. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91368. /**
  91369. * Sets the passed Effect "effect" with the Light information.
  91370. * @param effect The effect to update
  91371. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91372. * @returns The light
  91373. */
  91374. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91375. /**
  91376. * Returns the string "Light".
  91377. * @returns the class name
  91378. */
  91379. getClassName(): string;
  91380. /** @hidden */
  91381. readonly _isLight: boolean;
  91382. /**
  91383. * Converts the light information to a readable string for debug purpose.
  91384. * @param fullDetails Supports for multiple levels of logging within scene loading
  91385. * @returns the human readable light info
  91386. */
  91387. toString(fullDetails?: boolean): string;
  91388. /** @hidden */
  91389. protected _syncParentEnabledState(): void;
  91390. /**
  91391. * Set the enabled state of this node.
  91392. * @param value - the new enabled state
  91393. */
  91394. setEnabled(value: boolean): void;
  91395. /**
  91396. * Returns the Light associated shadow generator if any.
  91397. * @return the associated shadow generator.
  91398. */
  91399. getShadowGenerator(): Nullable<IShadowGenerator>;
  91400. /**
  91401. * Returns a Vector3, the absolute light position in the World.
  91402. * @returns the world space position of the light
  91403. */
  91404. getAbsolutePosition(): Vector3;
  91405. /**
  91406. * Specifies if the light will affect the passed mesh.
  91407. * @param mesh The mesh to test against the light
  91408. * @return true the mesh is affected otherwise, false.
  91409. */
  91410. canAffectMesh(mesh: AbstractMesh): boolean;
  91411. /**
  91412. * Sort function to order lights for rendering.
  91413. * @param a First Light object to compare to second.
  91414. * @param b Second Light object to compare first.
  91415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91416. */
  91417. static CompareLightsPriority(a: Light, b: Light): number;
  91418. /**
  91419. * Releases resources associated with this node.
  91420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91422. */
  91423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91424. /**
  91425. * Returns the light type ID (integer).
  91426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91427. */
  91428. getTypeID(): number;
  91429. /**
  91430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91431. * @returns the scaled intensity in intensity mode unit
  91432. */
  91433. getScaledIntensity(): number;
  91434. /**
  91435. * Returns a new Light object, named "name", from the current one.
  91436. * @param name The name of the cloned light
  91437. * @returns the new created light
  91438. */
  91439. clone(name: string): Nullable<Light>;
  91440. /**
  91441. * Serializes the current light into a Serialization object.
  91442. * @returns the serialized object.
  91443. */
  91444. serialize(): any;
  91445. /**
  91446. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91447. * This new light is named "name" and added to the passed scene.
  91448. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91449. * @param name The friendly name of the light
  91450. * @param scene The scene the new light will belong to
  91451. * @returns the constructor function
  91452. */
  91453. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91454. /**
  91455. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91456. * @param parsedLight The JSON representation of the light
  91457. * @param scene The scene to create the parsed light in
  91458. * @returns the created light after parsing
  91459. */
  91460. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91461. private _hookArrayForExcluded;
  91462. private _hookArrayForIncludedOnly;
  91463. private _resyncMeshes;
  91464. /**
  91465. * Forces the meshes to update their light related information in their rendering used effects
  91466. * @hidden Internal Use Only
  91467. */
  91468. _markMeshesAsLightDirty(): void;
  91469. /**
  91470. * Recomputes the cached photometric scale if needed.
  91471. */
  91472. private _computePhotometricScale;
  91473. /**
  91474. * Returns the Photometric Scale according to the light type and intensity mode.
  91475. */
  91476. private _getPhotometricScale;
  91477. /**
  91478. * Reorder the light in the scene according to their defined priority.
  91479. * @hidden Internal Use Only
  91480. */
  91481. _reorderLightsInScene(): void;
  91482. /**
  91483. * Prepares the list of defines specific to the light type.
  91484. * @param defines the list of defines
  91485. * @param lightIndex defines the index of the light for the effect
  91486. */
  91487. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91488. }
  91489. }
  91490. declare module BABYLON {
  91491. /**
  91492. * Interface used to define Action
  91493. */
  91494. export interface IAction {
  91495. /**
  91496. * Trigger for the action
  91497. */
  91498. trigger: number;
  91499. /** Options of the trigger */
  91500. triggerOptions: any;
  91501. /**
  91502. * Gets the trigger parameters
  91503. * @returns the trigger parameters
  91504. */
  91505. getTriggerParameter(): any;
  91506. /**
  91507. * Internal only - executes current action event
  91508. * @hidden
  91509. */
  91510. _executeCurrent(evt?: ActionEvent): void;
  91511. /**
  91512. * Serialize placeholder for child classes
  91513. * @param parent of child
  91514. * @returns the serialized object
  91515. */
  91516. serialize(parent: any): any;
  91517. /**
  91518. * Internal only
  91519. * @hidden
  91520. */
  91521. _prepare(): void;
  91522. /**
  91523. * Internal only - manager for action
  91524. * @hidden
  91525. */
  91526. _actionManager: AbstractActionManager;
  91527. /**
  91528. * Adds action to chain of actions, may be a DoNothingAction
  91529. * @param action defines the next action to execute
  91530. * @returns The action passed in
  91531. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91532. */
  91533. then(action: IAction): IAction;
  91534. }
  91535. /**
  91536. * The action to be carried out following a trigger
  91537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91538. */
  91539. export class Action implements IAction {
  91540. /** the trigger, with or without parameters, for the action */
  91541. triggerOptions: any;
  91542. /**
  91543. * Trigger for the action
  91544. */
  91545. trigger: number;
  91546. /**
  91547. * Internal only - manager for action
  91548. * @hidden
  91549. */
  91550. _actionManager: ActionManager;
  91551. private _nextActiveAction;
  91552. private _child;
  91553. private _condition?;
  91554. private _triggerParameter;
  91555. /**
  91556. * An event triggered prior to action being executed.
  91557. */
  91558. onBeforeExecuteObservable: Observable<Action>;
  91559. /**
  91560. * Creates a new Action
  91561. * @param triggerOptions the trigger, with or without parameters, for the action
  91562. * @param condition an optional determinant of action
  91563. */
  91564. constructor(
  91565. /** the trigger, with or without parameters, for the action */
  91566. triggerOptions: any, condition?: Condition);
  91567. /**
  91568. * Internal only
  91569. * @hidden
  91570. */
  91571. _prepare(): void;
  91572. /**
  91573. * Gets the trigger parameters
  91574. * @returns the trigger parameters
  91575. */
  91576. getTriggerParameter(): any;
  91577. /**
  91578. * Internal only - executes current action event
  91579. * @hidden
  91580. */
  91581. _executeCurrent(evt?: ActionEvent): void;
  91582. /**
  91583. * Execute placeholder for child classes
  91584. * @param evt optional action event
  91585. */
  91586. execute(evt?: ActionEvent): void;
  91587. /**
  91588. * Skips to next active action
  91589. */
  91590. skipToNextActiveAction(): void;
  91591. /**
  91592. * Adds action to chain of actions, may be a DoNothingAction
  91593. * @param action defines the next action to execute
  91594. * @returns The action passed in
  91595. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91596. */
  91597. then(action: Action): Action;
  91598. /**
  91599. * Internal only
  91600. * @hidden
  91601. */
  91602. _getProperty(propertyPath: string): string;
  91603. /**
  91604. * Internal only
  91605. * @hidden
  91606. */
  91607. _getEffectiveTarget(target: any, propertyPath: string): any;
  91608. /**
  91609. * Serialize placeholder for child classes
  91610. * @param parent of child
  91611. * @returns the serialized object
  91612. */
  91613. serialize(parent: any): any;
  91614. /**
  91615. * Internal only called by serialize
  91616. * @hidden
  91617. */
  91618. protected _serialize(serializedAction: any, parent?: any): any;
  91619. /**
  91620. * Internal only
  91621. * @hidden
  91622. */
  91623. static _SerializeValueAsString: (value: any) => string;
  91624. /**
  91625. * Internal only
  91626. * @hidden
  91627. */
  91628. static _GetTargetProperty: (target: Node | Scene) => {
  91629. name: string;
  91630. targetType: string;
  91631. value: string;
  91632. };
  91633. }
  91634. }
  91635. declare module BABYLON {
  91636. /**
  91637. * A Condition applied to an Action
  91638. */
  91639. export class Condition {
  91640. /**
  91641. * Internal only - manager for action
  91642. * @hidden
  91643. */
  91644. _actionManager: ActionManager;
  91645. /**
  91646. * Internal only
  91647. * @hidden
  91648. */
  91649. _evaluationId: number;
  91650. /**
  91651. * Internal only
  91652. * @hidden
  91653. */
  91654. _currentResult: boolean;
  91655. /**
  91656. * Creates a new Condition
  91657. * @param actionManager the manager of the action the condition is applied to
  91658. */
  91659. constructor(actionManager: ActionManager);
  91660. /**
  91661. * Check if the current condition is valid
  91662. * @returns a boolean
  91663. */
  91664. isValid(): boolean;
  91665. /**
  91666. * Internal only
  91667. * @hidden
  91668. */
  91669. _getProperty(propertyPath: string): string;
  91670. /**
  91671. * Internal only
  91672. * @hidden
  91673. */
  91674. _getEffectiveTarget(target: any, propertyPath: string): any;
  91675. /**
  91676. * Serialize placeholder for child classes
  91677. * @returns the serialized object
  91678. */
  91679. serialize(): any;
  91680. /**
  91681. * Internal only
  91682. * @hidden
  91683. */
  91684. protected _serialize(serializedCondition: any): any;
  91685. }
  91686. /**
  91687. * Defines specific conditional operators as extensions of Condition
  91688. */
  91689. export class ValueCondition extends Condition {
  91690. /** path to specify the property of the target the conditional operator uses */
  91691. propertyPath: string;
  91692. /** the value compared by the conditional operator against the current value of the property */
  91693. value: any;
  91694. /** the conditional operator, default ValueCondition.IsEqual */
  91695. operator: number;
  91696. /**
  91697. * Internal only
  91698. * @hidden
  91699. */
  91700. private static _IsEqual;
  91701. /**
  91702. * Internal only
  91703. * @hidden
  91704. */
  91705. private static _IsDifferent;
  91706. /**
  91707. * Internal only
  91708. * @hidden
  91709. */
  91710. private static _IsGreater;
  91711. /**
  91712. * Internal only
  91713. * @hidden
  91714. */
  91715. private static _IsLesser;
  91716. /**
  91717. * returns the number for IsEqual
  91718. */
  91719. static get IsEqual(): number;
  91720. /**
  91721. * Returns the number for IsDifferent
  91722. */
  91723. static get IsDifferent(): number;
  91724. /**
  91725. * Returns the number for IsGreater
  91726. */
  91727. static get IsGreater(): number;
  91728. /**
  91729. * Returns the number for IsLesser
  91730. */
  91731. static get IsLesser(): number;
  91732. /**
  91733. * Internal only The action manager for the condition
  91734. * @hidden
  91735. */
  91736. _actionManager: ActionManager;
  91737. /**
  91738. * Internal only
  91739. * @hidden
  91740. */
  91741. private _target;
  91742. /**
  91743. * Internal only
  91744. * @hidden
  91745. */
  91746. private _effectiveTarget;
  91747. /**
  91748. * Internal only
  91749. * @hidden
  91750. */
  91751. private _property;
  91752. /**
  91753. * Creates a new ValueCondition
  91754. * @param actionManager manager for the action the condition applies to
  91755. * @param target for the action
  91756. * @param propertyPath path to specify the property of the target the conditional operator uses
  91757. * @param value the value compared by the conditional operator against the current value of the property
  91758. * @param operator the conditional operator, default ValueCondition.IsEqual
  91759. */
  91760. constructor(actionManager: ActionManager, target: any,
  91761. /** path to specify the property of the target the conditional operator uses */
  91762. propertyPath: string,
  91763. /** the value compared by the conditional operator against the current value of the property */
  91764. value: any,
  91765. /** the conditional operator, default ValueCondition.IsEqual */
  91766. operator?: number);
  91767. /**
  91768. * Compares the given value with the property value for the specified conditional operator
  91769. * @returns the result of the comparison
  91770. */
  91771. isValid(): boolean;
  91772. /**
  91773. * Serialize the ValueCondition into a JSON compatible object
  91774. * @returns serialization object
  91775. */
  91776. serialize(): any;
  91777. /**
  91778. * Gets the name of the conditional operator for the ValueCondition
  91779. * @param operator the conditional operator
  91780. * @returns the name
  91781. */
  91782. static GetOperatorName(operator: number): string;
  91783. }
  91784. /**
  91785. * Defines a predicate condition as an extension of Condition
  91786. */
  91787. export class PredicateCondition extends Condition {
  91788. /** defines the predicate function used to validate the condition */
  91789. predicate: () => boolean;
  91790. /**
  91791. * Internal only - manager for action
  91792. * @hidden
  91793. */
  91794. _actionManager: ActionManager;
  91795. /**
  91796. * Creates a new PredicateCondition
  91797. * @param actionManager manager for the action the condition applies to
  91798. * @param predicate defines the predicate function used to validate the condition
  91799. */
  91800. constructor(actionManager: ActionManager,
  91801. /** defines the predicate function used to validate the condition */
  91802. predicate: () => boolean);
  91803. /**
  91804. * @returns the validity of the predicate condition
  91805. */
  91806. isValid(): boolean;
  91807. }
  91808. /**
  91809. * Defines a state condition as an extension of Condition
  91810. */
  91811. export class StateCondition extends Condition {
  91812. /** Value to compare with target state */
  91813. value: string;
  91814. /**
  91815. * Internal only - manager for action
  91816. * @hidden
  91817. */
  91818. _actionManager: ActionManager;
  91819. /**
  91820. * Internal only
  91821. * @hidden
  91822. */
  91823. private _target;
  91824. /**
  91825. * Creates a new StateCondition
  91826. * @param actionManager manager for the action the condition applies to
  91827. * @param target of the condition
  91828. * @param value to compare with target state
  91829. */
  91830. constructor(actionManager: ActionManager, target: any,
  91831. /** Value to compare with target state */
  91832. value: string);
  91833. /**
  91834. * Gets a boolean indicating if the current condition is met
  91835. * @returns the validity of the state
  91836. */
  91837. isValid(): boolean;
  91838. /**
  91839. * Serialize the StateCondition into a JSON compatible object
  91840. * @returns serialization object
  91841. */
  91842. serialize(): any;
  91843. }
  91844. }
  91845. declare module BABYLON {
  91846. /**
  91847. * This defines an action responsible to toggle a boolean once triggered.
  91848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91849. */
  91850. export class SwitchBooleanAction extends Action {
  91851. /**
  91852. * The path to the boolean property in the target object
  91853. */
  91854. propertyPath: string;
  91855. private _target;
  91856. private _effectiveTarget;
  91857. private _property;
  91858. /**
  91859. * Instantiate the action
  91860. * @param triggerOptions defines the trigger options
  91861. * @param target defines the object containing the boolean
  91862. * @param propertyPath defines the path to the boolean property in the target object
  91863. * @param condition defines the trigger related conditions
  91864. */
  91865. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91866. /** @hidden */
  91867. _prepare(): void;
  91868. /**
  91869. * Execute the action toggle the boolean value.
  91870. */
  91871. execute(): void;
  91872. /**
  91873. * Serializes the actions and its related information.
  91874. * @param parent defines the object to serialize in
  91875. * @returns the serialized object
  91876. */
  91877. serialize(parent: any): any;
  91878. }
  91879. /**
  91880. * This defines an action responsible to set a the state field of the target
  91881. * to a desired value once triggered.
  91882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91883. */
  91884. export class SetStateAction extends Action {
  91885. /**
  91886. * The value to store in the state field.
  91887. */
  91888. value: string;
  91889. private _target;
  91890. /**
  91891. * Instantiate the action
  91892. * @param triggerOptions defines the trigger options
  91893. * @param target defines the object containing the state property
  91894. * @param value defines the value to store in the state field
  91895. * @param condition defines the trigger related conditions
  91896. */
  91897. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91898. /**
  91899. * Execute the action and store the value on the target state property.
  91900. */
  91901. execute(): void;
  91902. /**
  91903. * Serializes the actions and its related information.
  91904. * @param parent defines the object to serialize in
  91905. * @returns the serialized object
  91906. */
  91907. serialize(parent: any): any;
  91908. }
  91909. /**
  91910. * This defines an action responsible to set a property of the target
  91911. * to a desired value once triggered.
  91912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91913. */
  91914. export class SetValueAction extends Action {
  91915. /**
  91916. * The path of the property to set in the target.
  91917. */
  91918. propertyPath: string;
  91919. /**
  91920. * The value to set in the property
  91921. */
  91922. value: any;
  91923. private _target;
  91924. private _effectiveTarget;
  91925. private _property;
  91926. /**
  91927. * Instantiate the action
  91928. * @param triggerOptions defines the trigger options
  91929. * @param target defines the object containing the property
  91930. * @param propertyPath defines the path of the property to set in the target
  91931. * @param value defines the value to set in the property
  91932. * @param condition defines the trigger related conditions
  91933. */
  91934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91935. /** @hidden */
  91936. _prepare(): void;
  91937. /**
  91938. * Execute the action and set the targetted property to the desired value.
  91939. */
  91940. execute(): void;
  91941. /**
  91942. * Serializes the actions and its related information.
  91943. * @param parent defines the object to serialize in
  91944. * @returns the serialized object
  91945. */
  91946. serialize(parent: any): any;
  91947. }
  91948. /**
  91949. * This defines an action responsible to increment the target value
  91950. * to a desired value once triggered.
  91951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91952. */
  91953. export class IncrementValueAction extends Action {
  91954. /**
  91955. * The path of the property to increment in the target.
  91956. */
  91957. propertyPath: string;
  91958. /**
  91959. * The value we should increment the property by.
  91960. */
  91961. value: any;
  91962. private _target;
  91963. private _effectiveTarget;
  91964. private _property;
  91965. /**
  91966. * Instantiate the action
  91967. * @param triggerOptions defines the trigger options
  91968. * @param target defines the object containing the property
  91969. * @param propertyPath defines the path of the property to increment in the target
  91970. * @param value defines the value value we should increment the property by
  91971. * @param condition defines the trigger related conditions
  91972. */
  91973. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91974. /** @hidden */
  91975. _prepare(): void;
  91976. /**
  91977. * Execute the action and increment the target of the value amount.
  91978. */
  91979. execute(): void;
  91980. /**
  91981. * Serializes the actions and its related information.
  91982. * @param parent defines the object to serialize in
  91983. * @returns the serialized object
  91984. */
  91985. serialize(parent: any): any;
  91986. }
  91987. /**
  91988. * This defines an action responsible to start an animation once triggered.
  91989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91990. */
  91991. export class PlayAnimationAction extends Action {
  91992. /**
  91993. * Where the animation should start (animation frame)
  91994. */
  91995. from: number;
  91996. /**
  91997. * Where the animation should stop (animation frame)
  91998. */
  91999. to: number;
  92000. /**
  92001. * Define if the animation should loop or stop after the first play.
  92002. */
  92003. loop?: boolean;
  92004. private _target;
  92005. /**
  92006. * Instantiate the action
  92007. * @param triggerOptions defines the trigger options
  92008. * @param target defines the target animation or animation name
  92009. * @param from defines from where the animation should start (animation frame)
  92010. * @param end defines where the animation should stop (animation frame)
  92011. * @param loop defines if the animation should loop or stop after the first play
  92012. * @param condition defines the trigger related conditions
  92013. */
  92014. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  92015. /** @hidden */
  92016. _prepare(): void;
  92017. /**
  92018. * Execute the action and play the animation.
  92019. */
  92020. execute(): void;
  92021. /**
  92022. * Serializes the actions and its related information.
  92023. * @param parent defines the object to serialize in
  92024. * @returns the serialized object
  92025. */
  92026. serialize(parent: any): any;
  92027. }
  92028. /**
  92029. * This defines an action responsible to stop an animation once triggered.
  92030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92031. */
  92032. export class StopAnimationAction extends Action {
  92033. private _target;
  92034. /**
  92035. * Instantiate the action
  92036. * @param triggerOptions defines the trigger options
  92037. * @param target defines the target animation or animation name
  92038. * @param condition defines the trigger related conditions
  92039. */
  92040. constructor(triggerOptions: any, target: any, condition?: Condition);
  92041. /** @hidden */
  92042. _prepare(): void;
  92043. /**
  92044. * Execute the action and stop the animation.
  92045. */
  92046. execute(): void;
  92047. /**
  92048. * Serializes the actions and its related information.
  92049. * @param parent defines the object to serialize in
  92050. * @returns the serialized object
  92051. */
  92052. serialize(parent: any): any;
  92053. }
  92054. /**
  92055. * This defines an action responsible that does nothing once triggered.
  92056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92057. */
  92058. export class DoNothingAction extends Action {
  92059. /**
  92060. * Instantiate the action
  92061. * @param triggerOptions defines the trigger options
  92062. * @param condition defines the trigger related conditions
  92063. */
  92064. constructor(triggerOptions?: any, condition?: Condition);
  92065. /**
  92066. * Execute the action and do nothing.
  92067. */
  92068. execute(): void;
  92069. /**
  92070. * Serializes the actions and its related information.
  92071. * @param parent defines the object to serialize in
  92072. * @returns the serialized object
  92073. */
  92074. serialize(parent: any): any;
  92075. }
  92076. /**
  92077. * This defines an action responsible to trigger several actions once triggered.
  92078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92079. */
  92080. export class CombineAction extends Action {
  92081. /**
  92082. * The list of aggregated animations to run.
  92083. */
  92084. children: Action[];
  92085. /**
  92086. * Instantiate the action
  92087. * @param triggerOptions defines the trigger options
  92088. * @param children defines the list of aggregated animations to run
  92089. * @param condition defines the trigger related conditions
  92090. */
  92091. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92092. /** @hidden */
  92093. _prepare(): void;
  92094. /**
  92095. * Execute the action and executes all the aggregated actions.
  92096. */
  92097. execute(evt: ActionEvent): void;
  92098. /**
  92099. * Serializes the actions and its related information.
  92100. * @param parent defines the object to serialize in
  92101. * @returns the serialized object
  92102. */
  92103. serialize(parent: any): any;
  92104. }
  92105. /**
  92106. * This defines an action responsible to run code (external event) once triggered.
  92107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92108. */
  92109. export class ExecuteCodeAction extends Action {
  92110. /**
  92111. * The callback function to run.
  92112. */
  92113. func: (evt: ActionEvent) => void;
  92114. /**
  92115. * Instantiate the action
  92116. * @param triggerOptions defines the trigger options
  92117. * @param func defines the callback function to run
  92118. * @param condition defines the trigger related conditions
  92119. */
  92120. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92121. /**
  92122. * Execute the action and run the attached code.
  92123. */
  92124. execute(evt: ActionEvent): void;
  92125. }
  92126. /**
  92127. * This defines an action responsible to set the parent property of the target once triggered.
  92128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92129. */
  92130. export class SetParentAction extends Action {
  92131. private _parent;
  92132. private _target;
  92133. /**
  92134. * Instantiate the action
  92135. * @param triggerOptions defines the trigger options
  92136. * @param target defines the target containing the parent property
  92137. * @param parent defines from where the animation should start (animation frame)
  92138. * @param condition defines the trigger related conditions
  92139. */
  92140. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92141. /** @hidden */
  92142. _prepare(): void;
  92143. /**
  92144. * Execute the action and set the parent property.
  92145. */
  92146. execute(): void;
  92147. /**
  92148. * Serializes the actions and its related information.
  92149. * @param parent defines the object to serialize in
  92150. * @returns the serialized object
  92151. */
  92152. serialize(parent: any): any;
  92153. }
  92154. }
  92155. declare module BABYLON {
  92156. /**
  92157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92160. */
  92161. export class ActionManager extends AbstractActionManager {
  92162. /**
  92163. * Nothing
  92164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92165. */
  92166. static readonly NothingTrigger: number;
  92167. /**
  92168. * On pick
  92169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92170. */
  92171. static readonly OnPickTrigger: number;
  92172. /**
  92173. * On left pick
  92174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92175. */
  92176. static readonly OnLeftPickTrigger: number;
  92177. /**
  92178. * On right pick
  92179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92180. */
  92181. static readonly OnRightPickTrigger: number;
  92182. /**
  92183. * On center pick
  92184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92185. */
  92186. static readonly OnCenterPickTrigger: number;
  92187. /**
  92188. * On pick down
  92189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92190. */
  92191. static readonly OnPickDownTrigger: number;
  92192. /**
  92193. * On double pick
  92194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92195. */
  92196. static readonly OnDoublePickTrigger: number;
  92197. /**
  92198. * On pick up
  92199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92200. */
  92201. static readonly OnPickUpTrigger: number;
  92202. /**
  92203. * On pick out.
  92204. * This trigger will only be raised if you also declared a OnPickDown
  92205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92206. */
  92207. static readonly OnPickOutTrigger: number;
  92208. /**
  92209. * On long press
  92210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92211. */
  92212. static readonly OnLongPressTrigger: number;
  92213. /**
  92214. * On pointer over
  92215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92216. */
  92217. static readonly OnPointerOverTrigger: number;
  92218. /**
  92219. * On pointer out
  92220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92221. */
  92222. static readonly OnPointerOutTrigger: number;
  92223. /**
  92224. * On every frame
  92225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92226. */
  92227. static readonly OnEveryFrameTrigger: number;
  92228. /**
  92229. * On intersection enter
  92230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92231. */
  92232. static readonly OnIntersectionEnterTrigger: number;
  92233. /**
  92234. * On intersection exit
  92235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92236. */
  92237. static readonly OnIntersectionExitTrigger: number;
  92238. /**
  92239. * On key down
  92240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92241. */
  92242. static readonly OnKeyDownTrigger: number;
  92243. /**
  92244. * On key up
  92245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92246. */
  92247. static readonly OnKeyUpTrigger: number;
  92248. private _scene;
  92249. /**
  92250. * Creates a new action manager
  92251. * @param scene defines the hosting scene
  92252. */
  92253. constructor(scene: Scene);
  92254. /**
  92255. * Releases all associated resources
  92256. */
  92257. dispose(): void;
  92258. /**
  92259. * Gets hosting scene
  92260. * @returns the hosting scene
  92261. */
  92262. getScene(): Scene;
  92263. /**
  92264. * Does this action manager handles actions of any of the given triggers
  92265. * @param triggers defines the triggers to be tested
  92266. * @return a boolean indicating whether one (or more) of the triggers is handled
  92267. */
  92268. hasSpecificTriggers(triggers: number[]): boolean;
  92269. /**
  92270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92271. * speed.
  92272. * @param triggerA defines the trigger to be tested
  92273. * @param triggerB defines the trigger to be tested
  92274. * @return a boolean indicating whether one (or more) of the triggers is handled
  92275. */
  92276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92277. /**
  92278. * Does this action manager handles actions of a given trigger
  92279. * @param trigger defines the trigger to be tested
  92280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92281. * @return whether the trigger is handled
  92282. */
  92283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92284. /**
  92285. * Does this action manager has pointer triggers
  92286. */
  92287. get hasPointerTriggers(): boolean;
  92288. /**
  92289. * Does this action manager has pick triggers
  92290. */
  92291. get hasPickTriggers(): boolean;
  92292. /**
  92293. * Registers an action to this action manager
  92294. * @param action defines the action to be registered
  92295. * @return the action amended (prepared) after registration
  92296. */
  92297. registerAction(action: IAction): Nullable<IAction>;
  92298. /**
  92299. * Unregisters an action to this action manager
  92300. * @param action defines the action to be unregistered
  92301. * @return a boolean indicating whether the action has been unregistered
  92302. */
  92303. unregisterAction(action: IAction): Boolean;
  92304. /**
  92305. * Process a specific trigger
  92306. * @param trigger defines the trigger to process
  92307. * @param evt defines the event details to be processed
  92308. */
  92309. processTrigger(trigger: number, evt?: IActionEvent): void;
  92310. /** @hidden */
  92311. _getEffectiveTarget(target: any, propertyPath: string): any;
  92312. /** @hidden */
  92313. _getProperty(propertyPath: string): string;
  92314. /**
  92315. * Serialize this manager to a JSON object
  92316. * @param name defines the property name to store this manager
  92317. * @returns a JSON representation of this manager
  92318. */
  92319. serialize(name: string): any;
  92320. /**
  92321. * Creates a new ActionManager from a JSON data
  92322. * @param parsedActions defines the JSON data to read from
  92323. * @param object defines the hosting mesh
  92324. * @param scene defines the hosting scene
  92325. */
  92326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92327. /**
  92328. * Get a trigger name by index
  92329. * @param trigger defines the trigger index
  92330. * @returns a trigger name
  92331. */
  92332. static GetTriggerName(trigger: number): string;
  92333. }
  92334. }
  92335. declare module BABYLON {
  92336. /**
  92337. * Class used to represent a sprite
  92338. * @see http://doc.babylonjs.com/babylon101/sprites
  92339. */
  92340. export class Sprite {
  92341. /** defines the name */
  92342. name: string;
  92343. /** Gets or sets the current world position */
  92344. position: Vector3;
  92345. /** Gets or sets the main color */
  92346. color: Color4;
  92347. /** Gets or sets the width */
  92348. width: number;
  92349. /** Gets or sets the height */
  92350. height: number;
  92351. /** Gets or sets rotation angle */
  92352. angle: number;
  92353. /** Gets or sets the cell index in the sprite sheet */
  92354. cellIndex: number;
  92355. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92356. cellRef: string;
  92357. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92358. invertU: number;
  92359. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92360. invertV: number;
  92361. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92362. disposeWhenFinishedAnimating: boolean;
  92363. /** Gets the list of attached animations */
  92364. animations: Animation[];
  92365. /** Gets or sets a boolean indicating if the sprite can be picked */
  92366. isPickable: boolean;
  92367. /**
  92368. * Gets or sets the associated action manager
  92369. */
  92370. actionManager: Nullable<ActionManager>;
  92371. private _animationStarted;
  92372. private _loopAnimation;
  92373. private _fromIndex;
  92374. private _toIndex;
  92375. private _delay;
  92376. private _direction;
  92377. private _manager;
  92378. private _time;
  92379. private _onAnimationEnd;
  92380. /**
  92381. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92382. */
  92383. isVisible: boolean;
  92384. /**
  92385. * Gets or sets the sprite size
  92386. */
  92387. get size(): number;
  92388. set size(value: number);
  92389. /**
  92390. * Creates a new Sprite
  92391. * @param name defines the name
  92392. * @param manager defines the manager
  92393. */
  92394. constructor(
  92395. /** defines the name */
  92396. name: string, manager: ISpriteManager);
  92397. /**
  92398. * Starts an animation
  92399. * @param from defines the initial key
  92400. * @param to defines the end key
  92401. * @param loop defines if the animation must loop
  92402. * @param delay defines the start delay (in ms)
  92403. * @param onAnimationEnd defines a callback to call when animation ends
  92404. */
  92405. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92406. /** Stops current animation (if any) */
  92407. stopAnimation(): void;
  92408. /** @hidden */
  92409. _animate(deltaTime: number): void;
  92410. /** Release associated resources */
  92411. dispose(): void;
  92412. }
  92413. }
  92414. declare module BABYLON {
  92415. /**
  92416. * Information about the result of picking within a scene
  92417. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92418. */
  92419. export class PickingInfo {
  92420. /** @hidden */
  92421. _pickingUnavailable: boolean;
  92422. /**
  92423. * If the pick collided with an object
  92424. */
  92425. hit: boolean;
  92426. /**
  92427. * Distance away where the pick collided
  92428. */
  92429. distance: number;
  92430. /**
  92431. * The location of pick collision
  92432. */
  92433. pickedPoint: Nullable<Vector3>;
  92434. /**
  92435. * The mesh corresponding the the pick collision
  92436. */
  92437. pickedMesh: Nullable<AbstractMesh>;
  92438. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92439. bu: number;
  92440. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92441. bv: number;
  92442. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92443. faceId: number;
  92444. /** Id of the the submesh that was picked */
  92445. subMeshId: number;
  92446. /** If a sprite was picked, this will be the sprite the pick collided with */
  92447. pickedSprite: Nullable<Sprite>;
  92448. /**
  92449. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92450. */
  92451. originMesh: Nullable<AbstractMesh>;
  92452. /**
  92453. * The ray that was used to perform the picking.
  92454. */
  92455. ray: Nullable<Ray>;
  92456. /**
  92457. * Gets the normal correspodning to the face the pick collided with
  92458. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92459. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92460. * @returns The normal correspodning to the face the pick collided with
  92461. */
  92462. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92463. /**
  92464. * Gets the texture coordinates of where the pick occured
  92465. * @returns the vector containing the coordnates of the texture
  92466. */
  92467. getTextureCoordinates(): Nullable<Vector2>;
  92468. }
  92469. }
  92470. declare module BABYLON {
  92471. /**
  92472. * Gather the list of pointer event types as constants.
  92473. */
  92474. export class PointerEventTypes {
  92475. /**
  92476. * 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.
  92477. */
  92478. static readonly POINTERDOWN: number;
  92479. /**
  92480. * The pointerup event is fired when a pointer is no longer active.
  92481. */
  92482. static readonly POINTERUP: number;
  92483. /**
  92484. * The pointermove event is fired when a pointer changes coordinates.
  92485. */
  92486. static readonly POINTERMOVE: number;
  92487. /**
  92488. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92489. */
  92490. static readonly POINTERWHEEL: number;
  92491. /**
  92492. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92493. */
  92494. static readonly POINTERPICK: number;
  92495. /**
  92496. * The pointertap event is fired when a the object has been touched and released without drag.
  92497. */
  92498. static readonly POINTERTAP: number;
  92499. /**
  92500. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92501. */
  92502. static readonly POINTERDOUBLETAP: number;
  92503. }
  92504. /**
  92505. * Base class of pointer info types.
  92506. */
  92507. export class PointerInfoBase {
  92508. /**
  92509. * Defines the type of event (PointerEventTypes)
  92510. */
  92511. type: number;
  92512. /**
  92513. * Defines the related dom event
  92514. */
  92515. event: PointerEvent | MouseWheelEvent;
  92516. /**
  92517. * Instantiates the base class of pointers info.
  92518. * @param type Defines the type of event (PointerEventTypes)
  92519. * @param event Defines the related dom event
  92520. */
  92521. constructor(
  92522. /**
  92523. * Defines the type of event (PointerEventTypes)
  92524. */
  92525. type: number,
  92526. /**
  92527. * Defines the related dom event
  92528. */
  92529. event: PointerEvent | MouseWheelEvent);
  92530. }
  92531. /**
  92532. * This class is used to store pointer related info for the onPrePointerObservable event.
  92533. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92534. */
  92535. export class PointerInfoPre extends PointerInfoBase {
  92536. /**
  92537. * Ray from a pointer if availible (eg. 6dof controller)
  92538. */
  92539. ray: Nullable<Ray>;
  92540. /**
  92541. * Defines the local position of the pointer on the canvas.
  92542. */
  92543. localPosition: Vector2;
  92544. /**
  92545. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92546. */
  92547. skipOnPointerObservable: boolean;
  92548. /**
  92549. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92550. * @param type Defines the type of event (PointerEventTypes)
  92551. * @param event Defines the related dom event
  92552. * @param localX Defines the local x coordinates of the pointer when the event occured
  92553. * @param localY Defines the local y coordinates of the pointer when the event occured
  92554. */
  92555. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92556. }
  92557. /**
  92558. * This type contains all the data related to a pointer event in Babylon.js.
  92559. * 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.
  92560. */
  92561. export class PointerInfo extends PointerInfoBase {
  92562. /**
  92563. * Defines the picking info associated to the info (if any)\
  92564. */
  92565. pickInfo: Nullable<PickingInfo>;
  92566. /**
  92567. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92568. * @param type Defines the type of event (PointerEventTypes)
  92569. * @param event Defines the related dom event
  92570. * @param pickInfo Defines the picking info associated to the info (if any)\
  92571. */
  92572. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92573. /**
  92574. * Defines the picking info associated to the info (if any)\
  92575. */
  92576. pickInfo: Nullable<PickingInfo>);
  92577. }
  92578. /**
  92579. * Data relating to a touch event on the screen.
  92580. */
  92581. export interface PointerTouch {
  92582. /**
  92583. * X coordinate of touch.
  92584. */
  92585. x: number;
  92586. /**
  92587. * Y coordinate of touch.
  92588. */
  92589. y: number;
  92590. /**
  92591. * Id of touch. Unique for each finger.
  92592. */
  92593. pointerId: number;
  92594. /**
  92595. * Event type passed from DOM.
  92596. */
  92597. type: any;
  92598. }
  92599. }
  92600. declare module BABYLON {
  92601. /**
  92602. * Manage the mouse inputs to control the movement of a free camera.
  92603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92604. */
  92605. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92606. /**
  92607. * Define if touch is enabled in the mouse input
  92608. */
  92609. touchEnabled: boolean;
  92610. /**
  92611. * Defines the camera the input is attached to.
  92612. */
  92613. camera: FreeCamera;
  92614. /**
  92615. * Defines the buttons associated with the input to handle camera move.
  92616. */
  92617. buttons: number[];
  92618. /**
  92619. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92620. */
  92621. angularSensibility: number;
  92622. private _pointerInput;
  92623. private _onMouseMove;
  92624. private _observer;
  92625. private previousPosition;
  92626. /**
  92627. * Observable for when a pointer move event occurs containing the move offset
  92628. */
  92629. onPointerMovedObservable: Observable<{
  92630. offsetX: number;
  92631. offsetY: number;
  92632. }>;
  92633. /**
  92634. * @hidden
  92635. * If the camera should be rotated automatically based on pointer movement
  92636. */
  92637. _allowCameraRotation: boolean;
  92638. /**
  92639. * Manage the mouse inputs to control the movement of a free camera.
  92640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92641. * @param touchEnabled Defines if touch is enabled or not
  92642. */
  92643. constructor(
  92644. /**
  92645. * Define if touch is enabled in the mouse input
  92646. */
  92647. touchEnabled?: boolean);
  92648. /**
  92649. * Attach the input controls to a specific dom element to get the input from.
  92650. * @param element Defines the element the controls should be listened from
  92651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92652. */
  92653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92654. /**
  92655. * Called on JS contextmenu event.
  92656. * Override this method to provide functionality.
  92657. */
  92658. protected onContextMenu(evt: PointerEvent): void;
  92659. /**
  92660. * Detach the current controls from the specified dom element.
  92661. * @param element Defines the element to stop listening the inputs from
  92662. */
  92663. detachControl(element: Nullable<HTMLElement>): void;
  92664. /**
  92665. * Gets the class name of the current intput.
  92666. * @returns the class name
  92667. */
  92668. getClassName(): string;
  92669. /**
  92670. * Get the friendly name associated with the input class.
  92671. * @returns the input friendly name
  92672. */
  92673. getSimpleName(): string;
  92674. }
  92675. }
  92676. declare module BABYLON {
  92677. /**
  92678. * Manage the touch inputs to control the movement of a free camera.
  92679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92680. */
  92681. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92682. /**
  92683. * Defines the camera the input is attached to.
  92684. */
  92685. camera: FreeCamera;
  92686. /**
  92687. * Defines the touch sensibility for rotation.
  92688. * The higher the faster.
  92689. */
  92690. touchAngularSensibility: number;
  92691. /**
  92692. * Defines the touch sensibility for move.
  92693. * The higher the faster.
  92694. */
  92695. touchMoveSensibility: number;
  92696. private _offsetX;
  92697. private _offsetY;
  92698. private _pointerPressed;
  92699. private _pointerInput;
  92700. private _observer;
  92701. private _onLostFocus;
  92702. /**
  92703. * Attach the input controls to a specific dom element to get the input from.
  92704. * @param element Defines the element the controls should be listened from
  92705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92706. */
  92707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92708. /**
  92709. * Detach the current controls from the specified dom element.
  92710. * @param element Defines the element to stop listening the inputs from
  92711. */
  92712. detachControl(element: Nullable<HTMLElement>): void;
  92713. /**
  92714. * Update the current camera state depending on the inputs that have been used this frame.
  92715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92716. */
  92717. checkInputs(): void;
  92718. /**
  92719. * Gets the class name of the current intput.
  92720. * @returns the class name
  92721. */
  92722. getClassName(): string;
  92723. /**
  92724. * Get the friendly name associated with the input class.
  92725. * @returns the input friendly name
  92726. */
  92727. getSimpleName(): string;
  92728. }
  92729. }
  92730. declare module BABYLON {
  92731. /**
  92732. * Default Inputs manager for the FreeCamera.
  92733. * It groups all the default supported inputs for ease of use.
  92734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92735. */
  92736. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92737. /**
  92738. * @hidden
  92739. */
  92740. _mouseInput: Nullable<FreeCameraMouseInput>;
  92741. /**
  92742. * Instantiates a new FreeCameraInputsManager.
  92743. * @param camera Defines the camera the inputs belong to
  92744. */
  92745. constructor(camera: FreeCamera);
  92746. /**
  92747. * Add keyboard input support to the input manager.
  92748. * @returns the current input manager
  92749. */
  92750. addKeyboard(): FreeCameraInputsManager;
  92751. /**
  92752. * Add mouse input support to the input manager.
  92753. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92754. * @returns the current input manager
  92755. */
  92756. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92757. /**
  92758. * Removes the mouse input support from the manager
  92759. * @returns the current input manager
  92760. */
  92761. removeMouse(): FreeCameraInputsManager;
  92762. /**
  92763. * Add touch input support to the input manager.
  92764. * @returns the current input manager
  92765. */
  92766. addTouch(): FreeCameraInputsManager;
  92767. /**
  92768. * Remove all attached input methods from a camera
  92769. */
  92770. clear(): void;
  92771. }
  92772. }
  92773. declare module BABYLON {
  92774. /**
  92775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92776. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92777. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92778. */
  92779. export class FreeCamera extends TargetCamera {
  92780. /**
  92781. * Define the collision ellipsoid of the camera.
  92782. * This is helpful to simulate a camera body like the player body around the camera
  92783. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92784. */
  92785. ellipsoid: Vector3;
  92786. /**
  92787. * Define an offset for the position of the ellipsoid around the camera.
  92788. * This can be helpful to determine the center of the body near the gravity center of the body
  92789. * instead of its head.
  92790. */
  92791. ellipsoidOffset: Vector3;
  92792. /**
  92793. * Enable or disable collisions of the camera with the rest of the scene objects.
  92794. */
  92795. checkCollisions: boolean;
  92796. /**
  92797. * Enable or disable gravity on the camera.
  92798. */
  92799. applyGravity: boolean;
  92800. /**
  92801. * Define the input manager associated to the camera.
  92802. */
  92803. inputs: FreeCameraInputsManager;
  92804. /**
  92805. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92806. * Higher values reduce sensitivity.
  92807. */
  92808. get angularSensibility(): number;
  92809. /**
  92810. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92811. * Higher values reduce sensitivity.
  92812. */
  92813. set angularSensibility(value: number);
  92814. /**
  92815. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92816. */
  92817. get keysUp(): number[];
  92818. set keysUp(value: number[]);
  92819. /**
  92820. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92821. */
  92822. get keysUpward(): number[];
  92823. set keysUpward(value: number[]);
  92824. /**
  92825. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92826. */
  92827. get keysDown(): number[];
  92828. set keysDown(value: number[]);
  92829. /**
  92830. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92831. */
  92832. get keysDownward(): number[];
  92833. set keysDownward(value: number[]);
  92834. /**
  92835. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92836. */
  92837. get keysLeft(): number[];
  92838. set keysLeft(value: number[]);
  92839. /**
  92840. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92841. */
  92842. get keysRight(): number[];
  92843. set keysRight(value: number[]);
  92844. /**
  92845. * Event raised when the camera collide with a mesh in the scene.
  92846. */
  92847. onCollide: (collidedMesh: AbstractMesh) => void;
  92848. private _collider;
  92849. private _needMoveForGravity;
  92850. private _oldPosition;
  92851. private _diffPosition;
  92852. private _newPosition;
  92853. /** @hidden */
  92854. _localDirection: Vector3;
  92855. /** @hidden */
  92856. _transformedDirection: Vector3;
  92857. /**
  92858. * Instantiates a Free Camera.
  92859. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92860. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92862. * @param name Define the name of the camera in the scene
  92863. * @param position Define the start position of the camera in the scene
  92864. * @param scene Define the scene the camera belongs to
  92865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92866. */
  92867. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92868. /**
  92869. * Attached controls to the current camera.
  92870. * @param element Defines the element the controls should be listened from
  92871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92872. */
  92873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92874. /**
  92875. * Detach the current controls from the camera.
  92876. * The camera will stop reacting to inputs.
  92877. * @param element Defines the element to stop listening the inputs from
  92878. */
  92879. detachControl(element: HTMLElement): void;
  92880. private _collisionMask;
  92881. /**
  92882. * Define a collision mask to limit the list of object the camera can collide with
  92883. */
  92884. get collisionMask(): number;
  92885. set collisionMask(mask: number);
  92886. /** @hidden */
  92887. _collideWithWorld(displacement: Vector3): void;
  92888. private _onCollisionPositionChange;
  92889. /** @hidden */
  92890. _checkInputs(): void;
  92891. /** @hidden */
  92892. _decideIfNeedsToMove(): boolean;
  92893. /** @hidden */
  92894. _updatePosition(): void;
  92895. /**
  92896. * Destroy the camera and release the current resources hold by it.
  92897. */
  92898. dispose(): void;
  92899. /**
  92900. * Gets the current object class name.
  92901. * @return the class name
  92902. */
  92903. getClassName(): string;
  92904. }
  92905. }
  92906. declare module BABYLON {
  92907. /**
  92908. * Represents a gamepad control stick position
  92909. */
  92910. export class StickValues {
  92911. /**
  92912. * The x component of the control stick
  92913. */
  92914. x: number;
  92915. /**
  92916. * The y component of the control stick
  92917. */
  92918. y: number;
  92919. /**
  92920. * Initializes the gamepad x and y control stick values
  92921. * @param x The x component of the gamepad control stick value
  92922. * @param y The y component of the gamepad control stick value
  92923. */
  92924. constructor(
  92925. /**
  92926. * The x component of the control stick
  92927. */
  92928. x: number,
  92929. /**
  92930. * The y component of the control stick
  92931. */
  92932. y: number);
  92933. }
  92934. /**
  92935. * An interface which manages callbacks for gamepad button changes
  92936. */
  92937. export interface GamepadButtonChanges {
  92938. /**
  92939. * Called when a gamepad has been changed
  92940. */
  92941. changed: boolean;
  92942. /**
  92943. * Called when a gamepad press event has been triggered
  92944. */
  92945. pressChanged: boolean;
  92946. /**
  92947. * Called when a touch event has been triggered
  92948. */
  92949. touchChanged: boolean;
  92950. /**
  92951. * Called when a value has changed
  92952. */
  92953. valueChanged: boolean;
  92954. }
  92955. /**
  92956. * Represents a gamepad
  92957. */
  92958. export class Gamepad {
  92959. /**
  92960. * The id of the gamepad
  92961. */
  92962. id: string;
  92963. /**
  92964. * The index of the gamepad
  92965. */
  92966. index: number;
  92967. /**
  92968. * The browser gamepad
  92969. */
  92970. browserGamepad: any;
  92971. /**
  92972. * Specifies what type of gamepad this represents
  92973. */
  92974. type: number;
  92975. private _leftStick;
  92976. private _rightStick;
  92977. /** @hidden */
  92978. _isConnected: boolean;
  92979. private _leftStickAxisX;
  92980. private _leftStickAxisY;
  92981. private _rightStickAxisX;
  92982. private _rightStickAxisY;
  92983. /**
  92984. * Triggered when the left control stick has been changed
  92985. */
  92986. private _onleftstickchanged;
  92987. /**
  92988. * Triggered when the right control stick has been changed
  92989. */
  92990. private _onrightstickchanged;
  92991. /**
  92992. * Represents a gamepad controller
  92993. */
  92994. static GAMEPAD: number;
  92995. /**
  92996. * Represents a generic controller
  92997. */
  92998. static GENERIC: number;
  92999. /**
  93000. * Represents an XBox controller
  93001. */
  93002. static XBOX: number;
  93003. /**
  93004. * Represents a pose-enabled controller
  93005. */
  93006. static POSE_ENABLED: number;
  93007. /**
  93008. * Represents an Dual Shock controller
  93009. */
  93010. static DUALSHOCK: number;
  93011. /**
  93012. * Specifies whether the left control stick should be Y-inverted
  93013. */
  93014. protected _invertLeftStickY: boolean;
  93015. /**
  93016. * Specifies if the gamepad has been connected
  93017. */
  93018. get isConnected(): boolean;
  93019. /**
  93020. * Initializes the gamepad
  93021. * @param id The id of the gamepad
  93022. * @param index The index of the gamepad
  93023. * @param browserGamepad The browser gamepad
  93024. * @param leftStickX The x component of the left joystick
  93025. * @param leftStickY The y component of the left joystick
  93026. * @param rightStickX The x component of the right joystick
  93027. * @param rightStickY The y component of the right joystick
  93028. */
  93029. constructor(
  93030. /**
  93031. * The id of the gamepad
  93032. */
  93033. id: string,
  93034. /**
  93035. * The index of the gamepad
  93036. */
  93037. index: number,
  93038. /**
  93039. * The browser gamepad
  93040. */
  93041. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93042. /**
  93043. * Callback triggered when the left joystick has changed
  93044. * @param callback
  93045. */
  93046. onleftstickchanged(callback: (values: StickValues) => void): void;
  93047. /**
  93048. * Callback triggered when the right joystick has changed
  93049. * @param callback
  93050. */
  93051. onrightstickchanged(callback: (values: StickValues) => void): void;
  93052. /**
  93053. * Gets the left joystick
  93054. */
  93055. get leftStick(): StickValues;
  93056. /**
  93057. * Sets the left joystick values
  93058. */
  93059. set leftStick(newValues: StickValues);
  93060. /**
  93061. * Gets the right joystick
  93062. */
  93063. get rightStick(): StickValues;
  93064. /**
  93065. * Sets the right joystick value
  93066. */
  93067. set rightStick(newValues: StickValues);
  93068. /**
  93069. * Updates the gamepad joystick positions
  93070. */
  93071. update(): void;
  93072. /**
  93073. * Disposes the gamepad
  93074. */
  93075. dispose(): void;
  93076. }
  93077. /**
  93078. * Represents a generic gamepad
  93079. */
  93080. export class GenericPad extends Gamepad {
  93081. private _buttons;
  93082. private _onbuttondown;
  93083. private _onbuttonup;
  93084. /**
  93085. * Observable triggered when a button has been pressed
  93086. */
  93087. onButtonDownObservable: Observable<number>;
  93088. /**
  93089. * Observable triggered when a button has been released
  93090. */
  93091. onButtonUpObservable: Observable<number>;
  93092. /**
  93093. * Callback triggered when a button has been pressed
  93094. * @param callback Called when a button has been pressed
  93095. */
  93096. onbuttondown(callback: (buttonPressed: number) => void): void;
  93097. /**
  93098. * Callback triggered when a button has been released
  93099. * @param callback Called when a button has been released
  93100. */
  93101. onbuttonup(callback: (buttonReleased: number) => void): void;
  93102. /**
  93103. * Initializes the generic gamepad
  93104. * @param id The id of the generic gamepad
  93105. * @param index The index of the generic gamepad
  93106. * @param browserGamepad The browser gamepad
  93107. */
  93108. constructor(id: string, index: number, browserGamepad: any);
  93109. private _setButtonValue;
  93110. /**
  93111. * Updates the generic gamepad
  93112. */
  93113. update(): void;
  93114. /**
  93115. * Disposes the generic gamepad
  93116. */
  93117. dispose(): void;
  93118. }
  93119. }
  93120. declare module BABYLON {
  93121. /**
  93122. * Defines the types of pose enabled controllers that are supported
  93123. */
  93124. export enum PoseEnabledControllerType {
  93125. /**
  93126. * HTC Vive
  93127. */
  93128. VIVE = 0,
  93129. /**
  93130. * Oculus Rift
  93131. */
  93132. OCULUS = 1,
  93133. /**
  93134. * Windows mixed reality
  93135. */
  93136. WINDOWS = 2,
  93137. /**
  93138. * Samsung gear VR
  93139. */
  93140. GEAR_VR = 3,
  93141. /**
  93142. * Google Daydream
  93143. */
  93144. DAYDREAM = 4,
  93145. /**
  93146. * Generic
  93147. */
  93148. GENERIC = 5
  93149. }
  93150. /**
  93151. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93152. */
  93153. export interface MutableGamepadButton {
  93154. /**
  93155. * Value of the button/trigger
  93156. */
  93157. value: number;
  93158. /**
  93159. * If the button/trigger is currently touched
  93160. */
  93161. touched: boolean;
  93162. /**
  93163. * If the button/trigger is currently pressed
  93164. */
  93165. pressed: boolean;
  93166. }
  93167. /**
  93168. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93169. * @hidden
  93170. */
  93171. export interface ExtendedGamepadButton extends GamepadButton {
  93172. /**
  93173. * If the button/trigger is currently pressed
  93174. */
  93175. readonly pressed: boolean;
  93176. /**
  93177. * If the button/trigger is currently touched
  93178. */
  93179. readonly touched: boolean;
  93180. /**
  93181. * Value of the button/trigger
  93182. */
  93183. readonly value: number;
  93184. }
  93185. /** @hidden */
  93186. export interface _GamePadFactory {
  93187. /**
  93188. * Returns whether or not the current gamepad can be created for this type of controller.
  93189. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93190. * @returns true if it can be created, otherwise false
  93191. */
  93192. canCreate(gamepadInfo: any): boolean;
  93193. /**
  93194. * Creates a new instance of the Gamepad.
  93195. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93196. * @returns the new gamepad instance
  93197. */
  93198. create(gamepadInfo: any): Gamepad;
  93199. }
  93200. /**
  93201. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93202. */
  93203. export class PoseEnabledControllerHelper {
  93204. /** @hidden */
  93205. static _ControllerFactories: _GamePadFactory[];
  93206. /** @hidden */
  93207. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93208. /**
  93209. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93210. * @param vrGamepad the gamepad to initialized
  93211. * @returns a vr controller of the type the gamepad identified as
  93212. */
  93213. static InitiateController(vrGamepad: any): Gamepad;
  93214. }
  93215. /**
  93216. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93217. */
  93218. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93219. /**
  93220. * If the controller is used in a webXR session
  93221. */
  93222. isXR: boolean;
  93223. private _deviceRoomPosition;
  93224. private _deviceRoomRotationQuaternion;
  93225. /**
  93226. * The device position in babylon space
  93227. */
  93228. devicePosition: Vector3;
  93229. /**
  93230. * The device rotation in babylon space
  93231. */
  93232. deviceRotationQuaternion: Quaternion;
  93233. /**
  93234. * The scale factor of the device in babylon space
  93235. */
  93236. deviceScaleFactor: number;
  93237. /**
  93238. * (Likely devicePosition should be used instead) The device position in its room space
  93239. */
  93240. position: Vector3;
  93241. /**
  93242. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93243. */
  93244. rotationQuaternion: Quaternion;
  93245. /**
  93246. * The type of controller (Eg. Windows mixed reality)
  93247. */
  93248. controllerType: PoseEnabledControllerType;
  93249. protected _calculatedPosition: Vector3;
  93250. private _calculatedRotation;
  93251. /**
  93252. * The raw pose from the device
  93253. */
  93254. rawPose: DevicePose;
  93255. private _trackPosition;
  93256. private _maxRotationDistFromHeadset;
  93257. private _draggedRoomRotation;
  93258. /**
  93259. * @hidden
  93260. */
  93261. _disableTrackPosition(fixedPosition: Vector3): void;
  93262. /**
  93263. * Internal, the mesh attached to the controller
  93264. * @hidden
  93265. */
  93266. _mesh: Nullable<AbstractMesh>;
  93267. private _poseControlledCamera;
  93268. private _leftHandSystemQuaternion;
  93269. /**
  93270. * Internal, matrix used to convert room space to babylon space
  93271. * @hidden
  93272. */
  93273. _deviceToWorld: Matrix;
  93274. /**
  93275. * Node to be used when casting a ray from the controller
  93276. * @hidden
  93277. */
  93278. _pointingPoseNode: Nullable<TransformNode>;
  93279. /**
  93280. * Name of the child mesh that can be used to cast a ray from the controller
  93281. */
  93282. static readonly POINTING_POSE: string;
  93283. /**
  93284. * Creates a new PoseEnabledController from a gamepad
  93285. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93286. */
  93287. constructor(browserGamepad: any);
  93288. private _workingMatrix;
  93289. /**
  93290. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93291. */
  93292. update(): void;
  93293. /**
  93294. * Updates only the pose device and mesh without doing any button event checking
  93295. */
  93296. protected _updatePoseAndMesh(): void;
  93297. /**
  93298. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93299. * @param poseData raw pose fromthe device
  93300. */
  93301. updateFromDevice(poseData: DevicePose): void;
  93302. /**
  93303. * @hidden
  93304. */
  93305. _meshAttachedObservable: Observable<AbstractMesh>;
  93306. /**
  93307. * Attaches a mesh to the controller
  93308. * @param mesh the mesh to be attached
  93309. */
  93310. attachToMesh(mesh: AbstractMesh): void;
  93311. /**
  93312. * Attaches the controllers mesh to a camera
  93313. * @param camera the camera the mesh should be attached to
  93314. */
  93315. attachToPoseControlledCamera(camera: TargetCamera): void;
  93316. /**
  93317. * Disposes of the controller
  93318. */
  93319. dispose(): void;
  93320. /**
  93321. * The mesh that is attached to the controller
  93322. */
  93323. get mesh(): Nullable<AbstractMesh>;
  93324. /**
  93325. * Gets the ray of the controller in the direction the controller is pointing
  93326. * @param length the length the resulting ray should be
  93327. * @returns a ray in the direction the controller is pointing
  93328. */
  93329. getForwardRay(length?: number): Ray;
  93330. }
  93331. }
  93332. declare module BABYLON {
  93333. /**
  93334. * Defines the WebVRController object that represents controllers tracked in 3D space
  93335. */
  93336. export abstract class WebVRController extends PoseEnabledController {
  93337. /**
  93338. * Internal, the default controller model for the controller
  93339. */
  93340. protected _defaultModel: Nullable<AbstractMesh>;
  93341. /**
  93342. * Fired when the trigger state has changed
  93343. */
  93344. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93345. /**
  93346. * Fired when the main button state has changed
  93347. */
  93348. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93349. /**
  93350. * Fired when the secondary button state has changed
  93351. */
  93352. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93353. /**
  93354. * Fired when the pad state has changed
  93355. */
  93356. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93357. /**
  93358. * Fired when controllers stick values have changed
  93359. */
  93360. onPadValuesChangedObservable: Observable<StickValues>;
  93361. /**
  93362. * Array of button availible on the controller
  93363. */
  93364. protected _buttons: Array<MutableGamepadButton>;
  93365. private _onButtonStateChange;
  93366. /**
  93367. * Fired when a controller button's state has changed
  93368. * @param callback the callback containing the button that was modified
  93369. */
  93370. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93371. /**
  93372. * X and Y axis corresponding to the controllers joystick
  93373. */
  93374. pad: StickValues;
  93375. /**
  93376. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93377. */
  93378. hand: string;
  93379. /**
  93380. * The default controller model for the controller
  93381. */
  93382. get defaultModel(): Nullable<AbstractMesh>;
  93383. /**
  93384. * Creates a new WebVRController from a gamepad
  93385. * @param vrGamepad the gamepad that the WebVRController should be created from
  93386. */
  93387. constructor(vrGamepad: any);
  93388. /**
  93389. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93390. */
  93391. update(): void;
  93392. /**
  93393. * Function to be called when a button is modified
  93394. */
  93395. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93396. /**
  93397. * Loads a mesh and attaches it to the controller
  93398. * @param scene the scene the mesh should be added to
  93399. * @param meshLoaded callback for when the mesh has been loaded
  93400. */
  93401. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93402. private _setButtonValue;
  93403. private _changes;
  93404. private _checkChanges;
  93405. /**
  93406. * Disposes of th webVRCOntroller
  93407. */
  93408. dispose(): void;
  93409. }
  93410. }
  93411. declare module BABYLON {
  93412. /**
  93413. * The HemisphericLight simulates the ambient environment light,
  93414. * so the passed direction is the light reflection direction, not the incoming direction.
  93415. */
  93416. export class HemisphericLight extends Light {
  93417. /**
  93418. * The groundColor is the light in the opposite direction to the one specified during creation.
  93419. * 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.
  93420. */
  93421. groundColor: Color3;
  93422. /**
  93423. * The light reflection direction, not the incoming direction.
  93424. */
  93425. direction: Vector3;
  93426. /**
  93427. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93428. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93429. * The HemisphericLight can't cast shadows.
  93430. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93431. * @param name The friendly name of the light
  93432. * @param direction The direction of the light reflection
  93433. * @param scene The scene the light belongs to
  93434. */
  93435. constructor(name: string, direction: Vector3, scene: Scene);
  93436. protected _buildUniformLayout(): void;
  93437. /**
  93438. * Returns the string "HemisphericLight".
  93439. * @return The class name
  93440. */
  93441. getClassName(): string;
  93442. /**
  93443. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93444. * Returns the updated direction.
  93445. * @param target The target the direction should point to
  93446. * @return The computed direction
  93447. */
  93448. setDirectionToTarget(target: Vector3): Vector3;
  93449. /**
  93450. * Returns the shadow generator associated to the light.
  93451. * @returns Always null for hemispheric lights because it does not support shadows.
  93452. */
  93453. getShadowGenerator(): Nullable<IShadowGenerator>;
  93454. /**
  93455. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93456. * @param effect The effect to update
  93457. * @param lightIndex The index of the light in the effect to update
  93458. * @returns The hemispheric light
  93459. */
  93460. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93461. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93462. /**
  93463. * Computes the world matrix of the node
  93464. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93465. * @param useWasUpdatedFlag defines a reserved property
  93466. * @returns the world matrix
  93467. */
  93468. computeWorldMatrix(): Matrix;
  93469. /**
  93470. * Returns the integer 3.
  93471. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93472. */
  93473. getTypeID(): number;
  93474. /**
  93475. * Prepares the list of defines specific to the light type.
  93476. * @param defines the list of defines
  93477. * @param lightIndex defines the index of the light for the effect
  93478. */
  93479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93480. }
  93481. }
  93482. declare module BABYLON {
  93483. /** @hidden */
  93484. export var vrMultiviewToSingleviewPixelShader: {
  93485. name: string;
  93486. shader: string;
  93487. };
  93488. }
  93489. declare module BABYLON {
  93490. /**
  93491. * Renders to multiple views with a single draw call
  93492. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93493. */
  93494. export class MultiviewRenderTarget extends RenderTargetTexture {
  93495. /**
  93496. * Creates a multiview render target
  93497. * @param scene scene used with the render target
  93498. * @param size the size of the render target (used for each view)
  93499. */
  93500. constructor(scene: Scene, size?: number | {
  93501. width: number;
  93502. height: number;
  93503. } | {
  93504. ratio: number;
  93505. });
  93506. /**
  93507. * @hidden
  93508. * @param faceIndex the face index, if its a cube texture
  93509. */
  93510. _bindFrameBuffer(faceIndex?: number): void;
  93511. /**
  93512. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93513. * @returns the view count
  93514. */
  93515. getViewCount(): number;
  93516. }
  93517. }
  93518. declare module BABYLON {
  93519. /**
  93520. * Represents a camera frustum
  93521. */
  93522. export class Frustum {
  93523. /**
  93524. * Gets the planes representing the frustum
  93525. * @param transform matrix to be applied to the returned planes
  93526. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93527. */
  93528. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93529. /**
  93530. * Gets the near frustum plane transformed by the transform matrix
  93531. * @param transform transformation matrix to be applied to the resulting frustum plane
  93532. * @param frustumPlane the resuling frustum plane
  93533. */
  93534. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93535. /**
  93536. * Gets the far frustum plane transformed by the transform matrix
  93537. * @param transform transformation matrix to be applied to the resulting frustum plane
  93538. * @param frustumPlane the resuling frustum plane
  93539. */
  93540. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93541. /**
  93542. * Gets the left frustum plane transformed by the transform matrix
  93543. * @param transform transformation matrix to be applied to the resulting frustum plane
  93544. * @param frustumPlane the resuling frustum plane
  93545. */
  93546. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93547. /**
  93548. * Gets the right frustum plane transformed by the transform matrix
  93549. * @param transform transformation matrix to be applied to the resulting frustum plane
  93550. * @param frustumPlane the resuling frustum plane
  93551. */
  93552. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93553. /**
  93554. * Gets the top frustum plane transformed by the transform matrix
  93555. * @param transform transformation matrix to be applied to the resulting frustum plane
  93556. * @param frustumPlane the resuling frustum plane
  93557. */
  93558. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93559. /**
  93560. * Gets the bottom frustum plane transformed by the transform matrix
  93561. * @param transform transformation matrix to be applied to the resulting frustum plane
  93562. * @param frustumPlane the resuling frustum plane
  93563. */
  93564. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93565. /**
  93566. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93567. * @param transform transformation matrix to be applied to the resulting frustum planes
  93568. * @param frustumPlanes the resuling frustum planes
  93569. */
  93570. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93571. }
  93572. }
  93573. declare module BABYLON {
  93574. interface Engine {
  93575. /**
  93576. * Creates a new multiview render target
  93577. * @param width defines the width of the texture
  93578. * @param height defines the height of the texture
  93579. * @returns the created multiview texture
  93580. */
  93581. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93582. /**
  93583. * Binds a multiview framebuffer to be drawn to
  93584. * @param multiviewTexture texture to bind
  93585. */
  93586. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93587. }
  93588. interface Camera {
  93589. /**
  93590. * @hidden
  93591. * 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)
  93592. */
  93593. _useMultiviewToSingleView: boolean;
  93594. /**
  93595. * @hidden
  93596. * 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)
  93597. */
  93598. _multiviewTexture: Nullable<RenderTargetTexture>;
  93599. /**
  93600. * @hidden
  93601. * ensures the multiview texture of the camera exists and has the specified width/height
  93602. * @param width height to set on the multiview texture
  93603. * @param height width to set on the multiview texture
  93604. */
  93605. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93606. }
  93607. interface Scene {
  93608. /** @hidden */
  93609. _transformMatrixR: Matrix;
  93610. /** @hidden */
  93611. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93612. /** @hidden */
  93613. _createMultiviewUbo(): void;
  93614. /** @hidden */
  93615. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93616. /** @hidden */
  93617. _renderMultiviewToSingleView(camera: Camera): void;
  93618. }
  93619. }
  93620. declare module BABYLON {
  93621. /**
  93622. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93623. * This will not be used for webXR as it supports displaying texture arrays directly
  93624. */
  93625. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93626. /**
  93627. * Initializes a VRMultiviewToSingleview
  93628. * @param name name of the post process
  93629. * @param camera camera to be applied to
  93630. * @param scaleFactor scaling factor to the size of the output texture
  93631. */
  93632. constructor(name: string, camera: Camera, scaleFactor: number);
  93633. }
  93634. }
  93635. declare module BABYLON {
  93636. /**
  93637. * Interface used to define additional presentation attributes
  93638. */
  93639. export interface IVRPresentationAttributes {
  93640. /**
  93641. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93642. */
  93643. highRefreshRate: boolean;
  93644. /**
  93645. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93646. */
  93647. foveationLevel: number;
  93648. }
  93649. interface Engine {
  93650. /** @hidden */
  93651. _vrDisplay: any;
  93652. /** @hidden */
  93653. _vrSupported: boolean;
  93654. /** @hidden */
  93655. _oldSize: Size;
  93656. /** @hidden */
  93657. _oldHardwareScaleFactor: number;
  93658. /** @hidden */
  93659. _vrExclusivePointerMode: boolean;
  93660. /** @hidden */
  93661. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93662. /** @hidden */
  93663. _onVRDisplayPointerRestricted: () => void;
  93664. /** @hidden */
  93665. _onVRDisplayPointerUnrestricted: () => void;
  93666. /** @hidden */
  93667. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93668. /** @hidden */
  93669. _onVrDisplayDisconnect: Nullable<() => void>;
  93670. /** @hidden */
  93671. _onVrDisplayPresentChange: Nullable<() => void>;
  93672. /**
  93673. * Observable signaled when VR display mode changes
  93674. */
  93675. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93676. /**
  93677. * Observable signaled when VR request present is complete
  93678. */
  93679. onVRRequestPresentComplete: Observable<boolean>;
  93680. /**
  93681. * Observable signaled when VR request present starts
  93682. */
  93683. onVRRequestPresentStart: Observable<Engine>;
  93684. /**
  93685. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93686. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93687. */
  93688. isInVRExclusivePointerMode: boolean;
  93689. /**
  93690. * Gets a boolean indicating if a webVR device was detected
  93691. * @returns true if a webVR device was detected
  93692. */
  93693. isVRDevicePresent(): boolean;
  93694. /**
  93695. * Gets the current webVR device
  93696. * @returns the current webVR device (or null)
  93697. */
  93698. getVRDevice(): any;
  93699. /**
  93700. * Initializes a webVR display and starts listening to display change events
  93701. * The onVRDisplayChangedObservable will be notified upon these changes
  93702. * @returns A promise containing a VRDisplay and if vr is supported
  93703. */
  93704. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93705. /** @hidden */
  93706. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93707. /**
  93708. * Gets or sets the presentation attributes used to configure VR rendering
  93709. */
  93710. vrPresentationAttributes?: IVRPresentationAttributes;
  93711. /**
  93712. * Call this function to switch to webVR mode
  93713. * Will do nothing if webVR is not supported or if there is no webVR device
  93714. * @param options the webvr options provided to the camera. mainly used for multiview
  93715. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93716. */
  93717. enableVR(options: WebVROptions): void;
  93718. /** @hidden */
  93719. _onVRFullScreenTriggered(): void;
  93720. }
  93721. }
  93722. declare module BABYLON {
  93723. /**
  93724. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93725. * IMPORTANT!! The data is right-hand data.
  93726. * @export
  93727. * @interface DevicePose
  93728. */
  93729. export interface DevicePose {
  93730. /**
  93731. * The position of the device, values in array are [x,y,z].
  93732. */
  93733. readonly position: Nullable<Float32Array>;
  93734. /**
  93735. * The linearVelocity of the device, values in array are [x,y,z].
  93736. */
  93737. readonly linearVelocity: Nullable<Float32Array>;
  93738. /**
  93739. * The linearAcceleration of the device, values in array are [x,y,z].
  93740. */
  93741. readonly linearAcceleration: Nullable<Float32Array>;
  93742. /**
  93743. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93744. */
  93745. readonly orientation: Nullable<Float32Array>;
  93746. /**
  93747. * The angularVelocity of the device, values in array are [x,y,z].
  93748. */
  93749. readonly angularVelocity: Nullable<Float32Array>;
  93750. /**
  93751. * The angularAcceleration of the device, values in array are [x,y,z].
  93752. */
  93753. readonly angularAcceleration: Nullable<Float32Array>;
  93754. }
  93755. /**
  93756. * Interface representing a pose controlled object in Babylon.
  93757. * A pose controlled object has both regular pose values as well as pose values
  93758. * from an external device such as a VR head mounted display
  93759. */
  93760. export interface PoseControlled {
  93761. /**
  93762. * The position of the object in babylon space.
  93763. */
  93764. position: Vector3;
  93765. /**
  93766. * The rotation quaternion of the object in babylon space.
  93767. */
  93768. rotationQuaternion: Quaternion;
  93769. /**
  93770. * The position of the device in babylon space.
  93771. */
  93772. devicePosition?: Vector3;
  93773. /**
  93774. * The rotation quaternion of the device in babylon space.
  93775. */
  93776. deviceRotationQuaternion: Quaternion;
  93777. /**
  93778. * The raw pose coming from the device.
  93779. */
  93780. rawPose: Nullable<DevicePose>;
  93781. /**
  93782. * The scale of the device to be used when translating from device space to babylon space.
  93783. */
  93784. deviceScaleFactor: number;
  93785. /**
  93786. * Updates the poseControlled values based on the input device pose.
  93787. * @param poseData the pose data to update the object with
  93788. */
  93789. updateFromDevice(poseData: DevicePose): void;
  93790. }
  93791. /**
  93792. * Set of options to customize the webVRCamera
  93793. */
  93794. export interface WebVROptions {
  93795. /**
  93796. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93797. */
  93798. trackPosition?: boolean;
  93799. /**
  93800. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93801. */
  93802. positionScale?: number;
  93803. /**
  93804. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93805. */
  93806. displayName?: string;
  93807. /**
  93808. * Should the native controller meshes be initialized. (default: true)
  93809. */
  93810. controllerMeshes?: boolean;
  93811. /**
  93812. * Creating a default HemiLight only on controllers. (default: true)
  93813. */
  93814. defaultLightingOnControllers?: boolean;
  93815. /**
  93816. * If you don't want to use the default VR button of the helper. (default: false)
  93817. */
  93818. useCustomVRButton?: boolean;
  93819. /**
  93820. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93821. */
  93822. customVRButton?: HTMLButtonElement;
  93823. /**
  93824. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93825. */
  93826. rayLength?: number;
  93827. /**
  93828. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93829. */
  93830. defaultHeight?: number;
  93831. /**
  93832. * If multiview should be used if availible (default: false)
  93833. */
  93834. useMultiview?: boolean;
  93835. }
  93836. /**
  93837. * This represents a WebVR camera.
  93838. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93839. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93840. */
  93841. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93842. private webVROptions;
  93843. /**
  93844. * @hidden
  93845. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93846. */
  93847. _vrDevice: any;
  93848. /**
  93849. * The rawPose of the vrDevice.
  93850. */
  93851. rawPose: Nullable<DevicePose>;
  93852. private _onVREnabled;
  93853. private _specsVersion;
  93854. private _attached;
  93855. private _frameData;
  93856. protected _descendants: Array<Node>;
  93857. private _deviceRoomPosition;
  93858. /** @hidden */
  93859. _deviceRoomRotationQuaternion: Quaternion;
  93860. private _standingMatrix;
  93861. /**
  93862. * Represents device position in babylon space.
  93863. */
  93864. devicePosition: Vector3;
  93865. /**
  93866. * Represents device rotation in babylon space.
  93867. */
  93868. deviceRotationQuaternion: Quaternion;
  93869. /**
  93870. * The scale of the device to be used when translating from device space to babylon space.
  93871. */
  93872. deviceScaleFactor: number;
  93873. private _deviceToWorld;
  93874. private _worldToDevice;
  93875. /**
  93876. * References to the webVR controllers for the vrDevice.
  93877. */
  93878. controllers: Array<WebVRController>;
  93879. /**
  93880. * Emits an event when a controller is attached.
  93881. */
  93882. onControllersAttachedObservable: Observable<WebVRController[]>;
  93883. /**
  93884. * Emits an event when a controller's mesh has been loaded;
  93885. */
  93886. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93887. /**
  93888. * Emits an event when the HMD's pose has been updated.
  93889. */
  93890. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93891. private _poseSet;
  93892. /**
  93893. * If the rig cameras be used as parent instead of this camera.
  93894. */
  93895. rigParenting: boolean;
  93896. private _lightOnControllers;
  93897. private _defaultHeight?;
  93898. /**
  93899. * Instantiates a WebVRFreeCamera.
  93900. * @param name The name of the WebVRFreeCamera
  93901. * @param position The starting anchor position for the camera
  93902. * @param scene The scene the camera belongs to
  93903. * @param webVROptions a set of customizable options for the webVRCamera
  93904. */
  93905. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93906. /**
  93907. * Gets the device distance from the ground in meters.
  93908. * @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.
  93909. */
  93910. deviceDistanceToRoomGround(): number;
  93911. /**
  93912. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93913. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93914. */
  93915. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93916. /**
  93917. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93918. * @returns A promise with a boolean set to if the standing matrix is supported.
  93919. */
  93920. useStandingMatrixAsync(): Promise<boolean>;
  93921. /**
  93922. * Disposes the camera
  93923. */
  93924. dispose(): void;
  93925. /**
  93926. * Gets a vrController by name.
  93927. * @param name The name of the controller to retreive
  93928. * @returns the controller matching the name specified or null if not found
  93929. */
  93930. getControllerByName(name: string): Nullable<WebVRController>;
  93931. private _leftController;
  93932. /**
  93933. * The controller corresponding to the users left hand.
  93934. */
  93935. get leftController(): Nullable<WebVRController>;
  93936. private _rightController;
  93937. /**
  93938. * The controller corresponding to the users right hand.
  93939. */
  93940. get rightController(): Nullable<WebVRController>;
  93941. /**
  93942. * Casts a ray forward from the vrCamera's gaze.
  93943. * @param length Length of the ray (default: 100)
  93944. * @returns the ray corresponding to the gaze
  93945. */
  93946. getForwardRay(length?: number): Ray;
  93947. /**
  93948. * @hidden
  93949. * Updates the camera based on device's frame data
  93950. */
  93951. _checkInputs(): void;
  93952. /**
  93953. * Updates the poseControlled values based on the input device pose.
  93954. * @param poseData Pose coming from the device
  93955. */
  93956. updateFromDevice(poseData: DevicePose): void;
  93957. private _htmlElementAttached;
  93958. private _detachIfAttached;
  93959. /**
  93960. * WebVR's attach control will start broadcasting frames to the device.
  93961. * Note that in certain browsers (chrome for example) this function must be called
  93962. * within a user-interaction callback. Example:
  93963. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93964. *
  93965. * @param element html element to attach the vrDevice to
  93966. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93967. */
  93968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93969. /**
  93970. * Detaches the camera from the html element and disables VR
  93971. *
  93972. * @param element html element to detach from
  93973. */
  93974. detachControl(element: HTMLElement): void;
  93975. /**
  93976. * @returns the name of this class
  93977. */
  93978. getClassName(): string;
  93979. /**
  93980. * Calls resetPose on the vrDisplay
  93981. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93982. */
  93983. resetToCurrentRotation(): void;
  93984. /**
  93985. * @hidden
  93986. * Updates the rig cameras (left and right eye)
  93987. */
  93988. _updateRigCameras(): void;
  93989. private _workingVector;
  93990. private _oneVector;
  93991. private _workingMatrix;
  93992. private updateCacheCalled;
  93993. private _correctPositionIfNotTrackPosition;
  93994. /**
  93995. * @hidden
  93996. * Updates the cached values of the camera
  93997. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93998. */
  93999. _updateCache(ignoreParentClass?: boolean): void;
  94000. /**
  94001. * @hidden
  94002. * Get current device position in babylon world
  94003. */
  94004. _computeDevicePosition(): void;
  94005. /**
  94006. * Updates the current device position and rotation in the babylon world
  94007. */
  94008. update(): void;
  94009. /**
  94010. * @hidden
  94011. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  94012. * @returns an identity matrix
  94013. */
  94014. _getViewMatrix(): Matrix;
  94015. private _tmpMatrix;
  94016. /**
  94017. * This function is called by the two RIG cameras.
  94018. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  94019. * @hidden
  94020. */
  94021. _getWebVRViewMatrix(): Matrix;
  94022. /** @hidden */
  94023. _getWebVRProjectionMatrix(): Matrix;
  94024. private _onGamepadConnectedObserver;
  94025. private _onGamepadDisconnectedObserver;
  94026. private _updateCacheWhenTrackingDisabledObserver;
  94027. /**
  94028. * Initializes the controllers and their meshes
  94029. */
  94030. initControllers(): void;
  94031. }
  94032. }
  94033. declare module BABYLON {
  94034. /**
  94035. * Size options for a post process
  94036. */
  94037. export type PostProcessOptions = {
  94038. width: number;
  94039. height: number;
  94040. };
  94041. /**
  94042. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94043. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94044. */
  94045. export class PostProcess {
  94046. /** Name of the PostProcess. */
  94047. name: string;
  94048. /**
  94049. * Gets or sets the unique id of the post process
  94050. */
  94051. uniqueId: number;
  94052. /**
  94053. * Width of the texture to apply the post process on
  94054. */
  94055. width: number;
  94056. /**
  94057. * Height of the texture to apply the post process on
  94058. */
  94059. height: number;
  94060. /**
  94061. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94062. * @hidden
  94063. */
  94064. _outputTexture: Nullable<InternalTexture>;
  94065. /**
  94066. * Sampling mode used by the shader
  94067. * See https://doc.babylonjs.com/classes/3.1/texture
  94068. */
  94069. renderTargetSamplingMode: number;
  94070. /**
  94071. * Clear color to use when screen clearing
  94072. */
  94073. clearColor: Color4;
  94074. /**
  94075. * If the buffer needs to be cleared before applying the post process. (default: true)
  94076. * Should be set to false if shader will overwrite all previous pixels.
  94077. */
  94078. autoClear: boolean;
  94079. /**
  94080. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94081. */
  94082. alphaMode: number;
  94083. /**
  94084. * Sets the setAlphaBlendConstants of the babylon engine
  94085. */
  94086. alphaConstants: Color4;
  94087. /**
  94088. * Animations to be used for the post processing
  94089. */
  94090. animations: Animation[];
  94091. /**
  94092. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94093. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94094. */
  94095. enablePixelPerfectMode: boolean;
  94096. /**
  94097. * Force the postprocess to be applied without taking in account viewport
  94098. */
  94099. forceFullscreenViewport: boolean;
  94100. /**
  94101. * List of inspectable custom properties (used by the Inspector)
  94102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94103. */
  94104. inspectableCustomProperties: IInspectable[];
  94105. /**
  94106. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94107. *
  94108. * | Value | Type | Description |
  94109. * | ----- | ----------------------------------- | ----------- |
  94110. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94111. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94112. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94113. *
  94114. */
  94115. scaleMode: number;
  94116. /**
  94117. * Force textures to be a power of two (default: false)
  94118. */
  94119. alwaysForcePOT: boolean;
  94120. private _samples;
  94121. /**
  94122. * Number of sample textures (default: 1)
  94123. */
  94124. get samples(): number;
  94125. set samples(n: number);
  94126. /**
  94127. * Modify the scale of the post process to be the same as the viewport (default: false)
  94128. */
  94129. adaptScaleToCurrentViewport: boolean;
  94130. private _camera;
  94131. private _scene;
  94132. private _engine;
  94133. private _options;
  94134. private _reusable;
  94135. private _textureType;
  94136. private _textureFormat;
  94137. /**
  94138. * Smart array of input and output textures for the post process.
  94139. * @hidden
  94140. */
  94141. _textures: SmartArray<InternalTexture>;
  94142. /**
  94143. * The index in _textures that corresponds to the output texture.
  94144. * @hidden
  94145. */
  94146. _currentRenderTextureInd: number;
  94147. private _effect;
  94148. private _samplers;
  94149. private _fragmentUrl;
  94150. private _vertexUrl;
  94151. private _parameters;
  94152. private _scaleRatio;
  94153. protected _indexParameters: any;
  94154. private _shareOutputWithPostProcess;
  94155. private _texelSize;
  94156. private _forcedOutputTexture;
  94157. /**
  94158. * Returns the fragment url or shader name used in the post process.
  94159. * @returns the fragment url or name in the shader store.
  94160. */
  94161. getEffectName(): string;
  94162. /**
  94163. * An event triggered when the postprocess is activated.
  94164. */
  94165. onActivateObservable: Observable<Camera>;
  94166. private _onActivateObserver;
  94167. /**
  94168. * A function that is added to the onActivateObservable
  94169. */
  94170. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94171. /**
  94172. * An event triggered when the postprocess changes its size.
  94173. */
  94174. onSizeChangedObservable: Observable<PostProcess>;
  94175. private _onSizeChangedObserver;
  94176. /**
  94177. * A function that is added to the onSizeChangedObservable
  94178. */
  94179. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94180. /**
  94181. * An event triggered when the postprocess applies its effect.
  94182. */
  94183. onApplyObservable: Observable<Effect>;
  94184. private _onApplyObserver;
  94185. /**
  94186. * A function that is added to the onApplyObservable
  94187. */
  94188. set onApply(callback: (effect: Effect) => void);
  94189. /**
  94190. * An event triggered before rendering the postprocess
  94191. */
  94192. onBeforeRenderObservable: Observable<Effect>;
  94193. private _onBeforeRenderObserver;
  94194. /**
  94195. * A function that is added to the onBeforeRenderObservable
  94196. */
  94197. set onBeforeRender(callback: (effect: Effect) => void);
  94198. /**
  94199. * An event triggered after rendering the postprocess
  94200. */
  94201. onAfterRenderObservable: Observable<Effect>;
  94202. private _onAfterRenderObserver;
  94203. /**
  94204. * A function that is added to the onAfterRenderObservable
  94205. */
  94206. set onAfterRender(callback: (efect: Effect) => void);
  94207. /**
  94208. * 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
  94209. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94210. */
  94211. get inputTexture(): InternalTexture;
  94212. set inputTexture(value: InternalTexture);
  94213. /**
  94214. * Gets the camera which post process is applied to.
  94215. * @returns The camera the post process is applied to.
  94216. */
  94217. getCamera(): Camera;
  94218. /**
  94219. * Gets the texel size of the postprocess.
  94220. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94221. */
  94222. get texelSize(): Vector2;
  94223. /**
  94224. * Creates a new instance PostProcess
  94225. * @param name The name of the PostProcess.
  94226. * @param fragmentUrl The url of the fragment shader to be used.
  94227. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94228. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94229. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94230. * @param camera The camera to apply the render pass to.
  94231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94232. * @param engine The engine which the post process will be applied. (default: current engine)
  94233. * @param reusable If the post process can be reused on the same frame. (default: false)
  94234. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94235. * @param textureType Type of textures used when performing the post process. (default: 0)
  94236. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94237. * @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
  94238. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94239. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94240. */
  94241. constructor(
  94242. /** Name of the PostProcess. */
  94243. 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);
  94244. /**
  94245. * Gets a string idenfifying the name of the class
  94246. * @returns "PostProcess" string
  94247. */
  94248. getClassName(): string;
  94249. /**
  94250. * Gets the engine which this post process belongs to.
  94251. * @returns The engine the post process was enabled with.
  94252. */
  94253. getEngine(): Engine;
  94254. /**
  94255. * The effect that is created when initializing the post process.
  94256. * @returns The created effect corresponding the the postprocess.
  94257. */
  94258. getEffect(): Effect;
  94259. /**
  94260. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94261. * @param postProcess The post process to share the output with.
  94262. * @returns This post process.
  94263. */
  94264. shareOutputWith(postProcess: PostProcess): PostProcess;
  94265. /**
  94266. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94267. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94268. */
  94269. useOwnOutput(): void;
  94270. /**
  94271. * Updates the effect with the current post process compile time values and recompiles the shader.
  94272. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94273. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94274. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94275. * @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
  94276. * @param onCompiled Called when the shader has been compiled.
  94277. * @param onError Called if there is an error when compiling a shader.
  94278. */
  94279. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94280. /**
  94281. * The post process is reusable if it can be used multiple times within one frame.
  94282. * @returns If the post process is reusable
  94283. */
  94284. isReusable(): boolean;
  94285. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94286. markTextureDirty(): void;
  94287. /**
  94288. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94289. * 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.
  94290. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94291. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94292. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94293. * @returns The target texture that was bound to be written to.
  94294. */
  94295. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94296. /**
  94297. * If the post process is supported.
  94298. */
  94299. get isSupported(): boolean;
  94300. /**
  94301. * The aspect ratio of the output texture.
  94302. */
  94303. get aspectRatio(): number;
  94304. /**
  94305. * Get a value indicating if the post-process is ready to be used
  94306. * @returns true if the post-process is ready (shader is compiled)
  94307. */
  94308. isReady(): boolean;
  94309. /**
  94310. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94311. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94312. */
  94313. apply(): Nullable<Effect>;
  94314. private _disposeTextures;
  94315. /**
  94316. * Disposes the post process.
  94317. * @param camera The camera to dispose the post process on.
  94318. */
  94319. dispose(camera?: Camera): void;
  94320. }
  94321. }
  94322. declare module BABYLON {
  94323. /** @hidden */
  94324. export var kernelBlurVaryingDeclaration: {
  94325. name: string;
  94326. shader: string;
  94327. };
  94328. }
  94329. declare module BABYLON {
  94330. /** @hidden */
  94331. export var kernelBlurFragment: {
  94332. name: string;
  94333. shader: string;
  94334. };
  94335. }
  94336. declare module BABYLON {
  94337. /** @hidden */
  94338. export var kernelBlurFragment2: {
  94339. name: string;
  94340. shader: string;
  94341. };
  94342. }
  94343. declare module BABYLON {
  94344. /** @hidden */
  94345. export var kernelBlurPixelShader: {
  94346. name: string;
  94347. shader: string;
  94348. };
  94349. }
  94350. declare module BABYLON {
  94351. /** @hidden */
  94352. export var kernelBlurVertex: {
  94353. name: string;
  94354. shader: string;
  94355. };
  94356. }
  94357. declare module BABYLON {
  94358. /** @hidden */
  94359. export var kernelBlurVertexShader: {
  94360. name: string;
  94361. shader: string;
  94362. };
  94363. }
  94364. declare module BABYLON {
  94365. /**
  94366. * The Blur Post Process which blurs an image based on a kernel and direction.
  94367. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94368. */
  94369. export class BlurPostProcess extends PostProcess {
  94370. /** The direction in which to blur the image. */
  94371. direction: Vector2;
  94372. private blockCompilation;
  94373. protected _kernel: number;
  94374. protected _idealKernel: number;
  94375. protected _packedFloat: boolean;
  94376. private _staticDefines;
  94377. /**
  94378. * Sets the length in pixels of the blur sample region
  94379. */
  94380. set kernel(v: number);
  94381. /**
  94382. * Gets the length in pixels of the blur sample region
  94383. */
  94384. get kernel(): number;
  94385. /**
  94386. * Sets wether or not the blur needs to unpack/repack floats
  94387. */
  94388. set packedFloat(v: boolean);
  94389. /**
  94390. * Gets wether or not the blur is unpacking/repacking floats
  94391. */
  94392. get packedFloat(): boolean;
  94393. /**
  94394. * Creates a new instance BlurPostProcess
  94395. * @param name The name of the effect.
  94396. * @param direction The direction in which to blur the image.
  94397. * @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.
  94398. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94399. * @param camera The camera to apply the render pass to.
  94400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94401. * @param engine The engine which the post process will be applied. (default: current engine)
  94402. * @param reusable If the post process can be reused on the same frame. (default: false)
  94403. * @param textureType Type of textures used when performing the post process. (default: 0)
  94404. * @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)
  94405. */
  94406. constructor(name: string,
  94407. /** The direction in which to blur the image. */
  94408. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94409. /**
  94410. * Updates the effect with the current post process compile time values and recompiles the shader.
  94411. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94412. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94413. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94414. * @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
  94415. * @param onCompiled Called when the shader has been compiled.
  94416. * @param onError Called if there is an error when compiling a shader.
  94417. */
  94418. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94419. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94420. /**
  94421. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94422. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94423. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94424. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94425. * The gaps between physical kernels are compensated for in the weighting of the samples
  94426. * @param idealKernel Ideal blur kernel.
  94427. * @return Nearest best kernel.
  94428. */
  94429. protected _nearestBestKernel(idealKernel: number): number;
  94430. /**
  94431. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94432. * @param x The point on the Gaussian distribution to sample.
  94433. * @return the value of the Gaussian function at x.
  94434. */
  94435. protected _gaussianWeight(x: number): number;
  94436. /**
  94437. * Generates a string that can be used as a floating point number in GLSL.
  94438. * @param x Value to print.
  94439. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94440. * @return GLSL float string.
  94441. */
  94442. protected _glslFloat(x: number, decimalFigures?: number): string;
  94443. }
  94444. }
  94445. declare module BABYLON {
  94446. /**
  94447. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94448. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94449. * You can then easily use it as a reflectionTexture on a flat surface.
  94450. * In case the surface is not a plane, please consider relying on reflection probes.
  94451. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94452. */
  94453. export class MirrorTexture extends RenderTargetTexture {
  94454. private scene;
  94455. /**
  94456. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94457. * 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.
  94458. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94459. */
  94460. mirrorPlane: Plane;
  94461. /**
  94462. * Define the blur ratio used to blur the reflection if needed.
  94463. */
  94464. set blurRatio(value: number);
  94465. get blurRatio(): number;
  94466. /**
  94467. * Define the adaptive blur kernel used to blur the reflection if needed.
  94468. * This will autocompute the closest best match for the `blurKernel`
  94469. */
  94470. set adaptiveBlurKernel(value: number);
  94471. /**
  94472. * Define the blur kernel used to blur the reflection if needed.
  94473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94474. */
  94475. set blurKernel(value: number);
  94476. /**
  94477. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94478. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94479. */
  94480. set blurKernelX(value: number);
  94481. get blurKernelX(): number;
  94482. /**
  94483. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94485. */
  94486. set blurKernelY(value: number);
  94487. get blurKernelY(): number;
  94488. private _autoComputeBlurKernel;
  94489. protected _onRatioRescale(): void;
  94490. private _updateGammaSpace;
  94491. private _imageProcessingConfigChangeObserver;
  94492. private _transformMatrix;
  94493. private _mirrorMatrix;
  94494. private _savedViewMatrix;
  94495. private _blurX;
  94496. private _blurY;
  94497. private _adaptiveBlurKernel;
  94498. private _blurKernelX;
  94499. private _blurKernelY;
  94500. private _blurRatio;
  94501. /**
  94502. * Instantiates a Mirror Texture.
  94503. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94504. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94505. * You can then easily use it as a reflectionTexture on a flat surface.
  94506. * In case the surface is not a plane, please consider relying on reflection probes.
  94507. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94508. * @param name
  94509. * @param size
  94510. * @param scene
  94511. * @param generateMipMaps
  94512. * @param type
  94513. * @param samplingMode
  94514. * @param generateDepthBuffer
  94515. */
  94516. constructor(name: string, size: number | {
  94517. width: number;
  94518. height: number;
  94519. } | {
  94520. ratio: number;
  94521. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94522. private _preparePostProcesses;
  94523. /**
  94524. * Clone the mirror texture.
  94525. * @returns the cloned texture
  94526. */
  94527. clone(): MirrorTexture;
  94528. /**
  94529. * Serialize the texture to a JSON representation you could use in Parse later on
  94530. * @returns the serialized JSON representation
  94531. */
  94532. serialize(): any;
  94533. /**
  94534. * Dispose the texture and release its associated resources.
  94535. */
  94536. dispose(): void;
  94537. }
  94538. }
  94539. declare module BABYLON {
  94540. /**
  94541. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94542. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94543. */
  94544. export class Texture extends BaseTexture {
  94545. /**
  94546. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94547. */
  94548. static SerializeBuffers: boolean;
  94549. /** @hidden */
  94550. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94551. /** @hidden */
  94552. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94553. /** @hidden */
  94554. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94555. /** nearest is mag = nearest and min = nearest and mip = linear */
  94556. static readonly NEAREST_SAMPLINGMODE: number;
  94557. /** nearest is mag = nearest and min = nearest and mip = linear */
  94558. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94560. static readonly BILINEAR_SAMPLINGMODE: number;
  94561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94562. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94563. /** Trilinear is mag = linear and min = linear and mip = linear */
  94564. static readonly TRILINEAR_SAMPLINGMODE: number;
  94565. /** Trilinear is mag = linear and min = linear and mip = linear */
  94566. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94567. /** mag = nearest and min = nearest and mip = nearest */
  94568. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94569. /** mag = nearest and min = linear and mip = nearest */
  94570. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94571. /** mag = nearest and min = linear and mip = linear */
  94572. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94573. /** mag = nearest and min = linear and mip = none */
  94574. static readonly NEAREST_LINEAR: number;
  94575. /** mag = nearest and min = nearest and mip = none */
  94576. static readonly NEAREST_NEAREST: number;
  94577. /** mag = linear and min = nearest and mip = nearest */
  94578. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94579. /** mag = linear and min = nearest and mip = linear */
  94580. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94581. /** mag = linear and min = linear and mip = none */
  94582. static readonly LINEAR_LINEAR: number;
  94583. /** mag = linear and min = nearest and mip = none */
  94584. static readonly LINEAR_NEAREST: number;
  94585. /** Explicit coordinates mode */
  94586. static readonly EXPLICIT_MODE: number;
  94587. /** Spherical coordinates mode */
  94588. static readonly SPHERICAL_MODE: number;
  94589. /** Planar coordinates mode */
  94590. static readonly PLANAR_MODE: number;
  94591. /** Cubic coordinates mode */
  94592. static readonly CUBIC_MODE: number;
  94593. /** Projection coordinates mode */
  94594. static readonly PROJECTION_MODE: number;
  94595. /** Inverse Cubic coordinates mode */
  94596. static readonly SKYBOX_MODE: number;
  94597. /** Inverse Cubic coordinates mode */
  94598. static readonly INVCUBIC_MODE: number;
  94599. /** Equirectangular coordinates mode */
  94600. static readonly EQUIRECTANGULAR_MODE: number;
  94601. /** Equirectangular Fixed coordinates mode */
  94602. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94603. /** Equirectangular Fixed Mirrored coordinates mode */
  94604. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94605. /** Texture is not repeating outside of 0..1 UVs */
  94606. static readonly CLAMP_ADDRESSMODE: number;
  94607. /** Texture is repeating outside of 0..1 UVs */
  94608. static readonly WRAP_ADDRESSMODE: number;
  94609. /** Texture is repeating and mirrored */
  94610. static readonly MIRROR_ADDRESSMODE: number;
  94611. /**
  94612. * 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
  94613. */
  94614. static UseSerializedUrlIfAny: boolean;
  94615. /**
  94616. * Define the url of the texture.
  94617. */
  94618. url: Nullable<string>;
  94619. /**
  94620. * Define an offset on the texture to offset the u coordinates of the UVs
  94621. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94622. */
  94623. uOffset: number;
  94624. /**
  94625. * Define an offset on the texture to offset the v coordinates of the UVs
  94626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94627. */
  94628. vOffset: number;
  94629. /**
  94630. * Define an offset on the texture to scale the u coordinates of the UVs
  94631. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94632. */
  94633. uScale: number;
  94634. /**
  94635. * Define an offset on the texture to scale the v coordinates of the UVs
  94636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94637. */
  94638. vScale: number;
  94639. /**
  94640. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94641. * @see http://doc.babylonjs.com/how_to/more_materials
  94642. */
  94643. uAng: number;
  94644. /**
  94645. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94646. * @see http://doc.babylonjs.com/how_to/more_materials
  94647. */
  94648. vAng: number;
  94649. /**
  94650. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94651. * @see http://doc.babylonjs.com/how_to/more_materials
  94652. */
  94653. wAng: number;
  94654. /**
  94655. * Defines the center of rotation (U)
  94656. */
  94657. uRotationCenter: number;
  94658. /**
  94659. * Defines the center of rotation (V)
  94660. */
  94661. vRotationCenter: number;
  94662. /**
  94663. * Defines the center of rotation (W)
  94664. */
  94665. wRotationCenter: number;
  94666. /**
  94667. * Are mip maps generated for this texture or not.
  94668. */
  94669. get noMipmap(): boolean;
  94670. /**
  94671. * List of inspectable custom properties (used by the Inspector)
  94672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94673. */
  94674. inspectableCustomProperties: Nullable<IInspectable[]>;
  94675. private _noMipmap;
  94676. /** @hidden */
  94677. _invertY: boolean;
  94678. private _rowGenerationMatrix;
  94679. private _cachedTextureMatrix;
  94680. private _projectionModeMatrix;
  94681. private _t0;
  94682. private _t1;
  94683. private _t2;
  94684. private _cachedUOffset;
  94685. private _cachedVOffset;
  94686. private _cachedUScale;
  94687. private _cachedVScale;
  94688. private _cachedUAng;
  94689. private _cachedVAng;
  94690. private _cachedWAng;
  94691. private _cachedProjectionMatrixId;
  94692. private _cachedCoordinatesMode;
  94693. /** @hidden */
  94694. protected _initialSamplingMode: number;
  94695. /** @hidden */
  94696. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94697. private _deleteBuffer;
  94698. protected _format: Nullable<number>;
  94699. private _delayedOnLoad;
  94700. private _delayedOnError;
  94701. private _mimeType?;
  94702. /**
  94703. * Observable triggered once the texture has been loaded.
  94704. */
  94705. onLoadObservable: Observable<Texture>;
  94706. protected _isBlocking: boolean;
  94707. /**
  94708. * Is the texture preventing material to render while loading.
  94709. * If false, a default texture will be used instead of the loading one during the preparation step.
  94710. */
  94711. set isBlocking(value: boolean);
  94712. get isBlocking(): boolean;
  94713. /**
  94714. * Get the current sampling mode associated with the texture.
  94715. */
  94716. get samplingMode(): number;
  94717. /**
  94718. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94719. */
  94720. get invertY(): boolean;
  94721. /**
  94722. * Instantiates a new texture.
  94723. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94724. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94725. * @param url defines the url of the picture to load as a texture
  94726. * @param scene defines the scene or engine the texture will belong to
  94727. * @param noMipmap defines if the texture will require mip maps or not
  94728. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94729. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94730. * @param onLoad defines a callback triggered when the texture has been loaded
  94731. * @param onError defines a callback triggered when an error occurred during the loading session
  94732. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94733. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94734. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94735. * @param mimeType defines an optional mime type information
  94736. */
  94737. 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);
  94738. /**
  94739. * Update the url (and optional buffer) of this texture if url was null during construction.
  94740. * @param url the url of the texture
  94741. * @param buffer the buffer of the texture (defaults to null)
  94742. * @param onLoad callback called when the texture is loaded (defaults to null)
  94743. */
  94744. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94745. /**
  94746. * Finish the loading sequence of a texture flagged as delayed load.
  94747. * @hidden
  94748. */
  94749. delayLoad(): void;
  94750. private _prepareRowForTextureGeneration;
  94751. /**
  94752. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94753. * @returns the transform matrix of the texture.
  94754. */
  94755. getTextureMatrix(uBase?: number): Matrix;
  94756. /**
  94757. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94758. * @returns The reflection texture transform
  94759. */
  94760. getReflectionTextureMatrix(): Matrix;
  94761. /**
  94762. * Clones the texture.
  94763. * @returns the cloned texture
  94764. */
  94765. clone(): Texture;
  94766. /**
  94767. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94768. * @returns The JSON representation of the texture
  94769. */
  94770. serialize(): any;
  94771. /**
  94772. * Get the current class name of the texture useful for serialization or dynamic coding.
  94773. * @returns "Texture"
  94774. */
  94775. getClassName(): string;
  94776. /**
  94777. * Dispose the texture and release its associated resources.
  94778. */
  94779. dispose(): void;
  94780. /**
  94781. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94782. * @param parsedTexture Define the JSON representation of the texture
  94783. * @param scene Define the scene the parsed texture should be instantiated in
  94784. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94785. * @returns The parsed texture if successful
  94786. */
  94787. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94788. /**
  94789. * Creates a texture from its base 64 representation.
  94790. * @param data Define the base64 payload without the data: prefix
  94791. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94792. * @param scene Define the scene the texture should belong to
  94793. * @param noMipmap Forces the texture to not create mip map information if true
  94794. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94795. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94796. * @param onLoad define a callback triggered when the texture has been loaded
  94797. * @param onError define a callback triggered when an error occurred during the loading session
  94798. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94799. * @returns the created texture
  94800. */
  94801. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94802. /**
  94803. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94804. * @param data Define the base64 payload without the data: prefix
  94805. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94806. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94807. * @param scene Define the scene the texture should belong to
  94808. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94809. * @param noMipmap Forces the texture to not create mip map information if true
  94810. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94811. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94812. * @param onLoad define a callback triggered when the texture has been loaded
  94813. * @param onError define a callback triggered when an error occurred during the loading session
  94814. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94815. * @returns the created texture
  94816. */
  94817. 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;
  94818. }
  94819. }
  94820. declare module BABYLON {
  94821. /**
  94822. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94823. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94824. */
  94825. export class PostProcessManager {
  94826. private _scene;
  94827. private _indexBuffer;
  94828. private _vertexBuffers;
  94829. /**
  94830. * Creates a new instance PostProcess
  94831. * @param scene The scene that the post process is associated with.
  94832. */
  94833. constructor(scene: Scene);
  94834. private _prepareBuffers;
  94835. private _buildIndexBuffer;
  94836. /**
  94837. * Rebuilds the vertex buffers of the manager.
  94838. * @hidden
  94839. */
  94840. _rebuild(): void;
  94841. /**
  94842. * Prepares a frame to be run through a post process.
  94843. * @param sourceTexture The input texture to the post procesess. (default: null)
  94844. * @param postProcesses An array of post processes to be run. (default: null)
  94845. * @returns True if the post processes were able to be run.
  94846. * @hidden
  94847. */
  94848. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94849. /**
  94850. * Manually render a set of post processes to a texture.
  94851. * @param postProcesses An array of post processes to be run.
  94852. * @param targetTexture The target texture to render to.
  94853. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94854. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94855. * @param lodLevel defines which lod of the texture to render to
  94856. */
  94857. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94858. /**
  94859. * Finalize the result of the output of the postprocesses.
  94860. * @param doNotPresent If true the result will not be displayed to the screen.
  94861. * @param targetTexture The target texture to render to.
  94862. * @param faceIndex The index of the face to bind the target texture to.
  94863. * @param postProcesses The array of post processes to render.
  94864. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94865. * @hidden
  94866. */
  94867. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94868. /**
  94869. * Disposes of the post process manager.
  94870. */
  94871. dispose(): void;
  94872. }
  94873. }
  94874. declare module BABYLON {
  94875. /**
  94876. * This Helps creating a texture that will be created from a camera in your scene.
  94877. * It is basically a dynamic texture that could be used to create special effects for instance.
  94878. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94879. */
  94880. export class RenderTargetTexture extends Texture {
  94881. isCube: boolean;
  94882. /**
  94883. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94884. */
  94885. static readonly REFRESHRATE_RENDER_ONCE: number;
  94886. /**
  94887. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94888. */
  94889. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94890. /**
  94891. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94892. * the central point of your effect and can save a lot of performances.
  94893. */
  94894. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94895. /**
  94896. * Use this predicate to dynamically define the list of mesh you want to render.
  94897. * If set, the renderList property will be overwritten.
  94898. */
  94899. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94900. private _renderList;
  94901. /**
  94902. * Use this list to define the list of mesh you want to render.
  94903. */
  94904. get renderList(): Nullable<Array<AbstractMesh>>;
  94905. set renderList(value: Nullable<Array<AbstractMesh>>);
  94906. /**
  94907. * Use this function to overload the renderList array at rendering time.
  94908. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94909. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94910. * the cube (if the RTT is a cube, else layerOrFace=0).
  94911. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94912. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94913. * hold dummy elements!
  94914. */
  94915. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94916. private _hookArray;
  94917. /**
  94918. * Define if particles should be rendered in your texture.
  94919. */
  94920. renderParticles: boolean;
  94921. /**
  94922. * Define if sprites should be rendered in your texture.
  94923. */
  94924. renderSprites: boolean;
  94925. /**
  94926. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94927. */
  94928. coordinatesMode: number;
  94929. /**
  94930. * Define the camera used to render the texture.
  94931. */
  94932. activeCamera: Nullable<Camera>;
  94933. /**
  94934. * Override the mesh isReady function with your own one.
  94935. */
  94936. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94937. /**
  94938. * Override the render function of the texture with your own one.
  94939. */
  94940. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94941. /**
  94942. * Define if camera post processes should be use while rendering the texture.
  94943. */
  94944. useCameraPostProcesses: boolean;
  94945. /**
  94946. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94947. */
  94948. ignoreCameraViewport: boolean;
  94949. private _postProcessManager;
  94950. private _postProcesses;
  94951. private _resizeObserver;
  94952. /**
  94953. * An event triggered when the texture is unbind.
  94954. */
  94955. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94956. /**
  94957. * An event triggered when the texture is unbind.
  94958. */
  94959. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94960. private _onAfterUnbindObserver;
  94961. /**
  94962. * Set a after unbind callback in the texture.
  94963. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94964. */
  94965. set onAfterUnbind(callback: () => void);
  94966. /**
  94967. * An event triggered before rendering the texture
  94968. */
  94969. onBeforeRenderObservable: Observable<number>;
  94970. private _onBeforeRenderObserver;
  94971. /**
  94972. * Set a before render callback in the texture.
  94973. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94974. */
  94975. set onBeforeRender(callback: (faceIndex: number) => void);
  94976. /**
  94977. * An event triggered after rendering the texture
  94978. */
  94979. onAfterRenderObservable: Observable<number>;
  94980. private _onAfterRenderObserver;
  94981. /**
  94982. * Set a after render callback in the texture.
  94983. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94984. */
  94985. set onAfterRender(callback: (faceIndex: number) => void);
  94986. /**
  94987. * An event triggered after the texture clear
  94988. */
  94989. onClearObservable: Observable<Engine>;
  94990. private _onClearObserver;
  94991. /**
  94992. * Set a clear callback in the texture.
  94993. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94994. */
  94995. set onClear(callback: (Engine: Engine) => void);
  94996. /**
  94997. * An event triggered when the texture is resized.
  94998. */
  94999. onResizeObservable: Observable<RenderTargetTexture>;
  95000. /**
  95001. * Define the clear color of the Render Target if it should be different from the scene.
  95002. */
  95003. clearColor: Color4;
  95004. protected _size: number | {
  95005. width: number;
  95006. height: number;
  95007. layers?: number;
  95008. };
  95009. protected _initialSizeParameter: number | {
  95010. width: number;
  95011. height: number;
  95012. } | {
  95013. ratio: number;
  95014. };
  95015. protected _sizeRatio: Nullable<number>;
  95016. /** @hidden */
  95017. _generateMipMaps: boolean;
  95018. protected _renderingManager: RenderingManager;
  95019. /** @hidden */
  95020. _waitingRenderList: string[];
  95021. protected _doNotChangeAspectRatio: boolean;
  95022. protected _currentRefreshId: number;
  95023. protected _refreshRate: number;
  95024. protected _textureMatrix: Matrix;
  95025. protected _samples: number;
  95026. protected _renderTargetOptions: RenderTargetCreationOptions;
  95027. /**
  95028. * Gets render target creation options that were used.
  95029. */
  95030. get renderTargetOptions(): RenderTargetCreationOptions;
  95031. protected _engine: Engine;
  95032. protected _onRatioRescale(): void;
  95033. /**
  95034. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95035. * It must define where the camera used to render the texture is set
  95036. */
  95037. boundingBoxPosition: Vector3;
  95038. private _boundingBoxSize;
  95039. /**
  95040. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95041. * When defined, the cubemap will switch to local mode
  95042. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95043. * @example https://www.babylonjs-playground.com/#RNASML
  95044. */
  95045. set boundingBoxSize(value: Vector3);
  95046. get boundingBoxSize(): Vector3;
  95047. /**
  95048. * In case the RTT has been created with a depth texture, get the associated
  95049. * depth texture.
  95050. * Otherwise, return null.
  95051. */
  95052. get depthStencilTexture(): Nullable<InternalTexture>;
  95053. /**
  95054. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95055. * or used a shadow, depth texture...
  95056. * @param name The friendly name of the texture
  95057. * @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)
  95058. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95059. * @param generateMipMaps True if mip maps need to be generated after render.
  95060. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95061. * @param type The type of the buffer in the RTT (int, half float, float...)
  95062. * @param isCube True if a cube texture needs to be created
  95063. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95064. * @param generateDepthBuffer True to generate a depth buffer
  95065. * @param generateStencilBuffer True to generate a stencil buffer
  95066. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95067. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95068. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95069. */
  95070. constructor(name: string, size: number | {
  95071. width: number;
  95072. height: number;
  95073. layers?: number;
  95074. } | {
  95075. ratio: number;
  95076. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95077. /**
  95078. * Creates a depth stencil texture.
  95079. * This is only available in WebGL 2 or with the depth texture extension available.
  95080. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95081. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95082. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95083. */
  95084. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95085. private _processSizeParameter;
  95086. /**
  95087. * Define the number of samples to use in case of MSAA.
  95088. * It defaults to one meaning no MSAA has been enabled.
  95089. */
  95090. get samples(): number;
  95091. set samples(value: number);
  95092. /**
  95093. * Resets the refresh counter of the texture and start bak from scratch.
  95094. * Could be useful to regenerate the texture if it is setup to render only once.
  95095. */
  95096. resetRefreshCounter(): void;
  95097. /**
  95098. * Define the refresh rate of the texture or the rendering frequency.
  95099. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95100. */
  95101. get refreshRate(): number;
  95102. set refreshRate(value: number);
  95103. /**
  95104. * Adds a post process to the render target rendering passes.
  95105. * @param postProcess define the post process to add
  95106. */
  95107. addPostProcess(postProcess: PostProcess): void;
  95108. /**
  95109. * Clear all the post processes attached to the render target
  95110. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95111. */
  95112. clearPostProcesses(dispose?: boolean): void;
  95113. /**
  95114. * Remove one of the post process from the list of attached post processes to the texture
  95115. * @param postProcess define the post process to remove from the list
  95116. */
  95117. removePostProcess(postProcess: PostProcess): void;
  95118. /** @hidden */
  95119. _shouldRender(): boolean;
  95120. /**
  95121. * Gets the actual render size of the texture.
  95122. * @returns the width of the render size
  95123. */
  95124. getRenderSize(): number;
  95125. /**
  95126. * Gets the actual render width of the texture.
  95127. * @returns the width of the render size
  95128. */
  95129. getRenderWidth(): number;
  95130. /**
  95131. * Gets the actual render height of the texture.
  95132. * @returns the height of the render size
  95133. */
  95134. getRenderHeight(): number;
  95135. /**
  95136. * Gets the actual number of layers of the texture.
  95137. * @returns the number of layers
  95138. */
  95139. getRenderLayers(): number;
  95140. /**
  95141. * Get if the texture can be rescaled or not.
  95142. */
  95143. get canRescale(): boolean;
  95144. /**
  95145. * Resize the texture using a ratio.
  95146. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95147. */
  95148. scale(ratio: number): void;
  95149. /**
  95150. * Get the texture reflection matrix used to rotate/transform the reflection.
  95151. * @returns the reflection matrix
  95152. */
  95153. getReflectionTextureMatrix(): Matrix;
  95154. /**
  95155. * Resize the texture to a new desired size.
  95156. * Be carrefull as it will recreate all the data in the new texture.
  95157. * @param size Define the new size. It can be:
  95158. * - a number for squared texture,
  95159. * - an object containing { width: number, height: number }
  95160. * - or an object containing a ratio { ratio: number }
  95161. */
  95162. resize(size: number | {
  95163. width: number;
  95164. height: number;
  95165. } | {
  95166. ratio: number;
  95167. }): void;
  95168. private _defaultRenderListPrepared;
  95169. /**
  95170. * Renders all the objects from the render list into the texture.
  95171. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95172. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95173. */
  95174. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95175. private _bestReflectionRenderTargetDimension;
  95176. private _prepareRenderingManager;
  95177. /**
  95178. * @hidden
  95179. * @param faceIndex face index to bind to if this is a cubetexture
  95180. * @param layer defines the index of the texture to bind in the array
  95181. */
  95182. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95183. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95184. private renderToTarget;
  95185. /**
  95186. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95187. * This allowed control for front to back rendering or reversly depending of the special needs.
  95188. *
  95189. * @param renderingGroupId The rendering group id corresponding to its index
  95190. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95191. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95192. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95193. */
  95194. 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;
  95195. /**
  95196. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95197. *
  95198. * @param renderingGroupId The rendering group id corresponding to its index
  95199. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95200. */
  95201. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95202. /**
  95203. * Clones the texture.
  95204. * @returns the cloned texture
  95205. */
  95206. clone(): RenderTargetTexture;
  95207. /**
  95208. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95209. * @returns The JSON representation of the texture
  95210. */
  95211. serialize(): any;
  95212. /**
  95213. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95214. */
  95215. disposeFramebufferObjects(): void;
  95216. /**
  95217. * Dispose the texture and release its associated resources.
  95218. */
  95219. dispose(): void;
  95220. /** @hidden */
  95221. _rebuild(): void;
  95222. /**
  95223. * Clear the info related to rendering groups preventing retention point in material dispose.
  95224. */
  95225. freeRenderingGroups(): void;
  95226. /**
  95227. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95228. * @returns the view count
  95229. */
  95230. getViewCount(): number;
  95231. }
  95232. }
  95233. declare module BABYLON {
  95234. /**
  95235. * Options for compiling materials.
  95236. */
  95237. export interface IMaterialCompilationOptions {
  95238. /**
  95239. * Defines whether clip planes are enabled.
  95240. */
  95241. clipPlane: boolean;
  95242. /**
  95243. * Defines whether instances are enabled.
  95244. */
  95245. useInstances: boolean;
  95246. }
  95247. /**
  95248. * Base class for the main features of a material in Babylon.js
  95249. */
  95250. export class Material implements IAnimatable {
  95251. /**
  95252. * Returns the triangle fill mode
  95253. */
  95254. static readonly TriangleFillMode: number;
  95255. /**
  95256. * Returns the wireframe mode
  95257. */
  95258. static readonly WireFrameFillMode: number;
  95259. /**
  95260. * Returns the point fill mode
  95261. */
  95262. static readonly PointFillMode: number;
  95263. /**
  95264. * Returns the point list draw mode
  95265. */
  95266. static readonly PointListDrawMode: number;
  95267. /**
  95268. * Returns the line list draw mode
  95269. */
  95270. static readonly LineListDrawMode: number;
  95271. /**
  95272. * Returns the line loop draw mode
  95273. */
  95274. static readonly LineLoopDrawMode: number;
  95275. /**
  95276. * Returns the line strip draw mode
  95277. */
  95278. static readonly LineStripDrawMode: number;
  95279. /**
  95280. * Returns the triangle strip draw mode
  95281. */
  95282. static readonly TriangleStripDrawMode: number;
  95283. /**
  95284. * Returns the triangle fan draw mode
  95285. */
  95286. static readonly TriangleFanDrawMode: number;
  95287. /**
  95288. * Stores the clock-wise side orientation
  95289. */
  95290. static readonly ClockWiseSideOrientation: number;
  95291. /**
  95292. * Stores the counter clock-wise side orientation
  95293. */
  95294. static readonly CounterClockWiseSideOrientation: number;
  95295. /**
  95296. * The dirty texture flag value
  95297. */
  95298. static readonly TextureDirtyFlag: number;
  95299. /**
  95300. * The dirty light flag value
  95301. */
  95302. static readonly LightDirtyFlag: number;
  95303. /**
  95304. * The dirty fresnel flag value
  95305. */
  95306. static readonly FresnelDirtyFlag: number;
  95307. /**
  95308. * The dirty attribute flag value
  95309. */
  95310. static readonly AttributesDirtyFlag: number;
  95311. /**
  95312. * The dirty misc flag value
  95313. */
  95314. static readonly MiscDirtyFlag: number;
  95315. /**
  95316. * The all dirty flag value
  95317. */
  95318. static readonly AllDirtyFlag: number;
  95319. /**
  95320. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95321. */
  95322. static readonly MATERIAL_OPAQUE: number;
  95323. /**
  95324. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95325. */
  95326. static readonly MATERIAL_ALPHATEST: number;
  95327. /**
  95328. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95329. */
  95330. static readonly MATERIAL_ALPHABLEND: number;
  95331. /**
  95332. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95333. * They are also discarded below the alpha cutoff threshold to improve performances.
  95334. */
  95335. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95336. /**
  95337. * The ID of the material
  95338. */
  95339. id: string;
  95340. /**
  95341. * Gets or sets the unique id of the material
  95342. */
  95343. uniqueId: number;
  95344. /**
  95345. * The name of the material
  95346. */
  95347. name: string;
  95348. /**
  95349. * Gets or sets user defined metadata
  95350. */
  95351. metadata: any;
  95352. /**
  95353. * For internal use only. Please do not use.
  95354. */
  95355. reservedDataStore: any;
  95356. /**
  95357. * Specifies if the ready state should be checked on each call
  95358. */
  95359. checkReadyOnEveryCall: boolean;
  95360. /**
  95361. * Specifies if the ready state should be checked once
  95362. */
  95363. checkReadyOnlyOnce: boolean;
  95364. /**
  95365. * The state of the material
  95366. */
  95367. state: string;
  95368. /**
  95369. * The alpha value of the material
  95370. */
  95371. protected _alpha: number;
  95372. /**
  95373. * List of inspectable custom properties (used by the Inspector)
  95374. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95375. */
  95376. inspectableCustomProperties: IInspectable[];
  95377. /**
  95378. * Sets the alpha value of the material
  95379. */
  95380. set alpha(value: number);
  95381. /**
  95382. * Gets the alpha value of the material
  95383. */
  95384. get alpha(): number;
  95385. /**
  95386. * Specifies if back face culling is enabled
  95387. */
  95388. protected _backFaceCulling: boolean;
  95389. /**
  95390. * Sets the back-face culling state
  95391. */
  95392. set backFaceCulling(value: boolean);
  95393. /**
  95394. * Gets the back-face culling state
  95395. */
  95396. get backFaceCulling(): boolean;
  95397. /**
  95398. * Stores the value for side orientation
  95399. */
  95400. sideOrientation: number;
  95401. /**
  95402. * Callback triggered when the material is compiled
  95403. */
  95404. onCompiled: Nullable<(effect: Effect) => void>;
  95405. /**
  95406. * Callback triggered when an error occurs
  95407. */
  95408. onError: Nullable<(effect: Effect, errors: string) => void>;
  95409. /**
  95410. * Callback triggered to get the render target textures
  95411. */
  95412. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95413. /**
  95414. * Gets a boolean indicating that current material needs to register RTT
  95415. */
  95416. get hasRenderTargetTextures(): boolean;
  95417. /**
  95418. * Specifies if the material should be serialized
  95419. */
  95420. doNotSerialize: boolean;
  95421. /**
  95422. * @hidden
  95423. */
  95424. _storeEffectOnSubMeshes: boolean;
  95425. /**
  95426. * Stores the animations for the material
  95427. */
  95428. animations: Nullable<Array<Animation>>;
  95429. /**
  95430. * An event triggered when the material is disposed
  95431. */
  95432. onDisposeObservable: Observable<Material>;
  95433. /**
  95434. * An observer which watches for dispose events
  95435. */
  95436. private _onDisposeObserver;
  95437. private _onUnBindObservable;
  95438. /**
  95439. * Called during a dispose event
  95440. */
  95441. set onDispose(callback: () => void);
  95442. private _onBindObservable;
  95443. /**
  95444. * An event triggered when the material is bound
  95445. */
  95446. get onBindObservable(): Observable<AbstractMesh>;
  95447. /**
  95448. * An observer which watches for bind events
  95449. */
  95450. private _onBindObserver;
  95451. /**
  95452. * Called during a bind event
  95453. */
  95454. set onBind(callback: (Mesh: AbstractMesh) => void);
  95455. /**
  95456. * An event triggered when the material is unbound
  95457. */
  95458. get onUnBindObservable(): Observable<Material>;
  95459. /**
  95460. * Stores the value of the alpha mode
  95461. */
  95462. private _alphaMode;
  95463. /**
  95464. * Sets the value of the alpha mode.
  95465. *
  95466. * | Value | Type | Description |
  95467. * | --- | --- | --- |
  95468. * | 0 | ALPHA_DISABLE | |
  95469. * | 1 | ALPHA_ADD | |
  95470. * | 2 | ALPHA_COMBINE | |
  95471. * | 3 | ALPHA_SUBTRACT | |
  95472. * | 4 | ALPHA_MULTIPLY | |
  95473. * | 5 | ALPHA_MAXIMIZED | |
  95474. * | 6 | ALPHA_ONEONE | |
  95475. * | 7 | ALPHA_PREMULTIPLIED | |
  95476. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95477. * | 9 | ALPHA_INTERPOLATE | |
  95478. * | 10 | ALPHA_SCREENMODE | |
  95479. *
  95480. */
  95481. set alphaMode(value: number);
  95482. /**
  95483. * Gets the value of the alpha mode
  95484. */
  95485. get alphaMode(): number;
  95486. /**
  95487. * Stores the state of the need depth pre-pass value
  95488. */
  95489. private _needDepthPrePass;
  95490. /**
  95491. * Sets the need depth pre-pass value
  95492. */
  95493. set needDepthPrePass(value: boolean);
  95494. /**
  95495. * Gets the depth pre-pass value
  95496. */
  95497. get needDepthPrePass(): boolean;
  95498. /**
  95499. * Specifies if depth writing should be disabled
  95500. */
  95501. disableDepthWrite: boolean;
  95502. /**
  95503. * Specifies if depth writing should be forced
  95504. */
  95505. forceDepthWrite: boolean;
  95506. /**
  95507. * Specifies the depth function that should be used. 0 means the default engine function
  95508. */
  95509. depthFunction: number;
  95510. /**
  95511. * Specifies if there should be a separate pass for culling
  95512. */
  95513. separateCullingPass: boolean;
  95514. /**
  95515. * Stores the state specifing if fog should be enabled
  95516. */
  95517. private _fogEnabled;
  95518. /**
  95519. * Sets the state for enabling fog
  95520. */
  95521. set fogEnabled(value: boolean);
  95522. /**
  95523. * Gets the value of the fog enabled state
  95524. */
  95525. get fogEnabled(): boolean;
  95526. /**
  95527. * Stores the size of points
  95528. */
  95529. pointSize: number;
  95530. /**
  95531. * Stores the z offset value
  95532. */
  95533. zOffset: number;
  95534. /**
  95535. * Gets a value specifying if wireframe mode is enabled
  95536. */
  95537. get wireframe(): boolean;
  95538. /**
  95539. * Sets the state of wireframe mode
  95540. */
  95541. set wireframe(value: boolean);
  95542. /**
  95543. * Gets the value specifying if point clouds are enabled
  95544. */
  95545. get pointsCloud(): boolean;
  95546. /**
  95547. * Sets the state of point cloud mode
  95548. */
  95549. set pointsCloud(value: boolean);
  95550. /**
  95551. * Gets the material fill mode
  95552. */
  95553. get fillMode(): number;
  95554. /**
  95555. * Sets the material fill mode
  95556. */
  95557. set fillMode(value: number);
  95558. /**
  95559. * @hidden
  95560. * Stores the effects for the material
  95561. */
  95562. _effect: Nullable<Effect>;
  95563. /**
  95564. * Specifies if uniform buffers should be used
  95565. */
  95566. private _useUBO;
  95567. /**
  95568. * Stores a reference to the scene
  95569. */
  95570. private _scene;
  95571. /**
  95572. * Stores the fill mode state
  95573. */
  95574. private _fillMode;
  95575. /**
  95576. * Specifies if the depth write state should be cached
  95577. */
  95578. private _cachedDepthWriteState;
  95579. /**
  95580. * Specifies if the depth function state should be cached
  95581. */
  95582. private _cachedDepthFunctionState;
  95583. /**
  95584. * Stores the uniform buffer
  95585. */
  95586. protected _uniformBuffer: UniformBuffer;
  95587. /** @hidden */
  95588. _indexInSceneMaterialArray: number;
  95589. /** @hidden */
  95590. meshMap: Nullable<{
  95591. [id: string]: AbstractMesh | undefined;
  95592. }>;
  95593. /**
  95594. * Creates a material instance
  95595. * @param name defines the name of the material
  95596. * @param scene defines the scene to reference
  95597. * @param doNotAdd specifies if the material should be added to the scene
  95598. */
  95599. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95600. /**
  95601. * Returns a string representation of the current material
  95602. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95603. * @returns a string with material information
  95604. */
  95605. toString(fullDetails?: boolean): string;
  95606. /**
  95607. * Gets the class name of the material
  95608. * @returns a string with the class name of the material
  95609. */
  95610. getClassName(): string;
  95611. /**
  95612. * Specifies if updates for the material been locked
  95613. */
  95614. get isFrozen(): boolean;
  95615. /**
  95616. * Locks updates for the material
  95617. */
  95618. freeze(): void;
  95619. /**
  95620. * Unlocks updates for the material
  95621. */
  95622. unfreeze(): void;
  95623. /**
  95624. * Specifies if the material is ready to be used
  95625. * @param mesh defines the mesh to check
  95626. * @param useInstances specifies if instances should be used
  95627. * @returns a boolean indicating if the material is ready to be used
  95628. */
  95629. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95630. /**
  95631. * Specifies that the submesh is ready to be used
  95632. * @param mesh defines the mesh to check
  95633. * @param subMesh defines which submesh to check
  95634. * @param useInstances specifies that instances should be used
  95635. * @returns a boolean indicating that the submesh is ready or not
  95636. */
  95637. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95638. /**
  95639. * Returns the material effect
  95640. * @returns the effect associated with the material
  95641. */
  95642. getEffect(): Nullable<Effect>;
  95643. /**
  95644. * Returns the current scene
  95645. * @returns a Scene
  95646. */
  95647. getScene(): Scene;
  95648. /**
  95649. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95650. */
  95651. protected _forceAlphaTest: boolean;
  95652. /**
  95653. * The transparency mode of the material.
  95654. */
  95655. protected _transparencyMode: Nullable<number>;
  95656. /**
  95657. * Gets the current transparency mode.
  95658. */
  95659. get transparencyMode(): Nullable<number>;
  95660. /**
  95661. * Sets the transparency mode of the material.
  95662. *
  95663. * | Value | Type | Description |
  95664. * | ----- | ----------------------------------- | ----------- |
  95665. * | 0 | OPAQUE | |
  95666. * | 1 | ALPHATEST | |
  95667. * | 2 | ALPHABLEND | |
  95668. * | 3 | ALPHATESTANDBLEND | |
  95669. *
  95670. */
  95671. set transparencyMode(value: Nullable<number>);
  95672. /**
  95673. * Returns true if alpha blending should be disabled.
  95674. */
  95675. protected get _disableAlphaBlending(): boolean;
  95676. /**
  95677. * Specifies whether or not this material should be rendered in alpha blend mode.
  95678. * @returns a boolean specifying if alpha blending is needed
  95679. */
  95680. needAlphaBlending(): boolean;
  95681. /**
  95682. * Specifies if the mesh will require alpha blending
  95683. * @param mesh defines the mesh to check
  95684. * @returns a boolean specifying if alpha blending is needed for the mesh
  95685. */
  95686. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95687. /**
  95688. * Specifies whether or not this material should be rendered in alpha test mode.
  95689. * @returns a boolean specifying if an alpha test is needed.
  95690. */
  95691. needAlphaTesting(): boolean;
  95692. /**
  95693. * Specifies if material alpha testing should be turned on for the mesh
  95694. * @param mesh defines the mesh to check
  95695. */
  95696. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95697. /**
  95698. * Gets the texture used for the alpha test
  95699. * @returns the texture to use for alpha testing
  95700. */
  95701. getAlphaTestTexture(): Nullable<BaseTexture>;
  95702. /**
  95703. * Marks the material to indicate that it needs to be re-calculated
  95704. */
  95705. markDirty(): void;
  95706. /** @hidden */
  95707. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95708. /**
  95709. * Binds the material to the mesh
  95710. * @param world defines the world transformation matrix
  95711. * @param mesh defines the mesh to bind the material to
  95712. */
  95713. bind(world: Matrix, mesh?: Mesh): void;
  95714. /**
  95715. * Binds the submesh to the material
  95716. * @param world defines the world transformation matrix
  95717. * @param mesh defines the mesh containing the submesh
  95718. * @param subMesh defines the submesh to bind the material to
  95719. */
  95720. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95721. /**
  95722. * Binds the world matrix to the material
  95723. * @param world defines the world transformation matrix
  95724. */
  95725. bindOnlyWorldMatrix(world: Matrix): void;
  95726. /**
  95727. * Binds the scene's uniform buffer to the effect.
  95728. * @param effect defines the effect to bind to the scene uniform buffer
  95729. * @param sceneUbo defines the uniform buffer storing scene data
  95730. */
  95731. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95732. /**
  95733. * Binds the view matrix to the effect
  95734. * @param effect defines the effect to bind the view matrix to
  95735. */
  95736. bindView(effect: Effect): void;
  95737. /**
  95738. * Binds the view projection matrix to the effect
  95739. * @param effect defines the effect to bind the view projection matrix to
  95740. */
  95741. bindViewProjection(effect: Effect): void;
  95742. /**
  95743. * Processes to execute after binding the material to a mesh
  95744. * @param mesh defines the rendered mesh
  95745. */
  95746. protected _afterBind(mesh?: Mesh): void;
  95747. /**
  95748. * Unbinds the material from the mesh
  95749. */
  95750. unbind(): void;
  95751. /**
  95752. * Gets the active textures from the material
  95753. * @returns an array of textures
  95754. */
  95755. getActiveTextures(): BaseTexture[];
  95756. /**
  95757. * Specifies if the material uses a texture
  95758. * @param texture defines the texture to check against the material
  95759. * @returns a boolean specifying if the material uses the texture
  95760. */
  95761. hasTexture(texture: BaseTexture): boolean;
  95762. /**
  95763. * Makes a duplicate of the material, and gives it a new name
  95764. * @param name defines the new name for the duplicated material
  95765. * @returns the cloned material
  95766. */
  95767. clone(name: string): Nullable<Material>;
  95768. /**
  95769. * Gets the meshes bound to the material
  95770. * @returns an array of meshes bound to the material
  95771. */
  95772. getBindedMeshes(): AbstractMesh[];
  95773. /**
  95774. * Force shader compilation
  95775. * @param mesh defines the mesh associated with this material
  95776. * @param onCompiled defines a function to execute once the material is compiled
  95777. * @param options defines the options to configure the compilation
  95778. * @param onError defines a function to execute if the material fails compiling
  95779. */
  95780. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95781. /**
  95782. * Force shader compilation
  95783. * @param mesh defines the mesh that will use this material
  95784. * @param options defines additional options for compiling the shaders
  95785. * @returns a promise that resolves when the compilation completes
  95786. */
  95787. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95788. private static readonly _AllDirtyCallBack;
  95789. private static readonly _ImageProcessingDirtyCallBack;
  95790. private static readonly _TextureDirtyCallBack;
  95791. private static readonly _FresnelDirtyCallBack;
  95792. private static readonly _MiscDirtyCallBack;
  95793. private static readonly _LightsDirtyCallBack;
  95794. private static readonly _AttributeDirtyCallBack;
  95795. private static _FresnelAndMiscDirtyCallBack;
  95796. private static _TextureAndMiscDirtyCallBack;
  95797. private static readonly _DirtyCallbackArray;
  95798. private static readonly _RunDirtyCallBacks;
  95799. /**
  95800. * Marks a define in the material to indicate that it needs to be re-computed
  95801. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95802. */
  95803. markAsDirty(flag: number): void;
  95804. /**
  95805. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95806. * @param func defines a function which checks material defines against the submeshes
  95807. */
  95808. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95809. /**
  95810. * Indicates that we need to re-calculated for all submeshes
  95811. */
  95812. protected _markAllSubMeshesAsAllDirty(): void;
  95813. /**
  95814. * Indicates that image processing needs to be re-calculated for all submeshes
  95815. */
  95816. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95817. /**
  95818. * Indicates that textures need to be re-calculated for all submeshes
  95819. */
  95820. protected _markAllSubMeshesAsTexturesDirty(): void;
  95821. /**
  95822. * Indicates that fresnel needs to be re-calculated for all submeshes
  95823. */
  95824. protected _markAllSubMeshesAsFresnelDirty(): void;
  95825. /**
  95826. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95827. */
  95828. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95829. /**
  95830. * Indicates that lights need to be re-calculated for all submeshes
  95831. */
  95832. protected _markAllSubMeshesAsLightsDirty(): void;
  95833. /**
  95834. * Indicates that attributes need to be re-calculated for all submeshes
  95835. */
  95836. protected _markAllSubMeshesAsAttributesDirty(): void;
  95837. /**
  95838. * Indicates that misc needs to be re-calculated for all submeshes
  95839. */
  95840. protected _markAllSubMeshesAsMiscDirty(): void;
  95841. /**
  95842. * Indicates that textures and misc need to be re-calculated for all submeshes
  95843. */
  95844. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95845. /**
  95846. * Disposes the material
  95847. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95848. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95849. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95850. */
  95851. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95852. /** @hidden */
  95853. private releaseVertexArrayObject;
  95854. /**
  95855. * Serializes this material
  95856. * @returns the serialized material object
  95857. */
  95858. serialize(): any;
  95859. /**
  95860. * Creates a material from parsed material data
  95861. * @param parsedMaterial defines parsed material data
  95862. * @param scene defines the hosting scene
  95863. * @param rootUrl defines the root URL to use to load textures
  95864. * @returns a new material
  95865. */
  95866. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95867. }
  95868. }
  95869. declare module BABYLON {
  95870. /**
  95871. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95872. * separate meshes. This can be use to improve performances.
  95873. * @see http://doc.babylonjs.com/how_to/multi_materials
  95874. */
  95875. export class MultiMaterial extends Material {
  95876. private _subMaterials;
  95877. /**
  95878. * Gets or Sets the list of Materials used within the multi material.
  95879. * They need to be ordered according to the submeshes order in the associated mesh
  95880. */
  95881. get subMaterials(): Nullable<Material>[];
  95882. set subMaterials(value: Nullable<Material>[]);
  95883. /**
  95884. * Function used to align with Node.getChildren()
  95885. * @returns the list of Materials used within the multi material
  95886. */
  95887. getChildren(): Nullable<Material>[];
  95888. /**
  95889. * Instantiates a new Multi Material
  95890. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95891. * separate meshes. This can be use to improve performances.
  95892. * @see http://doc.babylonjs.com/how_to/multi_materials
  95893. * @param name Define the name in the scene
  95894. * @param scene Define the scene the material belongs to
  95895. */
  95896. constructor(name: string, scene: Scene);
  95897. private _hookArray;
  95898. /**
  95899. * Get one of the submaterial by its index in the submaterials array
  95900. * @param index The index to look the sub material at
  95901. * @returns The Material if the index has been defined
  95902. */
  95903. getSubMaterial(index: number): Nullable<Material>;
  95904. /**
  95905. * Get the list of active textures for the whole sub materials list.
  95906. * @returns All the textures that will be used during the rendering
  95907. */
  95908. getActiveTextures(): BaseTexture[];
  95909. /**
  95910. * Gets the current class name of the material e.g. "MultiMaterial"
  95911. * Mainly use in serialization.
  95912. * @returns the class name
  95913. */
  95914. getClassName(): string;
  95915. /**
  95916. * Checks if the material is ready to render the requested sub mesh
  95917. * @param mesh Define the mesh the submesh belongs to
  95918. * @param subMesh Define the sub mesh to look readyness for
  95919. * @param useInstances Define whether or not the material is used with instances
  95920. * @returns true if ready, otherwise false
  95921. */
  95922. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95923. /**
  95924. * Clones the current material and its related sub materials
  95925. * @param name Define the name of the newly cloned material
  95926. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95927. * @returns the cloned material
  95928. */
  95929. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95930. /**
  95931. * Serializes the materials into a JSON representation.
  95932. * @returns the JSON representation
  95933. */
  95934. serialize(): any;
  95935. /**
  95936. * Dispose the material and release its associated resources
  95937. * @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)
  95938. * @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)
  95939. * @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)
  95940. */
  95941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95942. /**
  95943. * Creates a MultiMaterial from parsed MultiMaterial data.
  95944. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95945. * @param scene defines the hosting scene
  95946. * @returns a new MultiMaterial
  95947. */
  95948. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95949. }
  95950. }
  95951. declare module BABYLON {
  95952. /**
  95953. * Base class for submeshes
  95954. */
  95955. export class BaseSubMesh {
  95956. /** @hidden */
  95957. _materialDefines: Nullable<MaterialDefines>;
  95958. /** @hidden */
  95959. _materialEffect: Nullable<Effect>;
  95960. /**
  95961. * Gets material defines used by the effect associated to the sub mesh
  95962. */
  95963. get materialDefines(): Nullable<MaterialDefines>;
  95964. /**
  95965. * Sets material defines used by the effect associated to the sub mesh
  95966. */
  95967. set materialDefines(defines: Nullable<MaterialDefines>);
  95968. /**
  95969. * Gets associated effect
  95970. */
  95971. get effect(): Nullable<Effect>;
  95972. /**
  95973. * Sets associated effect (effect used to render this submesh)
  95974. * @param effect defines the effect to associate with
  95975. * @param defines defines the set of defines used to compile this effect
  95976. */
  95977. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95978. }
  95979. /**
  95980. * Defines a subdivision inside a mesh
  95981. */
  95982. export class SubMesh extends BaseSubMesh implements ICullable {
  95983. /** the material index to use */
  95984. materialIndex: number;
  95985. /** vertex index start */
  95986. verticesStart: number;
  95987. /** vertices count */
  95988. verticesCount: number;
  95989. /** index start */
  95990. indexStart: number;
  95991. /** indices count */
  95992. indexCount: number;
  95993. /** @hidden */
  95994. _linesIndexCount: number;
  95995. private _mesh;
  95996. private _renderingMesh;
  95997. private _boundingInfo;
  95998. private _linesIndexBuffer;
  95999. /** @hidden */
  96000. _lastColliderWorldVertices: Nullable<Vector3[]>;
  96001. /** @hidden */
  96002. _trianglePlanes: Plane[];
  96003. /** @hidden */
  96004. _lastColliderTransformMatrix: Nullable<Matrix>;
  96005. /** @hidden */
  96006. _renderId: number;
  96007. /** @hidden */
  96008. _alphaIndex: number;
  96009. /** @hidden */
  96010. _distanceToCamera: number;
  96011. /** @hidden */
  96012. _id: number;
  96013. private _currentMaterial;
  96014. /**
  96015. * Add a new submesh to a mesh
  96016. * @param materialIndex defines the material index to use
  96017. * @param verticesStart defines vertex index start
  96018. * @param verticesCount defines vertices count
  96019. * @param indexStart defines index start
  96020. * @param indexCount defines indices count
  96021. * @param mesh defines the parent mesh
  96022. * @param renderingMesh defines an optional rendering mesh
  96023. * @param createBoundingBox defines if bounding box should be created for this submesh
  96024. * @returns the new submesh
  96025. */
  96026. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  96027. /**
  96028. * Creates a new submesh
  96029. * @param materialIndex defines the material index to use
  96030. * @param verticesStart defines vertex index start
  96031. * @param verticesCount defines vertices count
  96032. * @param indexStart defines index start
  96033. * @param indexCount defines indices count
  96034. * @param mesh defines the parent mesh
  96035. * @param renderingMesh defines an optional rendering mesh
  96036. * @param createBoundingBox defines if bounding box should be created for this submesh
  96037. */
  96038. constructor(
  96039. /** the material index to use */
  96040. materialIndex: number,
  96041. /** vertex index start */
  96042. verticesStart: number,
  96043. /** vertices count */
  96044. verticesCount: number,
  96045. /** index start */
  96046. indexStart: number,
  96047. /** indices count */
  96048. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96049. /**
  96050. * Returns true if this submesh covers the entire parent mesh
  96051. * @ignorenaming
  96052. */
  96053. get IsGlobal(): boolean;
  96054. /**
  96055. * Returns the submesh BoudingInfo object
  96056. * @returns current bounding info (or mesh's one if the submesh is global)
  96057. */
  96058. getBoundingInfo(): BoundingInfo;
  96059. /**
  96060. * Sets the submesh BoundingInfo
  96061. * @param boundingInfo defines the new bounding info to use
  96062. * @returns the SubMesh
  96063. */
  96064. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96065. /**
  96066. * Returns the mesh of the current submesh
  96067. * @return the parent mesh
  96068. */
  96069. getMesh(): AbstractMesh;
  96070. /**
  96071. * Returns the rendering mesh of the submesh
  96072. * @returns the rendering mesh (could be different from parent mesh)
  96073. */
  96074. getRenderingMesh(): Mesh;
  96075. /**
  96076. * Returns the submesh material
  96077. * @returns null or the current material
  96078. */
  96079. getMaterial(): Nullable<Material>;
  96080. /**
  96081. * Sets a new updated BoundingInfo object to the submesh
  96082. * @param data defines an optional position array to use to determine the bounding info
  96083. * @returns the SubMesh
  96084. */
  96085. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96086. /** @hidden */
  96087. _checkCollision(collider: Collider): boolean;
  96088. /**
  96089. * Updates the submesh BoundingInfo
  96090. * @param world defines the world matrix to use to update the bounding info
  96091. * @returns the submesh
  96092. */
  96093. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96094. /**
  96095. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96096. * @param frustumPlanes defines the frustum planes
  96097. * @returns true if the submesh is intersecting with the frustum
  96098. */
  96099. isInFrustum(frustumPlanes: Plane[]): boolean;
  96100. /**
  96101. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96102. * @param frustumPlanes defines the frustum planes
  96103. * @returns true if the submesh is inside the frustum
  96104. */
  96105. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96106. /**
  96107. * Renders the submesh
  96108. * @param enableAlphaMode defines if alpha needs to be used
  96109. * @returns the submesh
  96110. */
  96111. render(enableAlphaMode: boolean): SubMesh;
  96112. /**
  96113. * @hidden
  96114. */
  96115. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96116. /**
  96117. * Checks if the submesh intersects with a ray
  96118. * @param ray defines the ray to test
  96119. * @returns true is the passed ray intersects the submesh bounding box
  96120. */
  96121. canIntersects(ray: Ray): boolean;
  96122. /**
  96123. * Intersects current submesh with a ray
  96124. * @param ray defines the ray to test
  96125. * @param positions defines mesh's positions array
  96126. * @param indices defines mesh's indices array
  96127. * @param fastCheck defines if only bounding info should be used
  96128. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96129. * @returns intersection info or null if no intersection
  96130. */
  96131. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96132. /** @hidden */
  96133. private _intersectLines;
  96134. /** @hidden */
  96135. private _intersectUnIndexedLines;
  96136. /** @hidden */
  96137. private _intersectTriangles;
  96138. /** @hidden */
  96139. private _intersectUnIndexedTriangles;
  96140. /** @hidden */
  96141. _rebuild(): void;
  96142. /**
  96143. * Creates a new submesh from the passed mesh
  96144. * @param newMesh defines the new hosting mesh
  96145. * @param newRenderingMesh defines an optional rendering mesh
  96146. * @returns the new submesh
  96147. */
  96148. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96149. /**
  96150. * Release associated resources
  96151. */
  96152. dispose(): void;
  96153. /**
  96154. * Gets the class name
  96155. * @returns the string "SubMesh".
  96156. */
  96157. getClassName(): string;
  96158. /**
  96159. * Creates a new submesh from indices data
  96160. * @param materialIndex the index of the main mesh material
  96161. * @param startIndex the index where to start the copy in the mesh indices array
  96162. * @param indexCount the number of indices to copy then from the startIndex
  96163. * @param mesh the main mesh to create the submesh from
  96164. * @param renderingMesh the optional rendering mesh
  96165. * @returns a new submesh
  96166. */
  96167. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96168. }
  96169. }
  96170. declare module BABYLON {
  96171. /**
  96172. * Class used to represent data loading progression
  96173. */
  96174. export class SceneLoaderFlags {
  96175. private static _ForceFullSceneLoadingForIncremental;
  96176. private static _ShowLoadingScreen;
  96177. private static _CleanBoneMatrixWeights;
  96178. private static _loggingLevel;
  96179. /**
  96180. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96181. */
  96182. static get ForceFullSceneLoadingForIncremental(): boolean;
  96183. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96184. /**
  96185. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96186. */
  96187. static get ShowLoadingScreen(): boolean;
  96188. static set ShowLoadingScreen(value: boolean);
  96189. /**
  96190. * Defines the current logging level (while loading the scene)
  96191. * @ignorenaming
  96192. */
  96193. static get loggingLevel(): number;
  96194. static set loggingLevel(value: number);
  96195. /**
  96196. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96197. */
  96198. static get CleanBoneMatrixWeights(): boolean;
  96199. static set CleanBoneMatrixWeights(value: boolean);
  96200. }
  96201. }
  96202. declare module BABYLON {
  96203. /**
  96204. * Class used to store geometry data (vertex buffers + index buffer)
  96205. */
  96206. export class Geometry implements IGetSetVerticesData {
  96207. /**
  96208. * Gets or sets the ID of the geometry
  96209. */
  96210. id: string;
  96211. /**
  96212. * Gets or sets the unique ID of the geometry
  96213. */
  96214. uniqueId: number;
  96215. /**
  96216. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96217. */
  96218. delayLoadState: number;
  96219. /**
  96220. * Gets the file containing the data to load when running in delay load state
  96221. */
  96222. delayLoadingFile: Nullable<string>;
  96223. /**
  96224. * Callback called when the geometry is updated
  96225. */
  96226. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96227. private _scene;
  96228. private _engine;
  96229. private _meshes;
  96230. private _totalVertices;
  96231. /** @hidden */
  96232. _indices: IndicesArray;
  96233. /** @hidden */
  96234. _vertexBuffers: {
  96235. [key: string]: VertexBuffer;
  96236. };
  96237. private _isDisposed;
  96238. private _extend;
  96239. private _boundingBias;
  96240. /** @hidden */
  96241. _delayInfo: Array<string>;
  96242. private _indexBuffer;
  96243. private _indexBufferIsUpdatable;
  96244. /** @hidden */
  96245. _boundingInfo: Nullable<BoundingInfo>;
  96246. /** @hidden */
  96247. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96248. /** @hidden */
  96249. _softwareSkinningFrameId: number;
  96250. private _vertexArrayObjects;
  96251. private _updatable;
  96252. /** @hidden */
  96253. _positions: Nullable<Vector3[]>;
  96254. /**
  96255. * 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
  96256. */
  96257. get boundingBias(): Vector2;
  96258. /**
  96259. * 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
  96260. */
  96261. set boundingBias(value: Vector2);
  96262. /**
  96263. * Static function used to attach a new empty geometry to a mesh
  96264. * @param mesh defines the mesh to attach the geometry to
  96265. * @returns the new Geometry
  96266. */
  96267. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96268. /**
  96269. * Creates a new geometry
  96270. * @param id defines the unique ID
  96271. * @param scene defines the hosting scene
  96272. * @param vertexData defines the VertexData used to get geometry data
  96273. * @param updatable defines if geometry must be updatable (false by default)
  96274. * @param mesh defines the mesh that will be associated with the geometry
  96275. */
  96276. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96277. /**
  96278. * Gets the current extend of the geometry
  96279. */
  96280. get extend(): {
  96281. minimum: Vector3;
  96282. maximum: Vector3;
  96283. };
  96284. /**
  96285. * Gets the hosting scene
  96286. * @returns the hosting Scene
  96287. */
  96288. getScene(): Scene;
  96289. /**
  96290. * Gets the hosting engine
  96291. * @returns the hosting Engine
  96292. */
  96293. getEngine(): Engine;
  96294. /**
  96295. * Defines if the geometry is ready to use
  96296. * @returns true if the geometry is ready to be used
  96297. */
  96298. isReady(): boolean;
  96299. /**
  96300. * Gets a value indicating that the geometry should not be serialized
  96301. */
  96302. get doNotSerialize(): boolean;
  96303. /** @hidden */
  96304. _rebuild(): void;
  96305. /**
  96306. * Affects all geometry data in one call
  96307. * @param vertexData defines the geometry data
  96308. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96309. */
  96310. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96311. /**
  96312. * Set specific vertex data
  96313. * @param kind defines the data kind (Position, normal, etc...)
  96314. * @param data defines the vertex data to use
  96315. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96316. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96317. */
  96318. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96319. /**
  96320. * Removes a specific vertex data
  96321. * @param kind defines the data kind (Position, normal, etc...)
  96322. */
  96323. removeVerticesData(kind: string): void;
  96324. /**
  96325. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96326. * @param buffer defines the vertex buffer to use
  96327. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96328. */
  96329. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96330. /**
  96331. * Update a specific vertex buffer
  96332. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96333. * It will do nothing if the buffer is not updatable
  96334. * @param kind defines the data kind (Position, normal, etc...)
  96335. * @param data defines the data to use
  96336. * @param offset defines the offset in the target buffer where to store the data
  96337. * @param useBytes set to true if the offset is in bytes
  96338. */
  96339. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96340. /**
  96341. * Update a specific vertex buffer
  96342. * This function will create a new buffer if the current one is not updatable
  96343. * @param kind defines the data kind (Position, normal, etc...)
  96344. * @param data defines the data to use
  96345. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96346. */
  96347. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96348. private _updateBoundingInfo;
  96349. /** @hidden */
  96350. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96351. /**
  96352. * Gets total number of vertices
  96353. * @returns the total number of vertices
  96354. */
  96355. getTotalVertices(): number;
  96356. /**
  96357. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96358. * @param kind defines the data kind (Position, normal, etc...)
  96359. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96361. * @returns a float array containing vertex data
  96362. */
  96363. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96364. /**
  96365. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96366. * @param kind defines the data kind (Position, normal, etc...)
  96367. * @returns true if the vertex buffer with the specified kind is updatable
  96368. */
  96369. isVertexBufferUpdatable(kind: string): boolean;
  96370. /**
  96371. * Gets a specific vertex buffer
  96372. * @param kind defines the data kind (Position, normal, etc...)
  96373. * @returns a VertexBuffer
  96374. */
  96375. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96376. /**
  96377. * Returns all vertex buffers
  96378. * @return an object holding all vertex buffers indexed by kind
  96379. */
  96380. getVertexBuffers(): Nullable<{
  96381. [key: string]: VertexBuffer;
  96382. }>;
  96383. /**
  96384. * Gets a boolean indicating if specific vertex buffer is present
  96385. * @param kind defines the data kind (Position, normal, etc...)
  96386. * @returns true if data is present
  96387. */
  96388. isVerticesDataPresent(kind: string): boolean;
  96389. /**
  96390. * Gets a list of all attached data kinds (Position, normal, etc...)
  96391. * @returns a list of string containing all kinds
  96392. */
  96393. getVerticesDataKinds(): string[];
  96394. /**
  96395. * Update index buffer
  96396. * @param indices defines the indices to store in the index buffer
  96397. * @param offset defines the offset in the target buffer where to store the data
  96398. * @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)
  96399. */
  96400. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96401. /**
  96402. * Creates a new index buffer
  96403. * @param indices defines the indices to store in the index buffer
  96404. * @param totalVertices defines the total number of vertices (could be null)
  96405. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96406. */
  96407. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96408. /**
  96409. * Return the total number of indices
  96410. * @returns the total number of indices
  96411. */
  96412. getTotalIndices(): number;
  96413. /**
  96414. * Gets the index buffer array
  96415. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96416. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96417. * @returns the index buffer array
  96418. */
  96419. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96420. /**
  96421. * Gets the index buffer
  96422. * @return the index buffer
  96423. */
  96424. getIndexBuffer(): Nullable<DataBuffer>;
  96425. /** @hidden */
  96426. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96427. /**
  96428. * Release the associated resources for a specific mesh
  96429. * @param mesh defines the source mesh
  96430. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96431. */
  96432. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96433. /**
  96434. * Apply current geometry to a given mesh
  96435. * @param mesh defines the mesh to apply geometry to
  96436. */
  96437. applyToMesh(mesh: Mesh): void;
  96438. private _updateExtend;
  96439. private _applyToMesh;
  96440. private notifyUpdate;
  96441. /**
  96442. * Load the geometry if it was flagged as delay loaded
  96443. * @param scene defines the hosting scene
  96444. * @param onLoaded defines a callback called when the geometry is loaded
  96445. */
  96446. load(scene: Scene, onLoaded?: () => void): void;
  96447. private _queueLoad;
  96448. /**
  96449. * Invert the geometry to move from a right handed system to a left handed one.
  96450. */
  96451. toLeftHanded(): void;
  96452. /** @hidden */
  96453. _resetPointsArrayCache(): void;
  96454. /** @hidden */
  96455. _generatePointsArray(): boolean;
  96456. /**
  96457. * Gets a value indicating if the geometry is disposed
  96458. * @returns true if the geometry was disposed
  96459. */
  96460. isDisposed(): boolean;
  96461. private _disposeVertexArrayObjects;
  96462. /**
  96463. * Free all associated resources
  96464. */
  96465. dispose(): void;
  96466. /**
  96467. * Clone the current geometry into a new geometry
  96468. * @param id defines the unique ID of the new geometry
  96469. * @returns a new geometry object
  96470. */
  96471. copy(id: string): Geometry;
  96472. /**
  96473. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96474. * @return a JSON representation of the current geometry data (without the vertices data)
  96475. */
  96476. serialize(): any;
  96477. private toNumberArray;
  96478. /**
  96479. * Serialize all vertices data into a JSON oject
  96480. * @returns a JSON representation of the current geometry data
  96481. */
  96482. serializeVerticeData(): any;
  96483. /**
  96484. * Extracts a clone of a mesh geometry
  96485. * @param mesh defines the source mesh
  96486. * @param id defines the unique ID of the new geometry object
  96487. * @returns the new geometry object
  96488. */
  96489. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96490. /**
  96491. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96492. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96493. * Be aware Math.random() could cause collisions, but:
  96494. * "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"
  96495. * @returns a string containing a new GUID
  96496. */
  96497. static RandomId(): string;
  96498. /** @hidden */
  96499. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96500. private static _CleanMatricesWeights;
  96501. /**
  96502. * Create a new geometry from persisted data (Using .babylon file format)
  96503. * @param parsedVertexData defines the persisted data
  96504. * @param scene defines the hosting scene
  96505. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96506. * @returns the new geometry object
  96507. */
  96508. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96509. }
  96510. }
  96511. declare module BABYLON {
  96512. /**
  96513. * Define an interface for all classes that will get and set the data on vertices
  96514. */
  96515. export interface IGetSetVerticesData {
  96516. /**
  96517. * Gets a boolean indicating if specific vertex data is present
  96518. * @param kind defines the vertex data kind to use
  96519. * @returns true is data kind is present
  96520. */
  96521. isVerticesDataPresent(kind: string): boolean;
  96522. /**
  96523. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96524. * @param kind defines the data kind (Position, normal, etc...)
  96525. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96526. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96527. * @returns a float array containing vertex data
  96528. */
  96529. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96530. /**
  96531. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96532. * @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.
  96533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96534. * @returns the indices array or an empty array if the mesh has no geometry
  96535. */
  96536. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96537. /**
  96538. * Set specific vertex data
  96539. * @param kind defines the data kind (Position, normal, etc...)
  96540. * @param data defines the vertex data to use
  96541. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96542. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96543. */
  96544. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96545. /**
  96546. * Update a specific associated vertex buffer
  96547. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96548. * - VertexBuffer.PositionKind
  96549. * - VertexBuffer.UVKind
  96550. * - VertexBuffer.UV2Kind
  96551. * - VertexBuffer.UV3Kind
  96552. * - VertexBuffer.UV4Kind
  96553. * - VertexBuffer.UV5Kind
  96554. * - VertexBuffer.UV6Kind
  96555. * - VertexBuffer.ColorKind
  96556. * - VertexBuffer.MatricesIndicesKind
  96557. * - VertexBuffer.MatricesIndicesExtraKind
  96558. * - VertexBuffer.MatricesWeightsKind
  96559. * - VertexBuffer.MatricesWeightsExtraKind
  96560. * @param data defines the data source
  96561. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96562. * @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)
  96563. */
  96564. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96565. /**
  96566. * Creates a new index buffer
  96567. * @param indices defines the indices to store in the index buffer
  96568. * @param totalVertices defines the total number of vertices (could be null)
  96569. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96570. */
  96571. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96572. }
  96573. /**
  96574. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96575. */
  96576. export class VertexData {
  96577. /**
  96578. * Mesh side orientation : usually the external or front surface
  96579. */
  96580. static readonly FRONTSIDE: number;
  96581. /**
  96582. * Mesh side orientation : usually the internal or back surface
  96583. */
  96584. static readonly BACKSIDE: number;
  96585. /**
  96586. * Mesh side orientation : both internal and external or front and back surfaces
  96587. */
  96588. static readonly DOUBLESIDE: number;
  96589. /**
  96590. * Mesh side orientation : by default, `FRONTSIDE`
  96591. */
  96592. static readonly DEFAULTSIDE: number;
  96593. /**
  96594. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96595. */
  96596. positions: Nullable<FloatArray>;
  96597. /**
  96598. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96599. */
  96600. normals: Nullable<FloatArray>;
  96601. /**
  96602. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96603. */
  96604. tangents: Nullable<FloatArray>;
  96605. /**
  96606. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96607. */
  96608. uvs: Nullable<FloatArray>;
  96609. /**
  96610. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96611. */
  96612. uvs2: Nullable<FloatArray>;
  96613. /**
  96614. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96615. */
  96616. uvs3: Nullable<FloatArray>;
  96617. /**
  96618. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96619. */
  96620. uvs4: Nullable<FloatArray>;
  96621. /**
  96622. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96623. */
  96624. uvs5: Nullable<FloatArray>;
  96625. /**
  96626. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96627. */
  96628. uvs6: Nullable<FloatArray>;
  96629. /**
  96630. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96631. */
  96632. colors: Nullable<FloatArray>;
  96633. /**
  96634. * 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).
  96635. */
  96636. matricesIndices: Nullable<FloatArray>;
  96637. /**
  96638. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96639. */
  96640. matricesWeights: Nullable<FloatArray>;
  96641. /**
  96642. * An array extending the number of possible indices
  96643. */
  96644. matricesIndicesExtra: Nullable<FloatArray>;
  96645. /**
  96646. * An array extending the number of possible weights when the number of indices is extended
  96647. */
  96648. matricesWeightsExtra: Nullable<FloatArray>;
  96649. /**
  96650. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96651. */
  96652. indices: Nullable<IndicesArray>;
  96653. /**
  96654. * Uses the passed data array to set the set the values for the specified kind of data
  96655. * @param data a linear array of floating numbers
  96656. * @param kind the type of data that is being set, eg positions, colors etc
  96657. */
  96658. set(data: FloatArray, kind: string): void;
  96659. /**
  96660. * Associates the vertexData to the passed Mesh.
  96661. * Sets it as updatable or not (default `false`)
  96662. * @param mesh the mesh the vertexData is applied to
  96663. * @param updatable when used and having the value true allows new data to update the vertexData
  96664. * @returns the VertexData
  96665. */
  96666. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96667. /**
  96668. * Associates the vertexData to the passed Geometry.
  96669. * Sets it as updatable or not (default `false`)
  96670. * @param geometry the geometry the vertexData is applied to
  96671. * @param updatable when used and having the value true allows new data to update the vertexData
  96672. * @returns VertexData
  96673. */
  96674. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96675. /**
  96676. * Updates the associated mesh
  96677. * @param mesh the mesh to be updated
  96678. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96679. * @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
  96680. * @returns VertexData
  96681. */
  96682. updateMesh(mesh: Mesh): VertexData;
  96683. /**
  96684. * Updates the associated geometry
  96685. * @param geometry the geometry to be updated
  96686. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96687. * @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
  96688. * @returns VertexData.
  96689. */
  96690. updateGeometry(geometry: Geometry): VertexData;
  96691. private _applyTo;
  96692. private _update;
  96693. /**
  96694. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96695. * @param matrix the transforming matrix
  96696. * @returns the VertexData
  96697. */
  96698. transform(matrix: Matrix): VertexData;
  96699. /**
  96700. * Merges the passed VertexData into the current one
  96701. * @param other the VertexData to be merged into the current one
  96702. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96703. * @returns the modified VertexData
  96704. */
  96705. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96706. private _mergeElement;
  96707. private _validate;
  96708. /**
  96709. * Serializes the VertexData
  96710. * @returns a serialized object
  96711. */
  96712. serialize(): any;
  96713. /**
  96714. * Extracts the vertexData from a mesh
  96715. * @param mesh the mesh from which to extract the VertexData
  96716. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96717. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96718. * @returns the object VertexData associated to the passed mesh
  96719. */
  96720. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96721. /**
  96722. * Extracts the vertexData from the geometry
  96723. * @param geometry the geometry from which to extract the VertexData
  96724. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96725. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96726. * @returns the object VertexData associated to the passed mesh
  96727. */
  96728. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96729. private static _ExtractFrom;
  96730. /**
  96731. * Creates the VertexData for a Ribbon
  96732. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96733. * * pathArray array of paths, each of which an array of successive Vector3
  96734. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96735. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96736. * * 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
  96737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96738. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  96739. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  96740. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96741. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96742. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96743. * @returns the VertexData of the ribbon
  96744. */
  96745. static CreateRibbon(options: {
  96746. pathArray: Vector3[][];
  96747. closeArray?: boolean;
  96748. closePath?: boolean;
  96749. offset?: number;
  96750. sideOrientation?: number;
  96751. frontUVs?: Vector4;
  96752. backUVs?: Vector4;
  96753. invertUV?: boolean;
  96754. uvs?: Vector2[];
  96755. colors?: Color4[];
  96756. }): VertexData;
  96757. /**
  96758. * Creates the VertexData for a box
  96759. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96760. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96761. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96762. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96763. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96764. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96765. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96767. * * 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)
  96768. * * 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)
  96769. * @returns the VertexData of the box
  96770. */
  96771. static CreateBox(options: {
  96772. size?: number;
  96773. width?: number;
  96774. height?: number;
  96775. depth?: number;
  96776. faceUV?: Vector4[];
  96777. faceColors?: Color4[];
  96778. sideOrientation?: number;
  96779. frontUVs?: Vector4;
  96780. backUVs?: Vector4;
  96781. }): VertexData;
  96782. /**
  96783. * Creates the VertexData for a tiled box
  96784. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96785. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96786. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96787. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96789. * @returns the VertexData of the box
  96790. */
  96791. static CreateTiledBox(options: {
  96792. pattern?: number;
  96793. width?: number;
  96794. height?: number;
  96795. depth?: number;
  96796. tileSize?: number;
  96797. tileWidth?: number;
  96798. tileHeight?: number;
  96799. alignHorizontal?: number;
  96800. alignVertical?: number;
  96801. faceUV?: Vector4[];
  96802. faceColors?: Color4[];
  96803. sideOrientation?: number;
  96804. }): VertexData;
  96805. /**
  96806. * Creates the VertexData for a tiled plane
  96807. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96808. * * pattern a limited pattern arrangement depending on the number
  96809. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96810. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96811. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96813. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  96814. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  96815. * @returns the VertexData of the tiled plane
  96816. */
  96817. static CreateTiledPlane(options: {
  96818. pattern?: number;
  96819. tileSize?: number;
  96820. tileWidth?: number;
  96821. tileHeight?: number;
  96822. size?: number;
  96823. width?: number;
  96824. height?: number;
  96825. alignHorizontal?: number;
  96826. alignVertical?: number;
  96827. sideOrientation?: number;
  96828. frontUVs?: Vector4;
  96829. backUVs?: Vector4;
  96830. }): VertexData;
  96831. /**
  96832. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96833. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96834. * * segments sets the number of horizontal strips optional, default 32
  96835. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96836. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96837. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96838. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96839. * * 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
  96840. * * 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
  96841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96842. * * 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)
  96843. * * 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)
  96844. * @returns the VertexData of the ellipsoid
  96845. */
  96846. static CreateSphere(options: {
  96847. segments?: number;
  96848. diameter?: number;
  96849. diameterX?: number;
  96850. diameterY?: number;
  96851. diameterZ?: number;
  96852. arc?: number;
  96853. slice?: number;
  96854. sideOrientation?: number;
  96855. frontUVs?: Vector4;
  96856. backUVs?: Vector4;
  96857. }): VertexData;
  96858. /**
  96859. * Creates the VertexData for a cylinder, cone or prism
  96860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96861. * * height sets the height (y direction) of the cylinder, optional, default 2
  96862. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96863. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96864. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96865. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96866. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96867. * * 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
  96868. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96869. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96870. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96871. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96873. * * 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)
  96874. * * 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)
  96875. * @returns the VertexData of the cylinder, cone or prism
  96876. */
  96877. static CreateCylinder(options: {
  96878. height?: number;
  96879. diameterTop?: number;
  96880. diameterBottom?: number;
  96881. diameter?: number;
  96882. tessellation?: number;
  96883. subdivisions?: number;
  96884. arc?: number;
  96885. faceColors?: Color4[];
  96886. faceUV?: Vector4[];
  96887. hasRings?: boolean;
  96888. enclose?: boolean;
  96889. sideOrientation?: number;
  96890. frontUVs?: Vector4;
  96891. backUVs?: Vector4;
  96892. }): VertexData;
  96893. /**
  96894. * Creates the VertexData for a torus
  96895. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96896. * * diameter the diameter of the torus, optional default 1
  96897. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96898. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96899. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96900. * * 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)
  96901. * * 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)
  96902. * @returns the VertexData of the torus
  96903. */
  96904. static CreateTorus(options: {
  96905. diameter?: number;
  96906. thickness?: number;
  96907. tessellation?: number;
  96908. sideOrientation?: number;
  96909. frontUVs?: Vector4;
  96910. backUVs?: Vector4;
  96911. }): VertexData;
  96912. /**
  96913. * Creates the VertexData of the LineSystem
  96914. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96915. * - lines an array of lines, each line being an array of successive Vector3
  96916. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96917. * @returns the VertexData of the LineSystem
  96918. */
  96919. static CreateLineSystem(options: {
  96920. lines: Vector3[][];
  96921. colors?: Nullable<Color4[][]>;
  96922. }): VertexData;
  96923. /**
  96924. * Create the VertexData for a DashedLines
  96925. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96926. * - points an array successive Vector3
  96927. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96928. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96929. * - dashNb the intended total number of dashes, optional, default 200
  96930. * @returns the VertexData for the DashedLines
  96931. */
  96932. static CreateDashedLines(options: {
  96933. points: Vector3[];
  96934. dashSize?: number;
  96935. gapSize?: number;
  96936. dashNb?: number;
  96937. }): VertexData;
  96938. /**
  96939. * Creates the VertexData for a Ground
  96940. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96941. * - width the width (x direction) of the ground, optional, default 1
  96942. * - height the height (z direction) of the ground, optional, default 1
  96943. * - subdivisions the number of subdivisions per side, optional, default 1
  96944. * @returns the VertexData of the Ground
  96945. */
  96946. static CreateGround(options: {
  96947. width?: number;
  96948. height?: number;
  96949. subdivisions?: number;
  96950. subdivisionsX?: number;
  96951. subdivisionsY?: number;
  96952. }): VertexData;
  96953. /**
  96954. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96955. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96956. * * xmin the ground minimum X coordinate, optional, default -1
  96957. * * zmin the ground minimum Z coordinate, optional, default -1
  96958. * * xmax the ground maximum X coordinate, optional, default 1
  96959. * * zmax the ground maximum Z coordinate, optional, default 1
  96960. * * 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}
  96961. * * 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}
  96962. * @returns the VertexData of the TiledGround
  96963. */
  96964. static CreateTiledGround(options: {
  96965. xmin: number;
  96966. zmin: number;
  96967. xmax: number;
  96968. zmax: number;
  96969. subdivisions?: {
  96970. w: number;
  96971. h: number;
  96972. };
  96973. precision?: {
  96974. w: number;
  96975. h: number;
  96976. };
  96977. }): VertexData;
  96978. /**
  96979. * Creates the VertexData of the Ground designed from a heightmap
  96980. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96981. * * width the width (x direction) of the ground
  96982. * * height the height (z direction) of the ground
  96983. * * subdivisions the number of subdivisions per side
  96984. * * minHeight the minimum altitude on the ground, optional, default 0
  96985. * * maxHeight the maximum altitude on the ground, optional default 1
  96986. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96987. * * buffer the array holding the image color data
  96988. * * bufferWidth the width of image
  96989. * * bufferHeight the height of image
  96990. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96991. * @returns the VertexData of the Ground designed from a heightmap
  96992. */
  96993. static CreateGroundFromHeightMap(options: {
  96994. width: number;
  96995. height: number;
  96996. subdivisions: number;
  96997. minHeight: number;
  96998. maxHeight: number;
  96999. colorFilter: Color3;
  97000. buffer: Uint8Array;
  97001. bufferWidth: number;
  97002. bufferHeight: number;
  97003. alphaFilter: number;
  97004. }): VertexData;
  97005. /**
  97006. * Creates the VertexData for a Plane
  97007. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  97008. * * size sets the width and height of the plane to the value of size, optional default 1
  97009. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  97010. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  97011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97012. * * 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)
  97013. * * 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)
  97014. * @returns the VertexData of the box
  97015. */
  97016. static CreatePlane(options: {
  97017. size?: number;
  97018. width?: number;
  97019. height?: number;
  97020. sideOrientation?: number;
  97021. frontUVs?: Vector4;
  97022. backUVs?: Vector4;
  97023. }): VertexData;
  97024. /**
  97025. * Creates the VertexData of the Disc or regular Polygon
  97026. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  97027. * * radius the radius of the disc, optional default 0.5
  97028. * * tessellation the number of polygon sides, optional, default 64
  97029. * * 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
  97030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97031. * * 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)
  97032. * * 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)
  97033. * @returns the VertexData of the box
  97034. */
  97035. static CreateDisc(options: {
  97036. radius?: number;
  97037. tessellation?: number;
  97038. arc?: number;
  97039. sideOrientation?: number;
  97040. frontUVs?: Vector4;
  97041. backUVs?: Vector4;
  97042. }): VertexData;
  97043. /**
  97044. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97045. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97046. * @param polygon a mesh built from polygonTriangulation.build()
  97047. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97048. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97049. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97050. * @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)
  97051. * @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)
  97052. * @returns the VertexData of the Polygon
  97053. */
  97054. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97055. /**
  97056. * Creates the VertexData of the IcoSphere
  97057. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97058. * * radius the radius of the IcoSphere, optional default 1
  97059. * * radiusX allows stretching in the x direction, optional, default radius
  97060. * * radiusY allows stretching in the y direction, optional, default radius
  97061. * * radiusZ allows stretching in the z direction, optional, default radius
  97062. * * flat when true creates a flat shaded mesh, optional, default true
  97063. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97064. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97065. * * 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)
  97066. * * 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)
  97067. * @returns the VertexData of the IcoSphere
  97068. */
  97069. static CreateIcoSphere(options: {
  97070. radius?: number;
  97071. radiusX?: number;
  97072. radiusY?: number;
  97073. radiusZ?: number;
  97074. flat?: boolean;
  97075. subdivisions?: number;
  97076. sideOrientation?: number;
  97077. frontUVs?: Vector4;
  97078. backUVs?: Vector4;
  97079. }): VertexData;
  97080. /**
  97081. * Creates the VertexData for a Polyhedron
  97082. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97083. * * type provided types are:
  97084. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97085. * * 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)
  97086. * * size the size of the IcoSphere, optional default 1
  97087. * * sizeX allows stretching in the x direction, optional, default size
  97088. * * sizeY allows stretching in the y direction, optional, default size
  97089. * * sizeZ allows stretching in the z direction, optional, default size
  97090. * * 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
  97091. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97092. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97093. * * flat when true creates a flat shaded mesh, optional, default true
  97094. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97096. * * 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)
  97097. * * 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)
  97098. * @returns the VertexData of the Polyhedron
  97099. */
  97100. static CreatePolyhedron(options: {
  97101. type?: number;
  97102. size?: number;
  97103. sizeX?: number;
  97104. sizeY?: number;
  97105. sizeZ?: number;
  97106. custom?: any;
  97107. faceUV?: Vector4[];
  97108. faceColors?: Color4[];
  97109. flat?: boolean;
  97110. sideOrientation?: number;
  97111. frontUVs?: Vector4;
  97112. backUVs?: Vector4;
  97113. }): VertexData;
  97114. /**
  97115. * Creates the VertexData for a TorusKnot
  97116. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97117. * * radius the radius of the torus knot, optional, default 2
  97118. * * tube the thickness of the tube, optional, default 0.5
  97119. * * radialSegments the number of sides on each tube segments, optional, default 32
  97120. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97121. * * p the number of windings around the z axis, optional, default 2
  97122. * * q the number of windings around the x axis, optional, default 3
  97123. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97124. * * 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)
  97125. * * 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)
  97126. * @returns the VertexData of the Torus Knot
  97127. */
  97128. static CreateTorusKnot(options: {
  97129. radius?: number;
  97130. tube?: number;
  97131. radialSegments?: number;
  97132. tubularSegments?: number;
  97133. p?: number;
  97134. q?: number;
  97135. sideOrientation?: number;
  97136. frontUVs?: Vector4;
  97137. backUVs?: Vector4;
  97138. }): VertexData;
  97139. /**
  97140. * Compute normals for given positions and indices
  97141. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97142. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97143. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97144. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97145. * * facetNormals : optional array of facet normals (vector3)
  97146. * * facetPositions : optional array of facet positions (vector3)
  97147. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97148. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97149. * * bInfo : optional bounding info, required for facetPartitioning computation
  97150. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97151. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97152. * * useRightHandedSystem: optional boolean to for right handed system computation
  97153. * * depthSort : optional boolean to enable the facet depth sort computation
  97154. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97155. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97156. */
  97157. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97158. facetNormals?: any;
  97159. facetPositions?: any;
  97160. facetPartitioning?: any;
  97161. ratio?: number;
  97162. bInfo?: any;
  97163. bbSize?: Vector3;
  97164. subDiv?: any;
  97165. useRightHandedSystem?: boolean;
  97166. depthSort?: boolean;
  97167. distanceTo?: Vector3;
  97168. depthSortedFacets?: any;
  97169. }): void;
  97170. /** @hidden */
  97171. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97172. /**
  97173. * Applies VertexData created from the imported parameters to the geometry
  97174. * @param parsedVertexData the parsed data from an imported file
  97175. * @param geometry the geometry to apply the VertexData to
  97176. */
  97177. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97178. }
  97179. }
  97180. declare module BABYLON {
  97181. /**
  97182. * Defines a target to use with MorphTargetManager
  97183. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97184. */
  97185. export class MorphTarget implements IAnimatable {
  97186. /** defines the name of the target */
  97187. name: string;
  97188. /**
  97189. * Gets or sets the list of animations
  97190. */
  97191. animations: Animation[];
  97192. private _scene;
  97193. private _positions;
  97194. private _normals;
  97195. private _tangents;
  97196. private _uvs;
  97197. private _influence;
  97198. private _uniqueId;
  97199. /**
  97200. * Observable raised when the influence changes
  97201. */
  97202. onInfluenceChanged: Observable<boolean>;
  97203. /** @hidden */
  97204. _onDataLayoutChanged: Observable<void>;
  97205. /**
  97206. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97207. */
  97208. get influence(): number;
  97209. set influence(influence: number);
  97210. /**
  97211. * Gets or sets the id of the morph Target
  97212. */
  97213. id: string;
  97214. private _animationPropertiesOverride;
  97215. /**
  97216. * Gets or sets the animation properties override
  97217. */
  97218. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97219. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97220. /**
  97221. * Creates a new MorphTarget
  97222. * @param name defines the name of the target
  97223. * @param influence defines the influence to use
  97224. * @param scene defines the scene the morphtarget belongs to
  97225. */
  97226. constructor(
  97227. /** defines the name of the target */
  97228. name: string, influence?: number, scene?: Nullable<Scene>);
  97229. /**
  97230. * Gets the unique ID of this manager
  97231. */
  97232. get uniqueId(): number;
  97233. /**
  97234. * Gets a boolean defining if the target contains position data
  97235. */
  97236. get hasPositions(): boolean;
  97237. /**
  97238. * Gets a boolean defining if the target contains normal data
  97239. */
  97240. get hasNormals(): boolean;
  97241. /**
  97242. * Gets a boolean defining if the target contains tangent data
  97243. */
  97244. get hasTangents(): boolean;
  97245. /**
  97246. * Gets a boolean defining if the target contains texture coordinates data
  97247. */
  97248. get hasUVs(): boolean;
  97249. /**
  97250. * Affects position data to this target
  97251. * @param data defines the position data to use
  97252. */
  97253. setPositions(data: Nullable<FloatArray>): void;
  97254. /**
  97255. * Gets the position data stored in this target
  97256. * @returns a FloatArray containing the position data (or null if not present)
  97257. */
  97258. getPositions(): Nullable<FloatArray>;
  97259. /**
  97260. * Affects normal data to this target
  97261. * @param data defines the normal data to use
  97262. */
  97263. setNormals(data: Nullable<FloatArray>): void;
  97264. /**
  97265. * Gets the normal data stored in this target
  97266. * @returns a FloatArray containing the normal data (or null if not present)
  97267. */
  97268. getNormals(): Nullable<FloatArray>;
  97269. /**
  97270. * Affects tangent data to this target
  97271. * @param data defines the tangent data to use
  97272. */
  97273. setTangents(data: Nullable<FloatArray>): void;
  97274. /**
  97275. * Gets the tangent data stored in this target
  97276. * @returns a FloatArray containing the tangent data (or null if not present)
  97277. */
  97278. getTangents(): Nullable<FloatArray>;
  97279. /**
  97280. * Affects texture coordinates data to this target
  97281. * @param data defines the texture coordinates data to use
  97282. */
  97283. setUVs(data: Nullable<FloatArray>): void;
  97284. /**
  97285. * Gets the texture coordinates data stored in this target
  97286. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97287. */
  97288. getUVs(): Nullable<FloatArray>;
  97289. /**
  97290. * Clone the current target
  97291. * @returns a new MorphTarget
  97292. */
  97293. clone(): MorphTarget;
  97294. /**
  97295. * Serializes the current target into a Serialization object
  97296. * @returns the serialized object
  97297. */
  97298. serialize(): any;
  97299. /**
  97300. * Returns the string "MorphTarget"
  97301. * @returns "MorphTarget"
  97302. */
  97303. getClassName(): string;
  97304. /**
  97305. * Creates a new target from serialized data
  97306. * @param serializationObject defines the serialized data to use
  97307. * @returns a new MorphTarget
  97308. */
  97309. static Parse(serializationObject: any): MorphTarget;
  97310. /**
  97311. * Creates a MorphTarget from mesh data
  97312. * @param mesh defines the source mesh
  97313. * @param name defines the name to use for the new target
  97314. * @param influence defines the influence to attach to the target
  97315. * @returns a new MorphTarget
  97316. */
  97317. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97318. }
  97319. }
  97320. declare module BABYLON {
  97321. /**
  97322. * This class is used to deform meshes using morphing between different targets
  97323. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97324. */
  97325. export class MorphTargetManager {
  97326. private _targets;
  97327. private _targetInfluenceChangedObservers;
  97328. private _targetDataLayoutChangedObservers;
  97329. private _activeTargets;
  97330. private _scene;
  97331. private _influences;
  97332. private _supportsNormals;
  97333. private _supportsTangents;
  97334. private _supportsUVs;
  97335. private _vertexCount;
  97336. private _uniqueId;
  97337. private _tempInfluences;
  97338. /**
  97339. * Gets or sets a boolean indicating if normals must be morphed
  97340. */
  97341. enableNormalMorphing: boolean;
  97342. /**
  97343. * Gets or sets a boolean indicating if tangents must be morphed
  97344. */
  97345. enableTangentMorphing: boolean;
  97346. /**
  97347. * Gets or sets a boolean indicating if UV must be morphed
  97348. */
  97349. enableUVMorphing: boolean;
  97350. /**
  97351. * Creates a new MorphTargetManager
  97352. * @param scene defines the current scene
  97353. */
  97354. constructor(scene?: Nullable<Scene>);
  97355. /**
  97356. * Gets the unique ID of this manager
  97357. */
  97358. get uniqueId(): number;
  97359. /**
  97360. * Gets the number of vertices handled by this manager
  97361. */
  97362. get vertexCount(): number;
  97363. /**
  97364. * Gets a boolean indicating if this manager supports morphing of normals
  97365. */
  97366. get supportsNormals(): boolean;
  97367. /**
  97368. * Gets a boolean indicating if this manager supports morphing of tangents
  97369. */
  97370. get supportsTangents(): boolean;
  97371. /**
  97372. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97373. */
  97374. get supportsUVs(): boolean;
  97375. /**
  97376. * Gets the number of targets stored in this manager
  97377. */
  97378. get numTargets(): number;
  97379. /**
  97380. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97381. */
  97382. get numInfluencers(): number;
  97383. /**
  97384. * Gets the list of influences (one per target)
  97385. */
  97386. get influences(): Float32Array;
  97387. /**
  97388. * Gets the active target at specified index. An active target is a target with an influence > 0
  97389. * @param index defines the index to check
  97390. * @returns the requested target
  97391. */
  97392. getActiveTarget(index: number): MorphTarget;
  97393. /**
  97394. * Gets the target at specified index
  97395. * @param index defines the index to check
  97396. * @returns the requested target
  97397. */
  97398. getTarget(index: number): MorphTarget;
  97399. /**
  97400. * Add a new target to this manager
  97401. * @param target defines the target to add
  97402. */
  97403. addTarget(target: MorphTarget): void;
  97404. /**
  97405. * Removes a target from the manager
  97406. * @param target defines the target to remove
  97407. */
  97408. removeTarget(target: MorphTarget): void;
  97409. /**
  97410. * Clone the current manager
  97411. * @returns a new MorphTargetManager
  97412. */
  97413. clone(): MorphTargetManager;
  97414. /**
  97415. * Serializes the current manager into a Serialization object
  97416. * @returns the serialized object
  97417. */
  97418. serialize(): any;
  97419. private _syncActiveTargets;
  97420. /**
  97421. * Syncrhonize the targets with all the meshes using this morph target manager
  97422. */
  97423. synchronize(): void;
  97424. /**
  97425. * Creates a new MorphTargetManager from serialized data
  97426. * @param serializationObject defines the serialized data
  97427. * @param scene defines the hosting scene
  97428. * @returns the new MorphTargetManager
  97429. */
  97430. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97431. }
  97432. }
  97433. declare module BABYLON {
  97434. /**
  97435. * Class used to represent a specific level of detail of a mesh
  97436. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97437. */
  97438. export class MeshLODLevel {
  97439. /** Defines the distance where this level should start being displayed */
  97440. distance: number;
  97441. /** Defines the mesh to use to render this level */
  97442. mesh: Nullable<Mesh>;
  97443. /**
  97444. * Creates a new LOD level
  97445. * @param distance defines the distance where this level should star being displayed
  97446. * @param mesh defines the mesh to use to render this level
  97447. */
  97448. constructor(
  97449. /** Defines the distance where this level should start being displayed */
  97450. distance: number,
  97451. /** Defines the mesh to use to render this level */
  97452. mesh: Nullable<Mesh>);
  97453. }
  97454. }
  97455. declare module BABYLON {
  97456. /**
  97457. * Mesh representing the gorund
  97458. */
  97459. export class GroundMesh extends Mesh {
  97460. /** If octree should be generated */
  97461. generateOctree: boolean;
  97462. private _heightQuads;
  97463. /** @hidden */
  97464. _subdivisionsX: number;
  97465. /** @hidden */
  97466. _subdivisionsY: number;
  97467. /** @hidden */
  97468. _width: number;
  97469. /** @hidden */
  97470. _height: number;
  97471. /** @hidden */
  97472. _minX: number;
  97473. /** @hidden */
  97474. _maxX: number;
  97475. /** @hidden */
  97476. _minZ: number;
  97477. /** @hidden */
  97478. _maxZ: number;
  97479. constructor(name: string, scene: Scene);
  97480. /**
  97481. * "GroundMesh"
  97482. * @returns "GroundMesh"
  97483. */
  97484. getClassName(): string;
  97485. /**
  97486. * The minimum of x and y subdivisions
  97487. */
  97488. get subdivisions(): number;
  97489. /**
  97490. * X subdivisions
  97491. */
  97492. get subdivisionsX(): number;
  97493. /**
  97494. * Y subdivisions
  97495. */
  97496. get subdivisionsY(): number;
  97497. /**
  97498. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97499. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97500. * @param chunksCount the number of subdivisions for x and y
  97501. * @param octreeBlocksSize (Default: 32)
  97502. */
  97503. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97504. /**
  97505. * Returns a height (y) value in the Worl system :
  97506. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97507. * @param x x coordinate
  97508. * @param z z coordinate
  97509. * @returns the ground y position if (x, z) are outside the ground surface.
  97510. */
  97511. getHeightAtCoordinates(x: number, z: number): number;
  97512. /**
  97513. * Returns a normalized vector (Vector3) orthogonal to the ground
  97514. * at the ground coordinates (x, z) expressed in the World system.
  97515. * @param x x coordinate
  97516. * @param z z coordinate
  97517. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97518. */
  97519. getNormalAtCoordinates(x: number, z: number): Vector3;
  97520. /**
  97521. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97522. * at the ground coordinates (x, z) expressed in the World system.
  97523. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97524. * @param x x coordinate
  97525. * @param z z coordinate
  97526. * @param ref vector to store the result
  97527. * @returns the GroundMesh.
  97528. */
  97529. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97530. /**
  97531. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97532. * if the ground has been updated.
  97533. * This can be used in the render loop.
  97534. * @returns the GroundMesh.
  97535. */
  97536. updateCoordinateHeights(): GroundMesh;
  97537. private _getFacetAt;
  97538. private _initHeightQuads;
  97539. private _computeHeightQuads;
  97540. /**
  97541. * Serializes this ground mesh
  97542. * @param serializationObject object to write serialization to
  97543. */
  97544. serialize(serializationObject: any): void;
  97545. /**
  97546. * Parses a serialized ground mesh
  97547. * @param parsedMesh the serialized mesh
  97548. * @param scene the scene to create the ground mesh in
  97549. * @returns the created ground mesh
  97550. */
  97551. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97552. }
  97553. }
  97554. declare module BABYLON {
  97555. /**
  97556. * Interface for Physics-Joint data
  97557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97558. */
  97559. export interface PhysicsJointData {
  97560. /**
  97561. * The main pivot of the joint
  97562. */
  97563. mainPivot?: Vector3;
  97564. /**
  97565. * The connected pivot of the joint
  97566. */
  97567. connectedPivot?: Vector3;
  97568. /**
  97569. * The main axis of the joint
  97570. */
  97571. mainAxis?: Vector3;
  97572. /**
  97573. * The connected axis of the joint
  97574. */
  97575. connectedAxis?: Vector3;
  97576. /**
  97577. * The collision of the joint
  97578. */
  97579. collision?: boolean;
  97580. /**
  97581. * Native Oimo/Cannon/Energy data
  97582. */
  97583. nativeParams?: any;
  97584. }
  97585. /**
  97586. * This is a holder class for the physics joint created by the physics plugin
  97587. * It holds a set of functions to control the underlying joint
  97588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97589. */
  97590. export class PhysicsJoint {
  97591. /**
  97592. * The type of the physics joint
  97593. */
  97594. type: number;
  97595. /**
  97596. * The data for the physics joint
  97597. */
  97598. jointData: PhysicsJointData;
  97599. private _physicsJoint;
  97600. protected _physicsPlugin: IPhysicsEnginePlugin;
  97601. /**
  97602. * Initializes the physics joint
  97603. * @param type The type of the physics joint
  97604. * @param jointData The data for the physics joint
  97605. */
  97606. constructor(
  97607. /**
  97608. * The type of the physics joint
  97609. */
  97610. type: number,
  97611. /**
  97612. * The data for the physics joint
  97613. */
  97614. jointData: PhysicsJointData);
  97615. /**
  97616. * Gets the physics joint
  97617. */
  97618. get physicsJoint(): any;
  97619. /**
  97620. * Sets the physics joint
  97621. */
  97622. set physicsJoint(newJoint: any);
  97623. /**
  97624. * Sets the physics plugin
  97625. */
  97626. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97627. /**
  97628. * Execute a function that is physics-plugin specific.
  97629. * @param {Function} func the function that will be executed.
  97630. * It accepts two parameters: the physics world and the physics joint
  97631. */
  97632. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97633. /**
  97634. * Distance-Joint type
  97635. */
  97636. static DistanceJoint: number;
  97637. /**
  97638. * Hinge-Joint type
  97639. */
  97640. static HingeJoint: number;
  97641. /**
  97642. * Ball-and-Socket joint type
  97643. */
  97644. static BallAndSocketJoint: number;
  97645. /**
  97646. * Wheel-Joint type
  97647. */
  97648. static WheelJoint: number;
  97649. /**
  97650. * Slider-Joint type
  97651. */
  97652. static SliderJoint: number;
  97653. /**
  97654. * Prismatic-Joint type
  97655. */
  97656. static PrismaticJoint: number;
  97657. /**
  97658. * Universal-Joint type
  97659. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97660. */
  97661. static UniversalJoint: number;
  97662. /**
  97663. * Hinge-Joint 2 type
  97664. */
  97665. static Hinge2Joint: number;
  97666. /**
  97667. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97668. */
  97669. static PointToPointJoint: number;
  97670. /**
  97671. * Spring-Joint type
  97672. */
  97673. static SpringJoint: number;
  97674. /**
  97675. * Lock-Joint type
  97676. */
  97677. static LockJoint: number;
  97678. }
  97679. /**
  97680. * A class representing a physics distance joint
  97681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97682. */
  97683. export class DistanceJoint extends PhysicsJoint {
  97684. /**
  97685. *
  97686. * @param jointData The data for the Distance-Joint
  97687. */
  97688. constructor(jointData: DistanceJointData);
  97689. /**
  97690. * Update the predefined distance.
  97691. * @param maxDistance The maximum preferred distance
  97692. * @param minDistance The minimum preferred distance
  97693. */
  97694. updateDistance(maxDistance: number, minDistance?: number): void;
  97695. }
  97696. /**
  97697. * Represents a Motor-Enabled Joint
  97698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97699. */
  97700. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97701. /**
  97702. * Initializes the Motor-Enabled Joint
  97703. * @param type The type of the joint
  97704. * @param jointData The physica joint data for the joint
  97705. */
  97706. constructor(type: number, jointData: PhysicsJointData);
  97707. /**
  97708. * Set the motor values.
  97709. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97710. * @param force the force to apply
  97711. * @param maxForce max force for this motor.
  97712. */
  97713. setMotor(force?: number, maxForce?: number): void;
  97714. /**
  97715. * Set the motor's limits.
  97716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97717. * @param upperLimit The upper limit of the motor
  97718. * @param lowerLimit The lower limit of the motor
  97719. */
  97720. setLimit(upperLimit: number, lowerLimit?: number): void;
  97721. }
  97722. /**
  97723. * This class represents a single physics Hinge-Joint
  97724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97725. */
  97726. export class HingeJoint extends MotorEnabledJoint {
  97727. /**
  97728. * Initializes the Hinge-Joint
  97729. * @param jointData The joint data for the Hinge-Joint
  97730. */
  97731. constructor(jointData: PhysicsJointData);
  97732. /**
  97733. * Set the motor values.
  97734. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97735. * @param {number} force the force to apply
  97736. * @param {number} maxForce max force for this motor.
  97737. */
  97738. setMotor(force?: number, maxForce?: number): void;
  97739. /**
  97740. * Set the motor's limits.
  97741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97742. * @param upperLimit The upper limit of the motor
  97743. * @param lowerLimit The lower limit of the motor
  97744. */
  97745. setLimit(upperLimit: number, lowerLimit?: number): void;
  97746. }
  97747. /**
  97748. * This class represents a dual hinge physics joint (same as wheel joint)
  97749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97750. */
  97751. export class Hinge2Joint extends MotorEnabledJoint {
  97752. /**
  97753. * Initializes the Hinge2-Joint
  97754. * @param jointData The joint data for the Hinge2-Joint
  97755. */
  97756. constructor(jointData: PhysicsJointData);
  97757. /**
  97758. * Set the motor values.
  97759. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97760. * @param {number} targetSpeed the speed the motor is to reach
  97761. * @param {number} maxForce max force for this motor.
  97762. * @param {motorIndex} the motor's index, 0 or 1.
  97763. */
  97764. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97765. /**
  97766. * Set the motor limits.
  97767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97768. * @param {number} upperLimit the upper limit
  97769. * @param {number} lowerLimit lower limit
  97770. * @param {motorIndex} the motor's index, 0 or 1.
  97771. */
  97772. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97773. }
  97774. /**
  97775. * Interface for a motor enabled joint
  97776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97777. */
  97778. export interface IMotorEnabledJoint {
  97779. /**
  97780. * Physics joint
  97781. */
  97782. physicsJoint: any;
  97783. /**
  97784. * Sets the motor of the motor-enabled joint
  97785. * @param force The force of the motor
  97786. * @param maxForce The maximum force of the motor
  97787. * @param motorIndex The index of the motor
  97788. */
  97789. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97790. /**
  97791. * Sets the limit of the motor
  97792. * @param upperLimit The upper limit of the motor
  97793. * @param lowerLimit The lower limit of the motor
  97794. * @param motorIndex The index of the motor
  97795. */
  97796. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97797. }
  97798. /**
  97799. * Joint data for a Distance-Joint
  97800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97801. */
  97802. export interface DistanceJointData extends PhysicsJointData {
  97803. /**
  97804. * Max distance the 2 joint objects can be apart
  97805. */
  97806. maxDistance: number;
  97807. }
  97808. /**
  97809. * Joint data from a spring joint
  97810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97811. */
  97812. export interface SpringJointData extends PhysicsJointData {
  97813. /**
  97814. * Length of the spring
  97815. */
  97816. length: number;
  97817. /**
  97818. * Stiffness of the spring
  97819. */
  97820. stiffness: number;
  97821. /**
  97822. * Damping of the spring
  97823. */
  97824. damping: number;
  97825. /** this callback will be called when applying the force to the impostors. */
  97826. forceApplicationCallback: () => void;
  97827. }
  97828. }
  97829. declare module BABYLON {
  97830. /**
  97831. * Holds the data for the raycast result
  97832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97833. */
  97834. export class PhysicsRaycastResult {
  97835. private _hasHit;
  97836. private _hitDistance;
  97837. private _hitNormalWorld;
  97838. private _hitPointWorld;
  97839. private _rayFromWorld;
  97840. private _rayToWorld;
  97841. /**
  97842. * Gets if there was a hit
  97843. */
  97844. get hasHit(): boolean;
  97845. /**
  97846. * Gets the distance from the hit
  97847. */
  97848. get hitDistance(): number;
  97849. /**
  97850. * Gets the hit normal/direction in the world
  97851. */
  97852. get hitNormalWorld(): Vector3;
  97853. /**
  97854. * Gets the hit point in the world
  97855. */
  97856. get hitPointWorld(): Vector3;
  97857. /**
  97858. * Gets the ray "start point" of the ray in the world
  97859. */
  97860. get rayFromWorld(): Vector3;
  97861. /**
  97862. * Gets the ray "end point" of the ray in the world
  97863. */
  97864. get rayToWorld(): Vector3;
  97865. /**
  97866. * Sets the hit data (normal & point in world space)
  97867. * @param hitNormalWorld defines the normal in world space
  97868. * @param hitPointWorld defines the point in world space
  97869. */
  97870. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97871. /**
  97872. * Sets the distance from the start point to the hit point
  97873. * @param distance
  97874. */
  97875. setHitDistance(distance: number): void;
  97876. /**
  97877. * Calculates the distance manually
  97878. */
  97879. calculateHitDistance(): void;
  97880. /**
  97881. * Resets all the values to default
  97882. * @param from The from point on world space
  97883. * @param to The to point on world space
  97884. */
  97885. reset(from?: Vector3, to?: Vector3): void;
  97886. }
  97887. /**
  97888. * Interface for the size containing width and height
  97889. */
  97890. interface IXYZ {
  97891. /**
  97892. * X
  97893. */
  97894. x: number;
  97895. /**
  97896. * Y
  97897. */
  97898. y: number;
  97899. /**
  97900. * Z
  97901. */
  97902. z: number;
  97903. }
  97904. }
  97905. declare module BABYLON {
  97906. /**
  97907. * Interface used to describe a physics joint
  97908. */
  97909. export interface PhysicsImpostorJoint {
  97910. /** Defines the main impostor to which the joint is linked */
  97911. mainImpostor: PhysicsImpostor;
  97912. /** Defines the impostor that is connected to the main impostor using this joint */
  97913. connectedImpostor: PhysicsImpostor;
  97914. /** Defines the joint itself */
  97915. joint: PhysicsJoint;
  97916. }
  97917. /** @hidden */
  97918. export interface IPhysicsEnginePlugin {
  97919. world: any;
  97920. name: string;
  97921. setGravity(gravity: Vector3): void;
  97922. setTimeStep(timeStep: number): void;
  97923. getTimeStep(): number;
  97924. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97925. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97926. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97927. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97928. removePhysicsBody(impostor: PhysicsImpostor): void;
  97929. generateJoint(joint: PhysicsImpostorJoint): void;
  97930. removeJoint(joint: PhysicsImpostorJoint): void;
  97931. isSupported(): boolean;
  97932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97934. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97936. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97937. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97938. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97939. getBodyMass(impostor: PhysicsImpostor): number;
  97940. getBodyFriction(impostor: PhysicsImpostor): number;
  97941. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97942. getBodyRestitution(impostor: PhysicsImpostor): number;
  97943. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97944. getBodyPressure?(impostor: PhysicsImpostor): number;
  97945. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97946. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97947. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97948. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97949. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97950. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97951. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97952. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97953. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97954. sleepBody(impostor: PhysicsImpostor): void;
  97955. wakeUpBody(impostor: PhysicsImpostor): void;
  97956. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97957. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97958. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97959. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97960. getRadius(impostor: PhysicsImpostor): number;
  97961. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97962. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97963. dispose(): void;
  97964. }
  97965. /**
  97966. * Interface used to define a physics engine
  97967. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97968. */
  97969. export interface IPhysicsEngine {
  97970. /**
  97971. * Gets the gravity vector used by the simulation
  97972. */
  97973. gravity: Vector3;
  97974. /**
  97975. * Sets the gravity vector used by the simulation
  97976. * @param gravity defines the gravity vector to use
  97977. */
  97978. setGravity(gravity: Vector3): void;
  97979. /**
  97980. * Set the time step of the physics engine.
  97981. * Default is 1/60.
  97982. * To slow it down, enter 1/600 for example.
  97983. * To speed it up, 1/30
  97984. * @param newTimeStep the new timestep to apply to this world.
  97985. */
  97986. setTimeStep(newTimeStep: number): void;
  97987. /**
  97988. * Get the time step of the physics engine.
  97989. * @returns the current time step
  97990. */
  97991. getTimeStep(): number;
  97992. /**
  97993. * Set the sub time step of the physics engine.
  97994. * Default is 0 meaning there is no sub steps
  97995. * To increase physics resolution precision, set a small value (like 1 ms)
  97996. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97997. */
  97998. setSubTimeStep(subTimeStep: number): void;
  97999. /**
  98000. * Get the sub time step of the physics engine.
  98001. * @returns the current sub time step
  98002. */
  98003. getSubTimeStep(): number;
  98004. /**
  98005. * Release all resources
  98006. */
  98007. dispose(): void;
  98008. /**
  98009. * Gets the name of the current physics plugin
  98010. * @returns the name of the plugin
  98011. */
  98012. getPhysicsPluginName(): string;
  98013. /**
  98014. * Adding a new impostor for the impostor tracking.
  98015. * This will be done by the impostor itself.
  98016. * @param impostor the impostor to add
  98017. */
  98018. addImpostor(impostor: PhysicsImpostor): void;
  98019. /**
  98020. * Remove an impostor from the engine.
  98021. * This impostor and its mesh will not longer be updated by the physics engine.
  98022. * @param impostor the impostor to remove
  98023. */
  98024. removeImpostor(impostor: PhysicsImpostor): void;
  98025. /**
  98026. * Add a joint to the physics engine
  98027. * @param mainImpostor defines the main impostor to which the joint is added.
  98028. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98029. * @param joint defines the joint that will connect both impostors.
  98030. */
  98031. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98032. /**
  98033. * Removes a joint from the simulation
  98034. * @param mainImpostor defines the impostor used with the joint
  98035. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98036. * @param joint defines the joint to remove
  98037. */
  98038. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98039. /**
  98040. * Gets the current plugin used to run the simulation
  98041. * @returns current plugin
  98042. */
  98043. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98044. /**
  98045. * Gets the list of physic impostors
  98046. * @returns an array of PhysicsImpostor
  98047. */
  98048. getImpostors(): Array<PhysicsImpostor>;
  98049. /**
  98050. * Gets the impostor for a physics enabled object
  98051. * @param object defines the object impersonated by the impostor
  98052. * @returns the PhysicsImpostor or null if not found
  98053. */
  98054. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98055. /**
  98056. * Gets the impostor for a physics body object
  98057. * @param body defines physics body used by the impostor
  98058. * @returns the PhysicsImpostor or null if not found
  98059. */
  98060. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98061. /**
  98062. * Does a raycast in the physics world
  98063. * @param from when should the ray start?
  98064. * @param to when should the ray end?
  98065. * @returns PhysicsRaycastResult
  98066. */
  98067. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98068. /**
  98069. * Called by the scene. No need to call it.
  98070. * @param delta defines the timespam between frames
  98071. */
  98072. _step(delta: number): void;
  98073. }
  98074. }
  98075. declare module BABYLON {
  98076. /**
  98077. * The interface for the physics imposter parameters
  98078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98079. */
  98080. export interface PhysicsImpostorParameters {
  98081. /**
  98082. * The mass of the physics imposter
  98083. */
  98084. mass: number;
  98085. /**
  98086. * The friction of the physics imposter
  98087. */
  98088. friction?: number;
  98089. /**
  98090. * The coefficient of restitution of the physics imposter
  98091. */
  98092. restitution?: number;
  98093. /**
  98094. * The native options of the physics imposter
  98095. */
  98096. nativeOptions?: any;
  98097. /**
  98098. * Specifies if the parent should be ignored
  98099. */
  98100. ignoreParent?: boolean;
  98101. /**
  98102. * Specifies if bi-directional transformations should be disabled
  98103. */
  98104. disableBidirectionalTransformation?: boolean;
  98105. /**
  98106. * The pressure inside the physics imposter, soft object only
  98107. */
  98108. pressure?: number;
  98109. /**
  98110. * The stiffness the physics imposter, soft object only
  98111. */
  98112. stiffness?: number;
  98113. /**
  98114. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98115. */
  98116. velocityIterations?: number;
  98117. /**
  98118. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98119. */
  98120. positionIterations?: number;
  98121. /**
  98122. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98123. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98124. * Add to fix multiple points
  98125. */
  98126. fixedPoints?: number;
  98127. /**
  98128. * The collision margin around a soft object
  98129. */
  98130. margin?: number;
  98131. /**
  98132. * The collision margin around a soft object
  98133. */
  98134. damping?: number;
  98135. /**
  98136. * The path for a rope based on an extrusion
  98137. */
  98138. path?: any;
  98139. /**
  98140. * The shape of an extrusion used for a rope based on an extrusion
  98141. */
  98142. shape?: any;
  98143. }
  98144. /**
  98145. * Interface for a physics-enabled object
  98146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98147. */
  98148. export interface IPhysicsEnabledObject {
  98149. /**
  98150. * The position of the physics-enabled object
  98151. */
  98152. position: Vector3;
  98153. /**
  98154. * The rotation of the physics-enabled object
  98155. */
  98156. rotationQuaternion: Nullable<Quaternion>;
  98157. /**
  98158. * The scale of the physics-enabled object
  98159. */
  98160. scaling: Vector3;
  98161. /**
  98162. * The rotation of the physics-enabled object
  98163. */
  98164. rotation?: Vector3;
  98165. /**
  98166. * The parent of the physics-enabled object
  98167. */
  98168. parent?: any;
  98169. /**
  98170. * The bounding info of the physics-enabled object
  98171. * @returns The bounding info of the physics-enabled object
  98172. */
  98173. getBoundingInfo(): BoundingInfo;
  98174. /**
  98175. * Computes the world matrix
  98176. * @param force Specifies if the world matrix should be computed by force
  98177. * @returns A world matrix
  98178. */
  98179. computeWorldMatrix(force: boolean): Matrix;
  98180. /**
  98181. * Gets the world matrix
  98182. * @returns A world matrix
  98183. */
  98184. getWorldMatrix?(): Matrix;
  98185. /**
  98186. * Gets the child meshes
  98187. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98188. * @returns An array of abstract meshes
  98189. */
  98190. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98191. /**
  98192. * Gets the vertex data
  98193. * @param kind The type of vertex data
  98194. * @returns A nullable array of numbers, or a float32 array
  98195. */
  98196. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98197. /**
  98198. * Gets the indices from the mesh
  98199. * @returns A nullable array of index arrays
  98200. */
  98201. getIndices?(): Nullable<IndicesArray>;
  98202. /**
  98203. * Gets the scene from the mesh
  98204. * @returns the indices array or null
  98205. */
  98206. getScene?(): Scene;
  98207. /**
  98208. * Gets the absolute position from the mesh
  98209. * @returns the absolute position
  98210. */
  98211. getAbsolutePosition(): Vector3;
  98212. /**
  98213. * Gets the absolute pivot point from the mesh
  98214. * @returns the absolute pivot point
  98215. */
  98216. getAbsolutePivotPoint(): Vector3;
  98217. /**
  98218. * Rotates the mesh
  98219. * @param axis The axis of rotation
  98220. * @param amount The amount of rotation
  98221. * @param space The space of the rotation
  98222. * @returns The rotation transform node
  98223. */
  98224. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98225. /**
  98226. * Translates the mesh
  98227. * @param axis The axis of translation
  98228. * @param distance The distance of translation
  98229. * @param space The space of the translation
  98230. * @returns The transform node
  98231. */
  98232. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98233. /**
  98234. * Sets the absolute position of the mesh
  98235. * @param absolutePosition The absolute position of the mesh
  98236. * @returns The transform node
  98237. */
  98238. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98239. /**
  98240. * Gets the class name of the mesh
  98241. * @returns The class name
  98242. */
  98243. getClassName(): string;
  98244. }
  98245. /**
  98246. * Represents a physics imposter
  98247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98248. */
  98249. export class PhysicsImpostor {
  98250. /**
  98251. * The physics-enabled object used as the physics imposter
  98252. */
  98253. object: IPhysicsEnabledObject;
  98254. /**
  98255. * The type of the physics imposter
  98256. */
  98257. type: number;
  98258. private _options;
  98259. private _scene?;
  98260. /**
  98261. * The default object size of the imposter
  98262. */
  98263. static DEFAULT_OBJECT_SIZE: Vector3;
  98264. /**
  98265. * The identity quaternion of the imposter
  98266. */
  98267. static IDENTITY_QUATERNION: Quaternion;
  98268. /** @hidden */
  98269. _pluginData: any;
  98270. private _physicsEngine;
  98271. private _physicsBody;
  98272. private _bodyUpdateRequired;
  98273. private _onBeforePhysicsStepCallbacks;
  98274. private _onAfterPhysicsStepCallbacks;
  98275. /** @hidden */
  98276. _onPhysicsCollideCallbacks: Array<{
  98277. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98278. otherImpostors: Array<PhysicsImpostor>;
  98279. }>;
  98280. private _deltaPosition;
  98281. private _deltaRotation;
  98282. private _deltaRotationConjugated;
  98283. /** @hidden */
  98284. _isFromLine: boolean;
  98285. private _parent;
  98286. private _isDisposed;
  98287. private static _tmpVecs;
  98288. private static _tmpQuat;
  98289. /**
  98290. * Specifies if the physics imposter is disposed
  98291. */
  98292. get isDisposed(): boolean;
  98293. /**
  98294. * Gets the mass of the physics imposter
  98295. */
  98296. get mass(): number;
  98297. set mass(value: number);
  98298. /**
  98299. * Gets the coefficient of friction
  98300. */
  98301. get friction(): number;
  98302. /**
  98303. * Sets the coefficient of friction
  98304. */
  98305. set friction(value: number);
  98306. /**
  98307. * Gets the coefficient of restitution
  98308. */
  98309. get restitution(): number;
  98310. /**
  98311. * Sets the coefficient of restitution
  98312. */
  98313. set restitution(value: number);
  98314. /**
  98315. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98316. */
  98317. get pressure(): number;
  98318. /**
  98319. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98320. */
  98321. set pressure(value: number);
  98322. /**
  98323. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98324. */
  98325. get stiffness(): number;
  98326. /**
  98327. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98328. */
  98329. set stiffness(value: number);
  98330. /**
  98331. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98332. */
  98333. get velocityIterations(): number;
  98334. /**
  98335. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98336. */
  98337. set velocityIterations(value: number);
  98338. /**
  98339. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98340. */
  98341. get positionIterations(): number;
  98342. /**
  98343. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98344. */
  98345. set positionIterations(value: number);
  98346. /**
  98347. * The unique id of the physics imposter
  98348. * set by the physics engine when adding this impostor to the array
  98349. */
  98350. uniqueId: number;
  98351. /**
  98352. * @hidden
  98353. */
  98354. soft: boolean;
  98355. /**
  98356. * @hidden
  98357. */
  98358. segments: number;
  98359. private _joints;
  98360. /**
  98361. * Initializes the physics imposter
  98362. * @param object The physics-enabled object used as the physics imposter
  98363. * @param type The type of the physics imposter
  98364. * @param _options The options for the physics imposter
  98365. * @param _scene The Babylon scene
  98366. */
  98367. constructor(
  98368. /**
  98369. * The physics-enabled object used as the physics imposter
  98370. */
  98371. object: IPhysicsEnabledObject,
  98372. /**
  98373. * The type of the physics imposter
  98374. */
  98375. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98376. /**
  98377. * This function will completly initialize this impostor.
  98378. * It will create a new body - but only if this mesh has no parent.
  98379. * If it has, this impostor will not be used other than to define the impostor
  98380. * of the child mesh.
  98381. * @hidden
  98382. */
  98383. _init(): void;
  98384. private _getPhysicsParent;
  98385. /**
  98386. * Should a new body be generated.
  98387. * @returns boolean specifying if body initialization is required
  98388. */
  98389. isBodyInitRequired(): boolean;
  98390. /**
  98391. * Sets the updated scaling
  98392. * @param updated Specifies if the scaling is updated
  98393. */
  98394. setScalingUpdated(): void;
  98395. /**
  98396. * Force a regeneration of this or the parent's impostor's body.
  98397. * Use under cautious - This will remove all joints already implemented.
  98398. */
  98399. forceUpdate(): void;
  98400. /**
  98401. * Gets the body that holds this impostor. Either its own, or its parent.
  98402. */
  98403. get physicsBody(): any;
  98404. /**
  98405. * Get the parent of the physics imposter
  98406. * @returns Physics imposter or null
  98407. */
  98408. get parent(): Nullable<PhysicsImpostor>;
  98409. /**
  98410. * Sets the parent of the physics imposter
  98411. */
  98412. set parent(value: Nullable<PhysicsImpostor>);
  98413. /**
  98414. * Set the physics body. Used mainly by the physics engine/plugin
  98415. */
  98416. set physicsBody(physicsBody: any);
  98417. /**
  98418. * Resets the update flags
  98419. */
  98420. resetUpdateFlags(): void;
  98421. /**
  98422. * Gets the object extend size
  98423. * @returns the object extend size
  98424. */
  98425. getObjectExtendSize(): Vector3;
  98426. /**
  98427. * Gets the object center
  98428. * @returns The object center
  98429. */
  98430. getObjectCenter(): Vector3;
  98431. /**
  98432. * Get a specific parameter from the options parameters
  98433. * @param paramName The object parameter name
  98434. * @returns The object parameter
  98435. */
  98436. getParam(paramName: string): any;
  98437. /**
  98438. * Sets a specific parameter in the options given to the physics plugin
  98439. * @param paramName The parameter name
  98440. * @param value The value of the parameter
  98441. */
  98442. setParam(paramName: string, value: number): void;
  98443. /**
  98444. * Specifically change the body's mass option. Won't recreate the physics body object
  98445. * @param mass The mass of the physics imposter
  98446. */
  98447. setMass(mass: number): void;
  98448. /**
  98449. * Gets the linear velocity
  98450. * @returns linear velocity or null
  98451. */
  98452. getLinearVelocity(): Nullable<Vector3>;
  98453. /**
  98454. * Sets the linear velocity
  98455. * @param velocity linear velocity or null
  98456. */
  98457. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98458. /**
  98459. * Gets the angular velocity
  98460. * @returns angular velocity or null
  98461. */
  98462. getAngularVelocity(): Nullable<Vector3>;
  98463. /**
  98464. * Sets the angular velocity
  98465. * @param velocity The velocity or null
  98466. */
  98467. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98468. /**
  98469. * Execute a function with the physics plugin native code
  98470. * Provide a function the will have two variables - the world object and the physics body object
  98471. * @param func The function to execute with the physics plugin native code
  98472. */
  98473. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98474. /**
  98475. * Register a function that will be executed before the physics world is stepping forward
  98476. * @param func The function to execute before the physics world is stepped forward
  98477. */
  98478. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98479. /**
  98480. * Unregister a function that will be executed before the physics world is stepping forward
  98481. * @param func The function to execute before the physics world is stepped forward
  98482. */
  98483. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98484. /**
  98485. * Register a function that will be executed after the physics step
  98486. * @param func The function to execute after physics step
  98487. */
  98488. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98489. /**
  98490. * Unregisters a function that will be executed after the physics step
  98491. * @param func The function to execute after physics step
  98492. */
  98493. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98494. /**
  98495. * register a function that will be executed when this impostor collides against a different body
  98496. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98497. * @param func Callback that is executed on collision
  98498. */
  98499. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98500. /**
  98501. * Unregisters the physics imposter on contact
  98502. * @param collideAgainst The physics object to collide against
  98503. * @param func Callback to execute on collision
  98504. */
  98505. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98506. private _tmpQuat;
  98507. private _tmpQuat2;
  98508. /**
  98509. * Get the parent rotation
  98510. * @returns The parent rotation
  98511. */
  98512. getParentsRotation(): Quaternion;
  98513. /**
  98514. * this function is executed by the physics engine.
  98515. */
  98516. beforeStep: () => void;
  98517. /**
  98518. * this function is executed by the physics engine
  98519. */
  98520. afterStep: () => void;
  98521. /**
  98522. * Legacy collision detection event support
  98523. */
  98524. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98525. /**
  98526. * event and body object due to cannon's event-based architecture.
  98527. */
  98528. onCollide: (e: {
  98529. body: any;
  98530. }) => void;
  98531. /**
  98532. * Apply a force
  98533. * @param force The force to apply
  98534. * @param contactPoint The contact point for the force
  98535. * @returns The physics imposter
  98536. */
  98537. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98538. /**
  98539. * Apply an impulse
  98540. * @param force The impulse force
  98541. * @param contactPoint The contact point for the impulse force
  98542. * @returns The physics imposter
  98543. */
  98544. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98545. /**
  98546. * A help function to create a joint
  98547. * @param otherImpostor A physics imposter used to create a joint
  98548. * @param jointType The type of joint
  98549. * @param jointData The data for the joint
  98550. * @returns The physics imposter
  98551. */
  98552. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98553. /**
  98554. * Add a joint to this impostor with a different impostor
  98555. * @param otherImpostor A physics imposter used to add a joint
  98556. * @param joint The joint to add
  98557. * @returns The physics imposter
  98558. */
  98559. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98560. /**
  98561. * Add an anchor to a cloth impostor
  98562. * @param otherImpostor rigid impostor to anchor to
  98563. * @param width ratio across width from 0 to 1
  98564. * @param height ratio up height from 0 to 1
  98565. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98566. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98567. * @returns impostor the soft imposter
  98568. */
  98569. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98570. /**
  98571. * Add a hook to a rope impostor
  98572. * @param otherImpostor rigid impostor to anchor to
  98573. * @param length ratio across rope from 0 to 1
  98574. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98575. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98576. * @returns impostor the rope imposter
  98577. */
  98578. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98579. /**
  98580. * Will keep this body still, in a sleep mode.
  98581. * @returns the physics imposter
  98582. */
  98583. sleep(): PhysicsImpostor;
  98584. /**
  98585. * Wake the body up.
  98586. * @returns The physics imposter
  98587. */
  98588. wakeUp(): PhysicsImpostor;
  98589. /**
  98590. * Clones the physics imposter
  98591. * @param newObject The physics imposter clones to this physics-enabled object
  98592. * @returns A nullable physics imposter
  98593. */
  98594. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98595. /**
  98596. * Disposes the physics imposter
  98597. */
  98598. dispose(): void;
  98599. /**
  98600. * Sets the delta position
  98601. * @param position The delta position amount
  98602. */
  98603. setDeltaPosition(position: Vector3): void;
  98604. /**
  98605. * Sets the delta rotation
  98606. * @param rotation The delta rotation amount
  98607. */
  98608. setDeltaRotation(rotation: Quaternion): void;
  98609. /**
  98610. * Gets the box size of the physics imposter and stores the result in the input parameter
  98611. * @param result Stores the box size
  98612. * @returns The physics imposter
  98613. */
  98614. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98615. /**
  98616. * Gets the radius of the physics imposter
  98617. * @returns Radius of the physics imposter
  98618. */
  98619. getRadius(): number;
  98620. /**
  98621. * Sync a bone with this impostor
  98622. * @param bone The bone to sync to the impostor.
  98623. * @param boneMesh The mesh that the bone is influencing.
  98624. * @param jointPivot The pivot of the joint / bone in local space.
  98625. * @param distToJoint Optional distance from the impostor to the joint.
  98626. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98627. */
  98628. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98629. /**
  98630. * Sync impostor to a bone
  98631. * @param bone The bone that the impostor will be synced to.
  98632. * @param boneMesh The mesh that the bone is influencing.
  98633. * @param jointPivot The pivot of the joint / bone in local space.
  98634. * @param distToJoint Optional distance from the impostor to the joint.
  98635. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98636. * @param boneAxis Optional vector3 axis the bone is aligned with
  98637. */
  98638. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98639. /**
  98640. * No-Imposter type
  98641. */
  98642. static NoImpostor: number;
  98643. /**
  98644. * Sphere-Imposter type
  98645. */
  98646. static SphereImpostor: number;
  98647. /**
  98648. * Box-Imposter type
  98649. */
  98650. static BoxImpostor: number;
  98651. /**
  98652. * Plane-Imposter type
  98653. */
  98654. static PlaneImpostor: number;
  98655. /**
  98656. * Mesh-imposter type
  98657. */
  98658. static MeshImpostor: number;
  98659. /**
  98660. * Capsule-Impostor type (Ammo.js plugin only)
  98661. */
  98662. static CapsuleImpostor: number;
  98663. /**
  98664. * Cylinder-Imposter type
  98665. */
  98666. static CylinderImpostor: number;
  98667. /**
  98668. * Particle-Imposter type
  98669. */
  98670. static ParticleImpostor: number;
  98671. /**
  98672. * Heightmap-Imposter type
  98673. */
  98674. static HeightmapImpostor: number;
  98675. /**
  98676. * ConvexHull-Impostor type (Ammo.js plugin only)
  98677. */
  98678. static ConvexHullImpostor: number;
  98679. /**
  98680. * Custom-Imposter type (Ammo.js plugin only)
  98681. */
  98682. static CustomImpostor: number;
  98683. /**
  98684. * Rope-Imposter type
  98685. */
  98686. static RopeImpostor: number;
  98687. /**
  98688. * Cloth-Imposter type
  98689. */
  98690. static ClothImpostor: number;
  98691. /**
  98692. * Softbody-Imposter type
  98693. */
  98694. static SoftbodyImpostor: number;
  98695. }
  98696. }
  98697. declare module BABYLON {
  98698. /**
  98699. * @hidden
  98700. **/
  98701. export class _CreationDataStorage {
  98702. closePath?: boolean;
  98703. closeArray?: boolean;
  98704. idx: number[];
  98705. dashSize: number;
  98706. gapSize: number;
  98707. path3D: Path3D;
  98708. pathArray: Vector3[][];
  98709. arc: number;
  98710. radius: number;
  98711. cap: number;
  98712. tessellation: number;
  98713. }
  98714. /**
  98715. * @hidden
  98716. **/
  98717. class _InstanceDataStorage {
  98718. visibleInstances: any;
  98719. batchCache: _InstancesBatch;
  98720. instancesBufferSize: number;
  98721. instancesBuffer: Nullable<Buffer>;
  98722. instancesData: Float32Array;
  98723. overridenInstanceCount: number;
  98724. isFrozen: boolean;
  98725. previousBatch: Nullable<_InstancesBatch>;
  98726. hardwareInstancedRendering: boolean;
  98727. sideOrientation: number;
  98728. manualUpdate: boolean;
  98729. }
  98730. /**
  98731. * @hidden
  98732. **/
  98733. export class _InstancesBatch {
  98734. mustReturn: boolean;
  98735. visibleInstances: Nullable<InstancedMesh[]>[];
  98736. renderSelf: boolean[];
  98737. hardwareInstancedRendering: boolean[];
  98738. }
  98739. /**
  98740. * Class used to represent renderable models
  98741. */
  98742. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98743. /**
  98744. * Mesh side orientation : usually the external or front surface
  98745. */
  98746. static readonly FRONTSIDE: number;
  98747. /**
  98748. * Mesh side orientation : usually the internal or back surface
  98749. */
  98750. static readonly BACKSIDE: number;
  98751. /**
  98752. * Mesh side orientation : both internal and external or front and back surfaces
  98753. */
  98754. static readonly DOUBLESIDE: number;
  98755. /**
  98756. * Mesh side orientation : by default, `FRONTSIDE`
  98757. */
  98758. static readonly DEFAULTSIDE: number;
  98759. /**
  98760. * Mesh cap setting : no cap
  98761. */
  98762. static readonly NO_CAP: number;
  98763. /**
  98764. * Mesh cap setting : one cap at the beginning of the mesh
  98765. */
  98766. static readonly CAP_START: number;
  98767. /**
  98768. * Mesh cap setting : one cap at the end of the mesh
  98769. */
  98770. static readonly CAP_END: number;
  98771. /**
  98772. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98773. */
  98774. static readonly CAP_ALL: number;
  98775. /**
  98776. * Mesh pattern setting : no flip or rotate
  98777. */
  98778. static readonly NO_FLIP: number;
  98779. /**
  98780. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98781. */
  98782. static readonly FLIP_TILE: number;
  98783. /**
  98784. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98785. */
  98786. static readonly ROTATE_TILE: number;
  98787. /**
  98788. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98789. */
  98790. static readonly FLIP_ROW: number;
  98791. /**
  98792. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98793. */
  98794. static readonly ROTATE_ROW: number;
  98795. /**
  98796. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98797. */
  98798. static readonly FLIP_N_ROTATE_TILE: number;
  98799. /**
  98800. * Mesh pattern setting : rotate pattern and rotate
  98801. */
  98802. static readonly FLIP_N_ROTATE_ROW: number;
  98803. /**
  98804. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98805. */
  98806. static readonly CENTER: number;
  98807. /**
  98808. * Mesh tile positioning : part tiles on left
  98809. */
  98810. static readonly LEFT: number;
  98811. /**
  98812. * Mesh tile positioning : part tiles on right
  98813. */
  98814. static readonly RIGHT: number;
  98815. /**
  98816. * Mesh tile positioning : part tiles on top
  98817. */
  98818. static readonly TOP: number;
  98819. /**
  98820. * Mesh tile positioning : part tiles on bottom
  98821. */
  98822. static readonly BOTTOM: number;
  98823. /**
  98824. * Gets the default side orientation.
  98825. * @param orientation the orientation to value to attempt to get
  98826. * @returns the default orientation
  98827. * @hidden
  98828. */
  98829. static _GetDefaultSideOrientation(orientation?: number): number;
  98830. private _internalMeshDataInfo;
  98831. /**
  98832. * An event triggered before rendering the mesh
  98833. */
  98834. get onBeforeRenderObservable(): Observable<Mesh>;
  98835. /**
  98836. * An event triggered before binding the mesh
  98837. */
  98838. get onBeforeBindObservable(): Observable<Mesh>;
  98839. /**
  98840. * An event triggered after rendering the mesh
  98841. */
  98842. get onAfterRenderObservable(): Observable<Mesh>;
  98843. /**
  98844. * An event triggered before drawing the mesh
  98845. */
  98846. get onBeforeDrawObservable(): Observable<Mesh>;
  98847. private _onBeforeDrawObserver;
  98848. /**
  98849. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98850. */
  98851. set onBeforeDraw(callback: () => void);
  98852. get hasInstances(): boolean;
  98853. /**
  98854. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98855. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98856. */
  98857. delayLoadState: number;
  98858. /**
  98859. * Gets the list of instances created from this mesh
  98860. * it is not supposed to be modified manually.
  98861. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98862. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98863. */
  98864. instances: InstancedMesh[];
  98865. /**
  98866. * Gets the file containing delay loading data for this mesh
  98867. */
  98868. delayLoadingFile: string;
  98869. /** @hidden */
  98870. _binaryInfo: any;
  98871. /**
  98872. * User defined function used to change how LOD level selection is done
  98873. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98874. */
  98875. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98876. /**
  98877. * Gets or sets the morph target manager
  98878. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98879. */
  98880. get morphTargetManager(): Nullable<MorphTargetManager>;
  98881. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98882. /** @hidden */
  98883. _creationDataStorage: Nullable<_CreationDataStorage>;
  98884. /** @hidden */
  98885. _geometry: Nullable<Geometry>;
  98886. /** @hidden */
  98887. _delayInfo: Array<string>;
  98888. /** @hidden */
  98889. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98890. /** @hidden */
  98891. _instanceDataStorage: _InstanceDataStorage;
  98892. private _effectiveMaterial;
  98893. /** @hidden */
  98894. _shouldGenerateFlatShading: boolean;
  98895. /** @hidden */
  98896. _originalBuilderSideOrientation: number;
  98897. /**
  98898. * Use this property to change the original side orientation defined at construction time
  98899. */
  98900. overrideMaterialSideOrientation: Nullable<number>;
  98901. /**
  98902. * Gets the source mesh (the one used to clone this one from)
  98903. */
  98904. get source(): Nullable<Mesh>;
  98905. /**
  98906. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98907. */
  98908. get isUnIndexed(): boolean;
  98909. set isUnIndexed(value: boolean);
  98910. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98911. get worldMatrixInstancedBuffer(): Float32Array;
  98912. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98913. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98914. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98915. /**
  98916. * @constructor
  98917. * @param name The value used by scene.getMeshByName() to do a lookup.
  98918. * @param scene The scene to add this mesh to.
  98919. * @param parent The parent of this mesh, if it has one
  98920. * @param source An optional Mesh from which geometry is shared, cloned.
  98921. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98922. * When false, achieved by calling a clone(), also passing False.
  98923. * This will make creation of children, recursive.
  98924. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98925. */
  98926. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98927. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98928. doNotInstantiate: boolean;
  98929. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98930. /**
  98931. * Gets the class name
  98932. * @returns the string "Mesh".
  98933. */
  98934. getClassName(): string;
  98935. /** @hidden */
  98936. get _isMesh(): boolean;
  98937. /**
  98938. * Returns a description of this mesh
  98939. * @param fullDetails define if full details about this mesh must be used
  98940. * @returns a descriptive string representing this mesh
  98941. */
  98942. toString(fullDetails?: boolean): string;
  98943. /** @hidden */
  98944. _unBindEffect(): void;
  98945. /**
  98946. * Gets a boolean indicating if this mesh has LOD
  98947. */
  98948. get hasLODLevels(): boolean;
  98949. /**
  98950. * Gets the list of MeshLODLevel associated with the current mesh
  98951. * @returns an array of MeshLODLevel
  98952. */
  98953. getLODLevels(): MeshLODLevel[];
  98954. private _sortLODLevels;
  98955. /**
  98956. * Add a mesh as LOD level triggered at the given distance.
  98957. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98958. * @param distance The distance from the center of the object to show this level
  98959. * @param mesh The mesh to be added as LOD level (can be null)
  98960. * @return This mesh (for chaining)
  98961. */
  98962. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98963. /**
  98964. * Returns the LOD level mesh at the passed distance or null if not found.
  98965. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98966. * @param distance The distance from the center of the object to show this level
  98967. * @returns a Mesh or `null`
  98968. */
  98969. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98970. /**
  98971. * Remove a mesh from the LOD array
  98972. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98973. * @param mesh defines the mesh to be removed
  98974. * @return This mesh (for chaining)
  98975. */
  98976. removeLODLevel(mesh: Mesh): Mesh;
  98977. /**
  98978. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98979. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98980. * @param camera defines the camera to use to compute distance
  98981. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98982. * @return This mesh (for chaining)
  98983. */
  98984. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98985. /**
  98986. * Gets the mesh internal Geometry object
  98987. */
  98988. get geometry(): Nullable<Geometry>;
  98989. /**
  98990. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98991. * @returns the total number of vertices
  98992. */
  98993. getTotalVertices(): number;
  98994. /**
  98995. * Returns the content of an associated vertex buffer
  98996. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98997. * - VertexBuffer.PositionKind
  98998. * - VertexBuffer.UVKind
  98999. * - VertexBuffer.UV2Kind
  99000. * - VertexBuffer.UV3Kind
  99001. * - VertexBuffer.UV4Kind
  99002. * - VertexBuffer.UV5Kind
  99003. * - VertexBuffer.UV6Kind
  99004. * - VertexBuffer.ColorKind
  99005. * - VertexBuffer.MatricesIndicesKind
  99006. * - VertexBuffer.MatricesIndicesExtraKind
  99007. * - VertexBuffer.MatricesWeightsKind
  99008. * - VertexBuffer.MatricesWeightsExtraKind
  99009. * @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
  99010. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  99011. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  99012. */
  99013. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  99014. /**
  99015. * Returns the mesh VertexBuffer object from the requested `kind`
  99016. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99017. * - VertexBuffer.PositionKind
  99018. * - VertexBuffer.NormalKind
  99019. * - VertexBuffer.UVKind
  99020. * - VertexBuffer.UV2Kind
  99021. * - VertexBuffer.UV3Kind
  99022. * - VertexBuffer.UV4Kind
  99023. * - VertexBuffer.UV5Kind
  99024. * - VertexBuffer.UV6Kind
  99025. * - VertexBuffer.ColorKind
  99026. * - VertexBuffer.MatricesIndicesKind
  99027. * - VertexBuffer.MatricesIndicesExtraKind
  99028. * - VertexBuffer.MatricesWeightsKind
  99029. * - VertexBuffer.MatricesWeightsExtraKind
  99030. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99031. */
  99032. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99033. /**
  99034. * Tests if a specific vertex buffer is associated with this mesh
  99035. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99036. * - VertexBuffer.PositionKind
  99037. * - VertexBuffer.NormalKind
  99038. * - VertexBuffer.UVKind
  99039. * - VertexBuffer.UV2Kind
  99040. * - VertexBuffer.UV3Kind
  99041. * - VertexBuffer.UV4Kind
  99042. * - VertexBuffer.UV5Kind
  99043. * - VertexBuffer.UV6Kind
  99044. * - VertexBuffer.ColorKind
  99045. * - VertexBuffer.MatricesIndicesKind
  99046. * - VertexBuffer.MatricesIndicesExtraKind
  99047. * - VertexBuffer.MatricesWeightsKind
  99048. * - VertexBuffer.MatricesWeightsExtraKind
  99049. * @returns a boolean
  99050. */
  99051. isVerticesDataPresent(kind: string): boolean;
  99052. /**
  99053. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99054. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99055. * - VertexBuffer.PositionKind
  99056. * - VertexBuffer.UVKind
  99057. * - VertexBuffer.UV2Kind
  99058. * - VertexBuffer.UV3Kind
  99059. * - VertexBuffer.UV4Kind
  99060. * - VertexBuffer.UV5Kind
  99061. * - VertexBuffer.UV6Kind
  99062. * - VertexBuffer.ColorKind
  99063. * - VertexBuffer.MatricesIndicesKind
  99064. * - VertexBuffer.MatricesIndicesExtraKind
  99065. * - VertexBuffer.MatricesWeightsKind
  99066. * - VertexBuffer.MatricesWeightsExtraKind
  99067. * @returns a boolean
  99068. */
  99069. isVertexBufferUpdatable(kind: string): boolean;
  99070. /**
  99071. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99072. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99073. * - VertexBuffer.PositionKind
  99074. * - VertexBuffer.NormalKind
  99075. * - VertexBuffer.UVKind
  99076. * - VertexBuffer.UV2Kind
  99077. * - VertexBuffer.UV3Kind
  99078. * - VertexBuffer.UV4Kind
  99079. * - VertexBuffer.UV5Kind
  99080. * - VertexBuffer.UV6Kind
  99081. * - VertexBuffer.ColorKind
  99082. * - VertexBuffer.MatricesIndicesKind
  99083. * - VertexBuffer.MatricesIndicesExtraKind
  99084. * - VertexBuffer.MatricesWeightsKind
  99085. * - VertexBuffer.MatricesWeightsExtraKind
  99086. * @returns an array of strings
  99087. */
  99088. getVerticesDataKinds(): string[];
  99089. /**
  99090. * Returns a positive integer : the total number of indices in this mesh geometry.
  99091. * @returns the numner of indices or zero if the mesh has no geometry.
  99092. */
  99093. getTotalIndices(): number;
  99094. /**
  99095. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99096. * @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.
  99097. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99098. * @returns the indices array or an empty array if the mesh has no geometry
  99099. */
  99100. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99101. get isBlocked(): boolean;
  99102. /**
  99103. * Determine if the current mesh is ready to be rendered
  99104. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99105. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99106. * @returns true if all associated assets are ready (material, textures, shaders)
  99107. */
  99108. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99109. /**
  99110. * 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.
  99111. */
  99112. get areNormalsFrozen(): boolean;
  99113. /**
  99114. * 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.
  99115. * @returns the current mesh
  99116. */
  99117. freezeNormals(): Mesh;
  99118. /**
  99119. * 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
  99120. * @returns the current mesh
  99121. */
  99122. unfreezeNormals(): Mesh;
  99123. /**
  99124. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99125. */
  99126. set overridenInstanceCount(count: number);
  99127. /** @hidden */
  99128. _preActivate(): Mesh;
  99129. /** @hidden */
  99130. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99131. /** @hidden */
  99132. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99133. /**
  99134. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99135. * This means the mesh underlying bounding box and sphere are recomputed.
  99136. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99137. * @returns the current mesh
  99138. */
  99139. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99140. /** @hidden */
  99141. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99142. /**
  99143. * This function will subdivide the mesh into multiple submeshes
  99144. * @param count defines the expected number of submeshes
  99145. */
  99146. subdivide(count: number): void;
  99147. /**
  99148. * Copy a FloatArray into a specific associated vertex buffer
  99149. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99150. * - VertexBuffer.PositionKind
  99151. * - VertexBuffer.UVKind
  99152. * - VertexBuffer.UV2Kind
  99153. * - VertexBuffer.UV3Kind
  99154. * - VertexBuffer.UV4Kind
  99155. * - VertexBuffer.UV5Kind
  99156. * - VertexBuffer.UV6Kind
  99157. * - VertexBuffer.ColorKind
  99158. * - VertexBuffer.MatricesIndicesKind
  99159. * - VertexBuffer.MatricesIndicesExtraKind
  99160. * - VertexBuffer.MatricesWeightsKind
  99161. * - VertexBuffer.MatricesWeightsExtraKind
  99162. * @param data defines the data source
  99163. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99164. * @param stride defines the data stride size (can be null)
  99165. * @returns the current mesh
  99166. */
  99167. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99168. /**
  99169. * Delete a vertex buffer associated with this mesh
  99170. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99171. * - VertexBuffer.PositionKind
  99172. * - VertexBuffer.UVKind
  99173. * - VertexBuffer.UV2Kind
  99174. * - VertexBuffer.UV3Kind
  99175. * - VertexBuffer.UV4Kind
  99176. * - VertexBuffer.UV5Kind
  99177. * - VertexBuffer.UV6Kind
  99178. * - VertexBuffer.ColorKind
  99179. * - VertexBuffer.MatricesIndicesKind
  99180. * - VertexBuffer.MatricesIndicesExtraKind
  99181. * - VertexBuffer.MatricesWeightsKind
  99182. * - VertexBuffer.MatricesWeightsExtraKind
  99183. */
  99184. removeVerticesData(kind: string): void;
  99185. /**
  99186. * Flags an associated vertex buffer as updatable
  99187. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99188. * - VertexBuffer.PositionKind
  99189. * - VertexBuffer.UVKind
  99190. * - VertexBuffer.UV2Kind
  99191. * - VertexBuffer.UV3Kind
  99192. * - VertexBuffer.UV4Kind
  99193. * - VertexBuffer.UV5Kind
  99194. * - VertexBuffer.UV6Kind
  99195. * - VertexBuffer.ColorKind
  99196. * - VertexBuffer.MatricesIndicesKind
  99197. * - VertexBuffer.MatricesIndicesExtraKind
  99198. * - VertexBuffer.MatricesWeightsKind
  99199. * - VertexBuffer.MatricesWeightsExtraKind
  99200. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99201. */
  99202. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99203. /**
  99204. * Sets the mesh global Vertex Buffer
  99205. * @param buffer defines the buffer to use
  99206. * @returns the current mesh
  99207. */
  99208. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99209. /**
  99210. * Update a specific associated vertex buffer
  99211. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99212. * - VertexBuffer.PositionKind
  99213. * - VertexBuffer.UVKind
  99214. * - VertexBuffer.UV2Kind
  99215. * - VertexBuffer.UV3Kind
  99216. * - VertexBuffer.UV4Kind
  99217. * - VertexBuffer.UV5Kind
  99218. * - VertexBuffer.UV6Kind
  99219. * - VertexBuffer.ColorKind
  99220. * - VertexBuffer.MatricesIndicesKind
  99221. * - VertexBuffer.MatricesIndicesExtraKind
  99222. * - VertexBuffer.MatricesWeightsKind
  99223. * - VertexBuffer.MatricesWeightsExtraKind
  99224. * @param data defines the data source
  99225. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99226. * @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)
  99227. * @returns the current mesh
  99228. */
  99229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99230. /**
  99231. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99232. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99233. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99234. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99235. * @returns the current mesh
  99236. */
  99237. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99238. /**
  99239. * Creates a un-shared specific occurence of the geometry for the mesh.
  99240. * @returns the current mesh
  99241. */
  99242. makeGeometryUnique(): Mesh;
  99243. /**
  99244. * Set the index buffer of this mesh
  99245. * @param indices defines the source data
  99246. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99247. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99248. * @returns the current mesh
  99249. */
  99250. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99251. /**
  99252. * Update the current index buffer
  99253. * @param indices defines the source data
  99254. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99255. * @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)
  99256. * @returns the current mesh
  99257. */
  99258. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99259. /**
  99260. * Invert the geometry to move from a right handed system to a left handed one.
  99261. * @returns the current mesh
  99262. */
  99263. toLeftHanded(): Mesh;
  99264. /** @hidden */
  99265. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99266. /** @hidden */
  99267. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99268. /**
  99269. * Registers for this mesh a javascript function called just before the rendering process
  99270. * @param func defines the function to call before rendering this mesh
  99271. * @returns the current mesh
  99272. */
  99273. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99274. /**
  99275. * Disposes a previously registered javascript function called before the rendering
  99276. * @param func defines the function to remove
  99277. * @returns the current mesh
  99278. */
  99279. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99280. /**
  99281. * Registers for this mesh a javascript function called just after the rendering is complete
  99282. * @param func defines the function to call after rendering this mesh
  99283. * @returns the current mesh
  99284. */
  99285. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99286. /**
  99287. * Disposes a previously registered javascript function called after the rendering.
  99288. * @param func defines the function to remove
  99289. * @returns the current mesh
  99290. */
  99291. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99292. /** @hidden */
  99293. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99294. /** @hidden */
  99295. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99296. /** @hidden */
  99297. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99298. /** @hidden */
  99299. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99300. /** @hidden */
  99301. _rebuild(): void;
  99302. /** @hidden */
  99303. _freeze(): void;
  99304. /** @hidden */
  99305. _unFreeze(): void;
  99306. /**
  99307. * 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
  99308. * @param subMesh defines the subMesh to render
  99309. * @param enableAlphaMode defines if alpha mode can be changed
  99310. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99311. * @returns the current mesh
  99312. */
  99313. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99314. private _onBeforeDraw;
  99315. /**
  99316. * Renormalize the mesh and patch it up if there are no weights
  99317. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99318. * However in the case of zero weights then we set just a single influence to 1.
  99319. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99320. */
  99321. cleanMatrixWeights(): void;
  99322. private normalizeSkinFourWeights;
  99323. private normalizeSkinWeightsAndExtra;
  99324. /**
  99325. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99326. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99327. * the user know there was an issue with importing the mesh
  99328. * @returns a validation object with skinned, valid and report string
  99329. */
  99330. validateSkinning(): {
  99331. skinned: boolean;
  99332. valid: boolean;
  99333. report: string;
  99334. };
  99335. /** @hidden */
  99336. _checkDelayState(): Mesh;
  99337. private _queueLoad;
  99338. /**
  99339. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99340. * A mesh is in the frustum if its bounding box intersects the frustum
  99341. * @param frustumPlanes defines the frustum to test
  99342. * @returns true if the mesh is in the frustum planes
  99343. */
  99344. isInFrustum(frustumPlanes: Plane[]): boolean;
  99345. /**
  99346. * Sets the mesh material by the material or multiMaterial `id` property
  99347. * @param id is a string identifying the material or the multiMaterial
  99348. * @returns the current mesh
  99349. */
  99350. setMaterialByID(id: string): Mesh;
  99351. /**
  99352. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99353. * @returns an array of IAnimatable
  99354. */
  99355. getAnimatables(): IAnimatable[];
  99356. /**
  99357. * Modifies the mesh geometry according to the passed transformation matrix.
  99358. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99359. * The mesh normals are modified using the same transformation.
  99360. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99361. * @param transform defines the transform matrix to use
  99362. * @see http://doc.babylonjs.com/resources/baking_transformations
  99363. * @returns the current mesh
  99364. */
  99365. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99366. /**
  99367. * Modifies the mesh geometry according to its own current World Matrix.
  99368. * The mesh World Matrix is then reset.
  99369. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99370. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99371. * @see http://doc.babylonjs.com/resources/baking_transformations
  99372. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99373. * @returns the current mesh
  99374. */
  99375. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99376. /** @hidden */
  99377. get _positions(): Nullable<Vector3[]>;
  99378. /** @hidden */
  99379. _resetPointsArrayCache(): Mesh;
  99380. /** @hidden */
  99381. _generatePointsArray(): boolean;
  99382. /**
  99383. * Returns a new Mesh object generated from the current mesh properties.
  99384. * This method must not get confused with createInstance()
  99385. * @param name is a string, the name given to the new mesh
  99386. * @param newParent can be any Node object (default `null`)
  99387. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99388. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99389. * @returns a new mesh
  99390. */
  99391. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99392. /**
  99393. * Releases resources associated with this mesh.
  99394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99396. */
  99397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99398. /** @hidden */
  99399. _disposeInstanceSpecificData(): void;
  99400. /**
  99401. * Modifies the mesh geometry according to a displacement map.
  99402. * 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.
  99403. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99404. * @param url is a string, the URL from the image file is to be downloaded.
  99405. * @param minHeight is the lower limit of the displacement.
  99406. * @param maxHeight is the upper limit of the displacement.
  99407. * @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.
  99408. * @param uvOffset is an optional vector2 used to offset UV.
  99409. * @param uvScale is an optional vector2 used to scale UV.
  99410. * @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.
  99411. * @returns the Mesh.
  99412. */
  99413. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99414. /**
  99415. * Modifies the mesh geometry according to a displacementMap buffer.
  99416. * 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.
  99417. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99418. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99419. * @param heightMapWidth is the width of the buffer image.
  99420. * @param heightMapHeight is the height of the buffer image.
  99421. * @param minHeight is the lower limit of the displacement.
  99422. * @param maxHeight is the upper limit of the displacement.
  99423. * @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.
  99424. * @param uvOffset is an optional vector2 used to offset UV.
  99425. * @param uvScale is an optional vector2 used to scale UV.
  99426. * @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.
  99427. * @returns the Mesh.
  99428. */
  99429. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99430. /**
  99431. * Modify the mesh to get a flat shading rendering.
  99432. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99433. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99434. * @returns current mesh
  99435. */
  99436. convertToFlatShadedMesh(): Mesh;
  99437. /**
  99438. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99439. * In other words, more vertices, no more indices and a single bigger VBO.
  99440. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99441. * @returns current mesh
  99442. */
  99443. convertToUnIndexedMesh(): Mesh;
  99444. /**
  99445. * Inverses facet orientations.
  99446. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99447. * @param flipNormals will also inverts the normals
  99448. * @returns current mesh
  99449. */
  99450. flipFaces(flipNormals?: boolean): Mesh;
  99451. /**
  99452. * Increase the number of facets and hence vertices in a mesh
  99453. * Vertex normals are interpolated from existing vertex normals
  99454. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99455. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99456. */
  99457. increaseVertices(numberPerEdge: number): void;
  99458. /**
  99459. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99460. * This will undo any application of covertToFlatShadedMesh
  99461. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99462. */
  99463. forceSharedVertices(): void;
  99464. /** @hidden */
  99465. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99466. /** @hidden */
  99467. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99468. /**
  99469. * Creates a new InstancedMesh object from the mesh model.
  99470. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99471. * @param name defines the name of the new instance
  99472. * @returns a new InstancedMesh
  99473. */
  99474. createInstance(name: string): InstancedMesh;
  99475. /**
  99476. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99477. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99478. * @returns the current mesh
  99479. */
  99480. synchronizeInstances(): Mesh;
  99481. /**
  99482. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99483. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99484. * This should be used together with the simplification to avoid disappearing triangles.
  99485. * @param successCallback an optional success callback to be called after the optimization finished.
  99486. * @returns the current mesh
  99487. */
  99488. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99489. /**
  99490. * Serialize current mesh
  99491. * @param serializationObject defines the object which will receive the serialization data
  99492. */
  99493. serialize(serializationObject: any): void;
  99494. /** @hidden */
  99495. _syncGeometryWithMorphTargetManager(): void;
  99496. /** @hidden */
  99497. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99498. /**
  99499. * Returns a new Mesh object parsed from the source provided.
  99500. * @param parsedMesh is the source
  99501. * @param scene defines the hosting scene
  99502. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99503. * @returns a new Mesh
  99504. */
  99505. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99506. /**
  99507. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99508. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99509. * @param name defines the name of the mesh to create
  99510. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99511. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99512. * @param closePath creates a seam between the first and the last points of each path of the path array
  99513. * @param offset is taken in account only if the `pathArray` is containing a single path
  99514. * @param scene defines the hosting scene
  99515. * @param updatable defines if the mesh must be flagged as updatable
  99516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99517. * @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)
  99518. * @returns a new Mesh
  99519. */
  99520. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99521. /**
  99522. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99523. * @param name defines the name of the mesh to create
  99524. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99525. * @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
  99526. * @param scene defines the hosting scene
  99527. * @param updatable defines if the mesh must be flagged as updatable
  99528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99529. * @returns a new Mesh
  99530. */
  99531. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99532. /**
  99533. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99534. * @param name defines the name of the mesh to create
  99535. * @param size sets the size (float) of each box side (default 1)
  99536. * @param scene defines the hosting scene
  99537. * @param updatable defines if the mesh must be flagged as updatable
  99538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99539. * @returns a new Mesh
  99540. */
  99541. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99542. /**
  99543. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99544. * @param name defines the name of the mesh to create
  99545. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99546. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99553. /**
  99554. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99557. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99558. * @param scene defines the hosting scene
  99559. * @returns a new Mesh
  99560. */
  99561. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99562. /**
  99563. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99564. * @param name defines the name of the mesh to create
  99565. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99566. * @param diameterTop set the top cap diameter (floats, default 1)
  99567. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99568. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99569. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99570. * @param scene defines the hosting scene
  99571. * @param updatable defines if the mesh must be flagged as updatable
  99572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99573. * @returns a new Mesh
  99574. */
  99575. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99576. /**
  99577. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99578. * @param name defines the name of the mesh to create
  99579. * @param diameter sets the diameter size (float) of the torus (default 1)
  99580. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99581. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99582. * @param scene defines the hosting scene
  99583. * @param updatable defines if the mesh must be flagged as updatable
  99584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99585. * @returns a new Mesh
  99586. */
  99587. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99588. /**
  99589. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99590. * @param name defines the name of the mesh to create
  99591. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99592. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99593. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99594. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99595. * @param p the number of windings on X axis (positive integers, default 2)
  99596. * @param q the number of windings on Y axis (positive integers, default 3)
  99597. * @param scene defines the hosting scene
  99598. * @param updatable defines if the mesh must be flagged as updatable
  99599. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99600. * @returns a new Mesh
  99601. */
  99602. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99603. /**
  99604. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  99605. * @param name defines the name of the mesh to create
  99606. * @param points is an array successive Vector3
  99607. * @param scene defines the hosting scene
  99608. * @param updatable defines if the mesh must be flagged as updatable
  99609. * @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).
  99610. * @returns a new Mesh
  99611. */
  99612. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99613. /**
  99614. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99615. * @param name defines the name of the mesh to create
  99616. * @param points is an array successive Vector3
  99617. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99618. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99619. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99620. * @param scene defines the hosting scene
  99621. * @param updatable defines if the mesh must be flagged as updatable
  99622. * @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)
  99623. * @returns a new Mesh
  99624. */
  99625. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99626. /**
  99627. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99628. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99629. * 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.
  99630. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99631. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99632. * Remember you can only change the shape positions, not their number when updating a polygon.
  99633. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99634. * @param name defines the name of the mesh to create
  99635. * @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
  99636. * @param scene defines the hosting scene
  99637. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99638. * @param updatable defines if the mesh must be flagged as updatable
  99639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99640. * @param earcutInjection can be used to inject your own earcut reference
  99641. * @returns a new Mesh
  99642. */
  99643. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99644. /**
  99645. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99646. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99647. * @param name defines the name of the mesh to create
  99648. * @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
  99649. * @param depth defines the height of extrusion
  99650. * @param scene defines the hosting scene
  99651. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99652. * @param updatable defines if the mesh must be flagged as updatable
  99653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99654. * @param earcutInjection can be used to inject your own earcut reference
  99655. * @returns a new Mesh
  99656. */
  99657. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99658. /**
  99659. * Creates an extruded shape mesh.
  99660. * 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
  99661. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99662. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99663. * @param name defines the name of the mesh to create
  99664. * @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
  99665. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99666. * @param scale is the value to scale the shape
  99667. * @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
  99668. * @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
  99669. * @param scene defines the hosting scene
  99670. * @param updatable defines if the mesh must be flagged as updatable
  99671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99672. * @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)
  99673. * @returns a new Mesh
  99674. */
  99675. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99676. /**
  99677. * Creates an custom extruded shape mesh.
  99678. * The custom extrusion is a parametric shape.
  99679. * It has no predefined shape. Its final shape will depend on the input parameters.
  99680. * Please consider using the same method from the MeshBuilder class instead
  99681. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99682. * @param name defines the name of the mesh to create
  99683. * @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
  99684. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99685. * @param scaleFunction is a custom Javascript function called on each path point
  99686. * @param rotationFunction is a custom Javascript function called on each path point
  99687. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99688. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99689. * @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
  99690. * @param scene defines the hosting scene
  99691. * @param updatable defines if the mesh must be flagged as updatable
  99692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99693. * @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)
  99694. * @returns a new Mesh
  99695. */
  99696. 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;
  99697. /**
  99698. * Creates lathe mesh.
  99699. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  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 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
  99703. * @param radius is the radius value of the lathe
  99704. * @param tessellation is the side number of the lathe.
  99705. * @param scene defines the hosting scene
  99706. * @param updatable defines if the mesh must be flagged as updatable
  99707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99708. * @returns a new Mesh
  99709. */
  99710. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99711. /**
  99712. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99713. * @param name defines the name of the mesh to create
  99714. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99715. * @param scene defines the hosting scene
  99716. * @param updatable defines if the mesh must be flagged as updatable
  99717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99718. * @returns a new Mesh
  99719. */
  99720. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99721. /**
  99722. * Creates a ground mesh.
  99723. * Please consider using the same method from the MeshBuilder class instead
  99724. * @param name defines the name of the mesh to create
  99725. * @param width set the width of the ground
  99726. * @param height set the height of the ground
  99727. * @param subdivisions sets the number of subdivisions per side
  99728. * @param scene defines the hosting scene
  99729. * @param updatable defines if the mesh must be flagged as updatable
  99730. * @returns a new Mesh
  99731. */
  99732. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99733. /**
  99734. * Creates a tiled ground mesh.
  99735. * Please consider using the same method from the MeshBuilder class instead
  99736. * @param name defines the name of the mesh to create
  99737. * @param xmin set the ground minimum X coordinate
  99738. * @param zmin set the ground minimum Y coordinate
  99739. * @param xmax set the ground maximum X coordinate
  99740. * @param zmax set the ground maximum Z coordinate
  99741. * @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
  99742. * @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
  99743. * @param scene defines the hosting scene
  99744. * @param updatable defines if the mesh must be flagged as updatable
  99745. * @returns a new Mesh
  99746. */
  99747. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99748. w: number;
  99749. h: number;
  99750. }, precision: {
  99751. w: number;
  99752. h: number;
  99753. }, scene: Scene, updatable?: boolean): Mesh;
  99754. /**
  99755. * Creates a ground mesh from a height map.
  99756. * Please consider using the same method from the MeshBuilder class instead
  99757. * @see http://doc.babylonjs.com/babylon101/height_map
  99758. * @param name defines the name of the mesh to create
  99759. * @param url sets the URL of the height map image resource
  99760. * @param width set the ground width size
  99761. * @param height set the ground height size
  99762. * @param subdivisions sets the number of subdivision per side
  99763. * @param minHeight is the minimum altitude on the ground
  99764. * @param maxHeight is the maximum altitude on the ground
  99765. * @param scene defines the hosting scene
  99766. * @param updatable defines if the mesh must be flagged as updatable
  99767. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99768. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99769. * @returns a new Mesh
  99770. */
  99771. 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;
  99772. /**
  99773. * Creates a tube mesh.
  99774. * The tube is a parametric shape.
  99775. * It has no predefined shape. Its final shape will depend on the input parameters.
  99776. * Please consider using the same method from the MeshBuilder class instead
  99777. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99778. * @param name defines the name of the mesh to create
  99779. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99780. * @param radius sets the tube radius size
  99781. * @param tessellation is the number of sides on the tubular surface
  99782. * @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
  99783. * @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
  99784. * @param scene defines the hosting scene
  99785. * @param updatable defines if the mesh must be flagged as updatable
  99786. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99787. * @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)
  99788. * @returns a new Mesh
  99789. */
  99790. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99791. (i: number, distance: number): number;
  99792. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99793. /**
  99794. * Creates a polyhedron mesh.
  99795. * Please consider using the same method from the MeshBuilder class instead.
  99796. * * 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
  99797. * * The parameter `size` (positive float, default 1) sets the polygon size
  99798. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99799. * * 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`
  99800. * * 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
  99801. * * 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)`)
  99802. * * 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
  99803. * * 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
  99804. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99805. * * If you create a double-sided mesh, you can choose what parts of 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
  99806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99807. * @param name defines the name of the mesh to create
  99808. * @param options defines the options used to create the mesh
  99809. * @param scene defines the hosting scene
  99810. * @returns a new Mesh
  99811. */
  99812. static CreatePolyhedron(name: string, options: {
  99813. type?: number;
  99814. size?: number;
  99815. sizeX?: number;
  99816. sizeY?: number;
  99817. sizeZ?: number;
  99818. custom?: any;
  99819. faceUV?: Vector4[];
  99820. faceColors?: Color4[];
  99821. updatable?: boolean;
  99822. sideOrientation?: number;
  99823. }, scene: Scene): Mesh;
  99824. /**
  99825. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99826. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99827. * * 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`)
  99828. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99829. * * 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
  99830. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99831. * * If you create a double-sided mesh, you can choose what parts of 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
  99832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99833. * @param name defines the name of the mesh
  99834. * @param options defines the options used to create the mesh
  99835. * @param scene defines the hosting scene
  99836. * @returns a new Mesh
  99837. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99838. */
  99839. static CreateIcoSphere(name: string, options: {
  99840. radius?: number;
  99841. flat?: boolean;
  99842. subdivisions?: number;
  99843. sideOrientation?: number;
  99844. updatable?: boolean;
  99845. }, scene: Scene): Mesh;
  99846. /**
  99847. * Creates a decal mesh.
  99848. * Please consider using the same method from the MeshBuilder class instead.
  99849. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99850. * @param name defines the name of the mesh
  99851. * @param sourceMesh defines the mesh receiving the decal
  99852. * @param position sets the position of the decal in world coordinates
  99853. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99854. * @param size sets the decal scaling
  99855. * @param angle sets the angle to rotate the decal
  99856. * @returns a new Mesh
  99857. */
  99858. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99859. /**
  99860. * Prepare internal position array for software CPU skinning
  99861. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99862. */
  99863. setPositionsForCPUSkinning(): Float32Array;
  99864. /**
  99865. * Prepare internal normal array for software CPU skinning
  99866. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99867. */
  99868. setNormalsForCPUSkinning(): Float32Array;
  99869. /**
  99870. * Updates the vertex buffer by applying transformation from the bones
  99871. * @param skeleton defines the skeleton to apply to current mesh
  99872. * @returns the current mesh
  99873. */
  99874. applySkeleton(skeleton: Skeleton): Mesh;
  99875. /**
  99876. * 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
  99877. * @param meshes defines the list of meshes to scan
  99878. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99879. */
  99880. static MinMax(meshes: AbstractMesh[]): {
  99881. min: Vector3;
  99882. max: Vector3;
  99883. };
  99884. /**
  99885. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99886. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99887. * @returns a vector3
  99888. */
  99889. static Center(meshesOrMinMaxVector: {
  99890. min: Vector3;
  99891. max: Vector3;
  99892. } | AbstractMesh[]): Vector3;
  99893. /**
  99894. * Merge the array of meshes into a single mesh for performance reasons.
  99895. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99896. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99897. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99898. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99899. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99900. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99901. * @returns a new mesh
  99902. */
  99903. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99904. /** @hidden */
  99905. addInstance(instance: InstancedMesh): void;
  99906. /** @hidden */
  99907. removeInstance(instance: InstancedMesh): void;
  99908. }
  99909. }
  99910. declare module BABYLON {
  99911. /**
  99912. * This is the base class of all the camera used in the application.
  99913. * @see http://doc.babylonjs.com/features/cameras
  99914. */
  99915. export class Camera extends Node {
  99916. /** @hidden */
  99917. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99918. /**
  99919. * This is the default projection mode used by the cameras.
  99920. * It helps recreating a feeling of perspective and better appreciate depth.
  99921. * This is the best way to simulate real life cameras.
  99922. */
  99923. static readonly PERSPECTIVE_CAMERA: number;
  99924. /**
  99925. * This helps creating camera with an orthographic mode.
  99926. * 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.
  99927. */
  99928. static readonly ORTHOGRAPHIC_CAMERA: number;
  99929. /**
  99930. * This is the default FOV mode for perspective cameras.
  99931. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99932. */
  99933. static readonly FOVMODE_VERTICAL_FIXED: number;
  99934. /**
  99935. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99936. */
  99937. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99938. /**
  99939. * This specifies ther is no need for a camera rig.
  99940. * Basically only one eye is rendered corresponding to the camera.
  99941. */
  99942. static readonly RIG_MODE_NONE: number;
  99943. /**
  99944. * Simulates a camera Rig with one blue eye and one red eye.
  99945. * This can be use with 3d blue and red glasses.
  99946. */
  99947. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99948. /**
  99949. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99950. */
  99951. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99952. /**
  99953. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99954. */
  99955. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99956. /**
  99957. * Defines that both eyes of the camera will be rendered over under each other.
  99958. */
  99959. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99960. /**
  99961. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99962. */
  99963. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99964. /**
  99965. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99966. */
  99967. static readonly RIG_MODE_VR: number;
  99968. /**
  99969. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99970. */
  99971. static readonly RIG_MODE_WEBVR: number;
  99972. /**
  99973. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99974. */
  99975. static readonly RIG_MODE_CUSTOM: number;
  99976. /**
  99977. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99978. */
  99979. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99980. /**
  99981. * Define the input manager associated with the camera.
  99982. */
  99983. inputs: CameraInputsManager<Camera>;
  99984. /** @hidden */
  99985. _position: Vector3;
  99986. /**
  99987. * Define the current local position of the camera in the scene
  99988. */
  99989. get position(): Vector3;
  99990. set position(newPosition: Vector3);
  99991. /**
  99992. * The vector the camera should consider as up.
  99993. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99994. */
  99995. upVector: Vector3;
  99996. /**
  99997. * Define the current limit on the left side for an orthographic camera
  99998. * In scene unit
  99999. */
  100000. orthoLeft: Nullable<number>;
  100001. /**
  100002. * Define the current limit on the right side for an orthographic camera
  100003. * In scene unit
  100004. */
  100005. orthoRight: Nullable<number>;
  100006. /**
  100007. * Define the current limit on the bottom side for an orthographic camera
  100008. * In scene unit
  100009. */
  100010. orthoBottom: Nullable<number>;
  100011. /**
  100012. * Define the current limit on the top side for an orthographic camera
  100013. * In scene unit
  100014. */
  100015. orthoTop: Nullable<number>;
  100016. /**
  100017. * Field Of View is set in Radians. (default is 0.8)
  100018. */
  100019. fov: number;
  100020. /**
  100021. * Define the minimum distance the camera can see from.
  100022. * This is important to note that the depth buffer are not infinite and the closer it starts
  100023. * the more your scene might encounter depth fighting issue.
  100024. */
  100025. minZ: number;
  100026. /**
  100027. * Define the maximum distance the camera can see to.
  100028. * This is important to note that the depth buffer are not infinite and the further it end
  100029. * the more your scene might encounter depth fighting issue.
  100030. */
  100031. maxZ: number;
  100032. /**
  100033. * Define the default inertia of the camera.
  100034. * This helps giving a smooth feeling to the camera movement.
  100035. */
  100036. inertia: number;
  100037. /**
  100038. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100039. */
  100040. mode: number;
  100041. /**
  100042. * Define whether the camera is intermediate.
  100043. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100044. */
  100045. isIntermediate: boolean;
  100046. /**
  100047. * Define the viewport of the camera.
  100048. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100049. */
  100050. viewport: Viewport;
  100051. /**
  100052. * Restricts the camera to viewing objects with the same layerMask.
  100053. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100054. */
  100055. layerMask: number;
  100056. /**
  100057. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100058. */
  100059. fovMode: number;
  100060. /**
  100061. * Rig mode of the camera.
  100062. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100063. * This is normally controlled byt the camera themselves as internal use.
  100064. */
  100065. cameraRigMode: number;
  100066. /**
  100067. * Defines the distance between both "eyes" in case of a RIG
  100068. */
  100069. interaxialDistance: number;
  100070. /**
  100071. * Defines if stereoscopic rendering is done side by side or over under.
  100072. */
  100073. isStereoscopicSideBySide: boolean;
  100074. /**
  100075. * 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
  100076. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100077. * else in the scene. (Eg. security camera)
  100078. *
  100079. * 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)
  100080. */
  100081. customRenderTargets: RenderTargetTexture[];
  100082. /**
  100083. * When set, the camera will render to this render target instead of the default canvas
  100084. *
  100085. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100086. */
  100087. outputRenderTarget: Nullable<RenderTargetTexture>;
  100088. /**
  100089. * Observable triggered when the camera view matrix has changed.
  100090. */
  100091. onViewMatrixChangedObservable: Observable<Camera>;
  100092. /**
  100093. * Observable triggered when the camera Projection matrix has changed.
  100094. */
  100095. onProjectionMatrixChangedObservable: Observable<Camera>;
  100096. /**
  100097. * Observable triggered when the inputs have been processed.
  100098. */
  100099. onAfterCheckInputsObservable: Observable<Camera>;
  100100. /**
  100101. * Observable triggered when reset has been called and applied to the camera.
  100102. */
  100103. onRestoreStateObservable: Observable<Camera>;
  100104. /**
  100105. * Is this camera a part of a rig system?
  100106. */
  100107. isRigCamera: boolean;
  100108. /**
  100109. * If isRigCamera set to true this will be set with the parent camera.
  100110. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100111. */
  100112. rigParent?: Camera;
  100113. /** @hidden */
  100114. _cameraRigParams: any;
  100115. /** @hidden */
  100116. _rigCameras: Camera[];
  100117. /** @hidden */
  100118. _rigPostProcess: Nullable<PostProcess>;
  100119. protected _webvrViewMatrix: Matrix;
  100120. /** @hidden */
  100121. _skipRendering: boolean;
  100122. /** @hidden */
  100123. _projectionMatrix: Matrix;
  100124. /** @hidden */
  100125. _postProcesses: Nullable<PostProcess>[];
  100126. /** @hidden */
  100127. _activeMeshes: SmartArray<AbstractMesh>;
  100128. protected _globalPosition: Vector3;
  100129. /** @hidden */
  100130. _computedViewMatrix: Matrix;
  100131. private _doNotComputeProjectionMatrix;
  100132. private _transformMatrix;
  100133. private _frustumPlanes;
  100134. private _refreshFrustumPlanes;
  100135. private _storedFov;
  100136. private _stateStored;
  100137. /**
  100138. * Instantiates a new camera object.
  100139. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100140. * @see http://doc.babylonjs.com/features/cameras
  100141. * @param name Defines the name of the camera in the scene
  100142. * @param position Defines the position of the camera
  100143. * @param scene Defines the scene the camera belongs too
  100144. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100145. */
  100146. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100147. /**
  100148. * Store current camera state (fov, position, etc..)
  100149. * @returns the camera
  100150. */
  100151. storeState(): Camera;
  100152. /**
  100153. * Restores the camera state values if it has been stored. You must call storeState() first
  100154. */
  100155. protected _restoreStateValues(): boolean;
  100156. /**
  100157. * Restored camera state. You must call storeState() first.
  100158. * @returns true if restored and false otherwise
  100159. */
  100160. restoreState(): boolean;
  100161. /**
  100162. * Gets the class name of the camera.
  100163. * @returns the class name
  100164. */
  100165. getClassName(): string;
  100166. /** @hidden */
  100167. readonly _isCamera: boolean;
  100168. /**
  100169. * Gets a string representation of the camera useful for debug purpose.
  100170. * @param fullDetails Defines that a more verboe level of logging is required
  100171. * @returns the string representation
  100172. */
  100173. toString(fullDetails?: boolean): string;
  100174. /**
  100175. * Gets the current world space position of the camera.
  100176. */
  100177. get globalPosition(): Vector3;
  100178. /**
  100179. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100180. * @returns the active meshe list
  100181. */
  100182. getActiveMeshes(): SmartArray<AbstractMesh>;
  100183. /**
  100184. * Check whether a mesh is part of the current active mesh list of the camera
  100185. * @param mesh Defines the mesh to check
  100186. * @returns true if active, false otherwise
  100187. */
  100188. isActiveMesh(mesh: Mesh): boolean;
  100189. /**
  100190. * Is this camera ready to be used/rendered
  100191. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100192. * @return true if the camera is ready
  100193. */
  100194. isReady(completeCheck?: boolean): boolean;
  100195. /** @hidden */
  100196. _initCache(): void;
  100197. /** @hidden */
  100198. _updateCache(ignoreParentClass?: boolean): void;
  100199. /** @hidden */
  100200. _isSynchronized(): boolean;
  100201. /** @hidden */
  100202. _isSynchronizedViewMatrix(): boolean;
  100203. /** @hidden */
  100204. _isSynchronizedProjectionMatrix(): boolean;
  100205. /**
  100206. * Attach the input controls to a specific dom element to get the input from.
  100207. * @param element Defines the element the controls should be listened from
  100208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100209. */
  100210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100211. /**
  100212. * Detach the current controls from the specified dom element.
  100213. * @param element Defines the element to stop listening the inputs from
  100214. */
  100215. detachControl(element: HTMLElement): void;
  100216. /**
  100217. * Update the camera state according to the different inputs gathered during the frame.
  100218. */
  100219. update(): void;
  100220. /** @hidden */
  100221. _checkInputs(): void;
  100222. /** @hidden */
  100223. get rigCameras(): Camera[];
  100224. /**
  100225. * Gets the post process used by the rig cameras
  100226. */
  100227. get rigPostProcess(): Nullable<PostProcess>;
  100228. /**
  100229. * Internal, gets the first post proces.
  100230. * @returns the first post process to be run on this camera.
  100231. */
  100232. _getFirstPostProcess(): Nullable<PostProcess>;
  100233. private _cascadePostProcessesToRigCams;
  100234. /**
  100235. * Attach a post process to the camera.
  100236. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100237. * @param postProcess The post process to attach to the camera
  100238. * @param insertAt The position of the post process in case several of them are in use in the scene
  100239. * @returns the position the post process has been inserted at
  100240. */
  100241. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100242. /**
  100243. * Detach a post process to the camera.
  100244. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100245. * @param postProcess The post process to detach from the camera
  100246. */
  100247. detachPostProcess(postProcess: PostProcess): void;
  100248. /**
  100249. * Gets the current world matrix of the camera
  100250. */
  100251. getWorldMatrix(): Matrix;
  100252. /** @hidden */
  100253. _getViewMatrix(): Matrix;
  100254. /**
  100255. * Gets the current view matrix of the camera.
  100256. * @param force forces the camera to recompute the matrix without looking at the cached state
  100257. * @returns the view matrix
  100258. */
  100259. getViewMatrix(force?: boolean): Matrix;
  100260. /**
  100261. * Freeze the projection matrix.
  100262. * It will prevent the cache check of the camera projection compute and can speed up perf
  100263. * if no parameter of the camera are meant to change
  100264. * @param projection Defines manually a projection if necessary
  100265. */
  100266. freezeProjectionMatrix(projection?: Matrix): void;
  100267. /**
  100268. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100269. */
  100270. unfreezeProjectionMatrix(): void;
  100271. /**
  100272. * Gets the current projection matrix of the camera.
  100273. * @param force forces the camera to recompute the matrix without looking at the cached state
  100274. * @returns the projection matrix
  100275. */
  100276. getProjectionMatrix(force?: boolean): Matrix;
  100277. /**
  100278. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100279. * @returns a Matrix
  100280. */
  100281. getTransformationMatrix(): Matrix;
  100282. private _updateFrustumPlanes;
  100283. /**
  100284. * Checks if a cullable object (mesh...) is in the camera frustum
  100285. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100286. * @param target The object to check
  100287. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100288. * @returns true if the object is in frustum otherwise false
  100289. */
  100290. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100291. /**
  100292. * Checks if a cullable object (mesh...) is in the camera frustum
  100293. * Unlike isInFrustum this cheks the full bounding box
  100294. * @param target The object to check
  100295. * @returns true if the object is in frustum otherwise false
  100296. */
  100297. isCompletelyInFrustum(target: ICullable): boolean;
  100298. /**
  100299. * Gets a ray in the forward direction from the camera.
  100300. * @param length Defines the length of the ray to create
  100301. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100302. * @param origin Defines the start point of the ray which defaults to the camera position
  100303. * @returns the forward ray
  100304. */
  100305. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100306. /**
  100307. * Releases resources associated with this node.
  100308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100310. */
  100311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100312. /** @hidden */
  100313. _isLeftCamera: boolean;
  100314. /**
  100315. * Gets the left camera of a rig setup in case of Rigged Camera
  100316. */
  100317. get isLeftCamera(): boolean;
  100318. /** @hidden */
  100319. _isRightCamera: boolean;
  100320. /**
  100321. * Gets the right camera of a rig setup in case of Rigged Camera
  100322. */
  100323. get isRightCamera(): boolean;
  100324. /**
  100325. * Gets the left camera of a rig setup in case of Rigged Camera
  100326. */
  100327. get leftCamera(): Nullable<FreeCamera>;
  100328. /**
  100329. * Gets the right camera of a rig setup in case of Rigged Camera
  100330. */
  100331. get rightCamera(): Nullable<FreeCamera>;
  100332. /**
  100333. * Gets the left camera target of a rig setup in case of Rigged Camera
  100334. * @returns the target position
  100335. */
  100336. getLeftTarget(): Nullable<Vector3>;
  100337. /**
  100338. * Gets the right camera target of a rig setup in case of Rigged Camera
  100339. * @returns the target position
  100340. */
  100341. getRightTarget(): Nullable<Vector3>;
  100342. /**
  100343. * @hidden
  100344. */
  100345. setCameraRigMode(mode: number, rigParams: any): void;
  100346. /** @hidden */
  100347. static _setStereoscopicRigMode(camera: Camera): void;
  100348. /** @hidden */
  100349. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100350. /** @hidden */
  100351. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100352. /** @hidden */
  100353. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100354. /** @hidden */
  100355. _getVRProjectionMatrix(): Matrix;
  100356. protected _updateCameraRotationMatrix(): void;
  100357. protected _updateWebVRCameraRotationMatrix(): void;
  100358. /**
  100359. * This function MUST be overwritten by the different WebVR cameras available.
  100360. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100361. * @hidden
  100362. */
  100363. _getWebVRProjectionMatrix(): Matrix;
  100364. /**
  100365. * This function MUST be overwritten by the different WebVR cameras available.
  100366. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100367. * @hidden
  100368. */
  100369. _getWebVRViewMatrix(): Matrix;
  100370. /** @hidden */
  100371. setCameraRigParameter(name: string, value: any): void;
  100372. /**
  100373. * needs to be overridden by children so sub has required properties to be copied
  100374. * @hidden
  100375. */
  100376. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100377. /**
  100378. * May need to be overridden by children
  100379. * @hidden
  100380. */
  100381. _updateRigCameras(): void;
  100382. /** @hidden */
  100383. _setupInputs(): void;
  100384. /**
  100385. * Serialiaze the camera setup to a json represention
  100386. * @returns the JSON representation
  100387. */
  100388. serialize(): any;
  100389. /**
  100390. * Clones the current camera.
  100391. * @param name The cloned camera name
  100392. * @returns the cloned camera
  100393. */
  100394. clone(name: string): Camera;
  100395. /**
  100396. * Gets the direction of the camera relative to a given local axis.
  100397. * @param localAxis Defines the reference axis to provide a relative direction.
  100398. * @return the direction
  100399. */
  100400. getDirection(localAxis: Vector3): Vector3;
  100401. /**
  100402. * Returns the current camera absolute rotation
  100403. */
  100404. get absoluteRotation(): Quaternion;
  100405. /**
  100406. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100407. * @param localAxis Defines the reference axis to provide a relative direction.
  100408. * @param result Defines the vector to store the result in
  100409. */
  100410. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100411. /**
  100412. * Gets a camera constructor for a given camera type
  100413. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100414. * @param name The name of the camera the result will be able to instantiate
  100415. * @param scene The scene the result will construct the camera in
  100416. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100417. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100418. * @returns a factory method to construc the camera
  100419. */
  100420. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100421. /**
  100422. * Compute the world matrix of the camera.
  100423. * @returns the camera world matrix
  100424. */
  100425. computeWorldMatrix(): Matrix;
  100426. /**
  100427. * Parse a JSON and creates the camera from the parsed information
  100428. * @param parsedCamera The JSON to parse
  100429. * @param scene The scene to instantiate the camera in
  100430. * @returns the newly constructed camera
  100431. */
  100432. static Parse(parsedCamera: any, scene: Scene): Camera;
  100433. }
  100434. }
  100435. declare module BABYLON {
  100436. /**
  100437. * Class containing static functions to help procedurally build meshes
  100438. */
  100439. export class DiscBuilder {
  100440. /**
  100441. * Creates a plane polygonal mesh. By default, this is a disc
  100442. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100443. * * 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
  100444. * * 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
  100445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100448. * @param name defines the name of the mesh
  100449. * @param options defines the options used to create the mesh
  100450. * @param scene defines the hosting scene
  100451. * @returns the plane polygonal mesh
  100452. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100453. */
  100454. static CreateDisc(name: string, options: {
  100455. radius?: number;
  100456. tessellation?: number;
  100457. arc?: number;
  100458. updatable?: boolean;
  100459. sideOrientation?: number;
  100460. frontUVs?: Vector4;
  100461. backUVs?: Vector4;
  100462. }, scene?: Nullable<Scene>): Mesh;
  100463. }
  100464. }
  100465. declare module BABYLON {
  100466. /**
  100467. * Options to be used when creating a FresnelParameters.
  100468. */
  100469. export type IFresnelParametersCreationOptions = {
  100470. /**
  100471. * Define the color used on edges (grazing angle)
  100472. */
  100473. leftColor?: Color3;
  100474. /**
  100475. * Define the color used on center
  100476. */
  100477. rightColor?: Color3;
  100478. /**
  100479. * Define bias applied to computed fresnel term
  100480. */
  100481. bias?: number;
  100482. /**
  100483. * Defined the power exponent applied to fresnel term
  100484. */
  100485. power?: number;
  100486. /**
  100487. * Define if the fresnel effect is enable or not.
  100488. */
  100489. isEnabled?: boolean;
  100490. };
  100491. /**
  100492. * Serialized format for FresnelParameters.
  100493. */
  100494. export type IFresnelParametersSerialized = {
  100495. /**
  100496. * Define the color used on edges (grazing angle) [as an array]
  100497. */
  100498. leftColor: number[];
  100499. /**
  100500. * Define the color used on center [as an array]
  100501. */
  100502. rightColor: number[];
  100503. /**
  100504. * Define bias applied to computed fresnel term
  100505. */
  100506. bias: number;
  100507. /**
  100508. * Defined the power exponent applied to fresnel term
  100509. */
  100510. power?: number;
  100511. /**
  100512. * Define if the fresnel effect is enable or not.
  100513. */
  100514. isEnabled: boolean;
  100515. };
  100516. /**
  100517. * This represents all the required information to add a fresnel effect on a material:
  100518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100519. */
  100520. export class FresnelParameters {
  100521. private _isEnabled;
  100522. /**
  100523. * Define if the fresnel effect is enable or not.
  100524. */
  100525. get isEnabled(): boolean;
  100526. set isEnabled(value: boolean);
  100527. /**
  100528. * Define the color used on edges (grazing angle)
  100529. */
  100530. leftColor: Color3;
  100531. /**
  100532. * Define the color used on center
  100533. */
  100534. rightColor: Color3;
  100535. /**
  100536. * Define bias applied to computed fresnel term
  100537. */
  100538. bias: number;
  100539. /**
  100540. * Defined the power exponent applied to fresnel term
  100541. */
  100542. power: number;
  100543. /**
  100544. * Creates a new FresnelParameters object.
  100545. *
  100546. * @param options provide your own settings to optionally to override defaults
  100547. */
  100548. constructor(options?: IFresnelParametersCreationOptions);
  100549. /**
  100550. * Clones the current fresnel and its valuues
  100551. * @returns a clone fresnel configuration
  100552. */
  100553. clone(): FresnelParameters;
  100554. /**
  100555. * Determines equality between FresnelParameters objects
  100556. * @param otherFresnelParameters defines the second operand
  100557. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100558. */
  100559. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100560. /**
  100561. * Serializes the current fresnel parameters to a JSON representation.
  100562. * @return the JSON serialization
  100563. */
  100564. serialize(): IFresnelParametersSerialized;
  100565. /**
  100566. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100567. * @param parsedFresnelParameters Define the JSON representation
  100568. * @returns the parsed parameters
  100569. */
  100570. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100571. }
  100572. }
  100573. declare module BABYLON {
  100574. /**
  100575. * Base class of materials working in push mode in babylon JS
  100576. * @hidden
  100577. */
  100578. export class PushMaterial extends Material {
  100579. protected _activeEffect: Effect;
  100580. protected _normalMatrix: Matrix;
  100581. /**
  100582. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100583. * This means that the material can keep using a previous shader while a new one is being compiled.
  100584. * This is mostly used when shader parallel compilation is supported (true by default)
  100585. */
  100586. allowShaderHotSwapping: boolean;
  100587. constructor(name: string, scene: Scene);
  100588. getEffect(): Effect;
  100589. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100590. /**
  100591. * Binds the given world matrix to the active effect
  100592. *
  100593. * @param world the matrix to bind
  100594. */
  100595. bindOnlyWorldMatrix(world: Matrix): void;
  100596. /**
  100597. * Binds the given normal matrix to the active effect
  100598. *
  100599. * @param normalMatrix the matrix to bind
  100600. */
  100601. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100602. bind(world: Matrix, mesh?: Mesh): void;
  100603. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100604. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100605. }
  100606. }
  100607. declare module BABYLON {
  100608. /**
  100609. * This groups all the flags used to control the materials channel.
  100610. */
  100611. export class MaterialFlags {
  100612. private static _DiffuseTextureEnabled;
  100613. /**
  100614. * Are diffuse textures enabled in the application.
  100615. */
  100616. static get DiffuseTextureEnabled(): boolean;
  100617. static set DiffuseTextureEnabled(value: boolean);
  100618. private static _AmbientTextureEnabled;
  100619. /**
  100620. * Are ambient textures enabled in the application.
  100621. */
  100622. static get AmbientTextureEnabled(): boolean;
  100623. static set AmbientTextureEnabled(value: boolean);
  100624. private static _OpacityTextureEnabled;
  100625. /**
  100626. * Are opacity textures enabled in the application.
  100627. */
  100628. static get OpacityTextureEnabled(): boolean;
  100629. static set OpacityTextureEnabled(value: boolean);
  100630. private static _ReflectionTextureEnabled;
  100631. /**
  100632. * Are reflection textures enabled in the application.
  100633. */
  100634. static get ReflectionTextureEnabled(): boolean;
  100635. static set ReflectionTextureEnabled(value: boolean);
  100636. private static _EmissiveTextureEnabled;
  100637. /**
  100638. * Are emissive textures enabled in the application.
  100639. */
  100640. static get EmissiveTextureEnabled(): boolean;
  100641. static set EmissiveTextureEnabled(value: boolean);
  100642. private static _SpecularTextureEnabled;
  100643. /**
  100644. * Are specular textures enabled in the application.
  100645. */
  100646. static get SpecularTextureEnabled(): boolean;
  100647. static set SpecularTextureEnabled(value: boolean);
  100648. private static _BumpTextureEnabled;
  100649. /**
  100650. * Are bump textures enabled in the application.
  100651. */
  100652. static get BumpTextureEnabled(): boolean;
  100653. static set BumpTextureEnabled(value: boolean);
  100654. private static _LightmapTextureEnabled;
  100655. /**
  100656. * Are lightmap textures enabled in the application.
  100657. */
  100658. static get LightmapTextureEnabled(): boolean;
  100659. static set LightmapTextureEnabled(value: boolean);
  100660. private static _RefractionTextureEnabled;
  100661. /**
  100662. * Are refraction textures enabled in the application.
  100663. */
  100664. static get RefractionTextureEnabled(): boolean;
  100665. static set RefractionTextureEnabled(value: boolean);
  100666. private static _ColorGradingTextureEnabled;
  100667. /**
  100668. * Are color grading textures enabled in the application.
  100669. */
  100670. static get ColorGradingTextureEnabled(): boolean;
  100671. static set ColorGradingTextureEnabled(value: boolean);
  100672. private static _FresnelEnabled;
  100673. /**
  100674. * Are fresnels enabled in the application.
  100675. */
  100676. static get FresnelEnabled(): boolean;
  100677. static set FresnelEnabled(value: boolean);
  100678. private static _ClearCoatTextureEnabled;
  100679. /**
  100680. * Are clear coat textures enabled in the application.
  100681. */
  100682. static get ClearCoatTextureEnabled(): boolean;
  100683. static set ClearCoatTextureEnabled(value: boolean);
  100684. private static _ClearCoatBumpTextureEnabled;
  100685. /**
  100686. * Are clear coat bump textures enabled in the application.
  100687. */
  100688. static get ClearCoatBumpTextureEnabled(): boolean;
  100689. static set ClearCoatBumpTextureEnabled(value: boolean);
  100690. private static _ClearCoatTintTextureEnabled;
  100691. /**
  100692. * Are clear coat tint textures enabled in the application.
  100693. */
  100694. static get ClearCoatTintTextureEnabled(): boolean;
  100695. static set ClearCoatTintTextureEnabled(value: boolean);
  100696. private static _SheenTextureEnabled;
  100697. /**
  100698. * Are sheen textures enabled in the application.
  100699. */
  100700. static get SheenTextureEnabled(): boolean;
  100701. static set SheenTextureEnabled(value: boolean);
  100702. private static _AnisotropicTextureEnabled;
  100703. /**
  100704. * Are anisotropic textures enabled in the application.
  100705. */
  100706. static get AnisotropicTextureEnabled(): boolean;
  100707. static set AnisotropicTextureEnabled(value: boolean);
  100708. private static _ThicknessTextureEnabled;
  100709. /**
  100710. * Are thickness textures enabled in the application.
  100711. */
  100712. static get ThicknessTextureEnabled(): boolean;
  100713. static set ThicknessTextureEnabled(value: boolean);
  100714. }
  100715. }
  100716. declare module BABYLON {
  100717. /** @hidden */
  100718. export var defaultFragmentDeclaration: {
  100719. name: string;
  100720. shader: string;
  100721. };
  100722. }
  100723. declare module BABYLON {
  100724. /** @hidden */
  100725. export var defaultUboDeclaration: {
  100726. name: string;
  100727. shader: string;
  100728. };
  100729. }
  100730. declare module BABYLON {
  100731. /** @hidden */
  100732. export var lightFragmentDeclaration: {
  100733. name: string;
  100734. shader: string;
  100735. };
  100736. }
  100737. declare module BABYLON {
  100738. /** @hidden */
  100739. export var lightUboDeclaration: {
  100740. name: string;
  100741. shader: string;
  100742. };
  100743. }
  100744. declare module BABYLON {
  100745. /** @hidden */
  100746. export var lightsFragmentFunctions: {
  100747. name: string;
  100748. shader: string;
  100749. };
  100750. }
  100751. declare module BABYLON {
  100752. /** @hidden */
  100753. export var shadowsFragmentFunctions: {
  100754. name: string;
  100755. shader: string;
  100756. };
  100757. }
  100758. declare module BABYLON {
  100759. /** @hidden */
  100760. export var fresnelFunction: {
  100761. name: string;
  100762. shader: string;
  100763. };
  100764. }
  100765. declare module BABYLON {
  100766. /** @hidden */
  100767. export var reflectionFunction: {
  100768. name: string;
  100769. shader: string;
  100770. };
  100771. }
  100772. declare module BABYLON {
  100773. /** @hidden */
  100774. export var bumpFragmentFunctions: {
  100775. name: string;
  100776. shader: string;
  100777. };
  100778. }
  100779. declare module BABYLON {
  100780. /** @hidden */
  100781. export var logDepthDeclaration: {
  100782. name: string;
  100783. shader: string;
  100784. };
  100785. }
  100786. declare module BABYLON {
  100787. /** @hidden */
  100788. export var bumpFragment: {
  100789. name: string;
  100790. shader: string;
  100791. };
  100792. }
  100793. declare module BABYLON {
  100794. /** @hidden */
  100795. export var depthPrePass: {
  100796. name: string;
  100797. shader: string;
  100798. };
  100799. }
  100800. declare module BABYLON {
  100801. /** @hidden */
  100802. export var lightFragment: {
  100803. name: string;
  100804. shader: string;
  100805. };
  100806. }
  100807. declare module BABYLON {
  100808. /** @hidden */
  100809. export var logDepthFragment: {
  100810. name: string;
  100811. shader: string;
  100812. };
  100813. }
  100814. declare module BABYLON {
  100815. /** @hidden */
  100816. export var defaultPixelShader: {
  100817. name: string;
  100818. shader: string;
  100819. };
  100820. }
  100821. declare module BABYLON {
  100822. /** @hidden */
  100823. export var defaultVertexDeclaration: {
  100824. name: string;
  100825. shader: string;
  100826. };
  100827. }
  100828. declare module BABYLON {
  100829. /** @hidden */
  100830. export var bumpVertexDeclaration: {
  100831. name: string;
  100832. shader: string;
  100833. };
  100834. }
  100835. declare module BABYLON {
  100836. /** @hidden */
  100837. export var bumpVertex: {
  100838. name: string;
  100839. shader: string;
  100840. };
  100841. }
  100842. declare module BABYLON {
  100843. /** @hidden */
  100844. export var fogVertex: {
  100845. name: string;
  100846. shader: string;
  100847. };
  100848. }
  100849. declare module BABYLON {
  100850. /** @hidden */
  100851. export var shadowsVertex: {
  100852. name: string;
  100853. shader: string;
  100854. };
  100855. }
  100856. declare module BABYLON {
  100857. /** @hidden */
  100858. export var pointCloudVertex: {
  100859. name: string;
  100860. shader: string;
  100861. };
  100862. }
  100863. declare module BABYLON {
  100864. /** @hidden */
  100865. export var logDepthVertex: {
  100866. name: string;
  100867. shader: string;
  100868. };
  100869. }
  100870. declare module BABYLON {
  100871. /** @hidden */
  100872. export var defaultVertexShader: {
  100873. name: string;
  100874. shader: string;
  100875. };
  100876. }
  100877. declare module BABYLON {
  100878. /** @hidden */
  100879. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100880. MAINUV1: boolean;
  100881. MAINUV2: boolean;
  100882. DIFFUSE: boolean;
  100883. DIFFUSEDIRECTUV: number;
  100884. AMBIENT: boolean;
  100885. AMBIENTDIRECTUV: number;
  100886. OPACITY: boolean;
  100887. OPACITYDIRECTUV: number;
  100888. OPACITYRGB: boolean;
  100889. REFLECTION: boolean;
  100890. EMISSIVE: boolean;
  100891. EMISSIVEDIRECTUV: number;
  100892. SPECULAR: boolean;
  100893. SPECULARDIRECTUV: number;
  100894. BUMP: boolean;
  100895. BUMPDIRECTUV: number;
  100896. PARALLAX: boolean;
  100897. PARALLAXOCCLUSION: boolean;
  100898. SPECULAROVERALPHA: boolean;
  100899. CLIPPLANE: boolean;
  100900. CLIPPLANE2: boolean;
  100901. CLIPPLANE3: boolean;
  100902. CLIPPLANE4: boolean;
  100903. CLIPPLANE5: boolean;
  100904. CLIPPLANE6: boolean;
  100905. ALPHATEST: boolean;
  100906. DEPTHPREPASS: boolean;
  100907. ALPHAFROMDIFFUSE: boolean;
  100908. POINTSIZE: boolean;
  100909. FOG: boolean;
  100910. SPECULARTERM: boolean;
  100911. DIFFUSEFRESNEL: boolean;
  100912. OPACITYFRESNEL: boolean;
  100913. REFLECTIONFRESNEL: boolean;
  100914. REFRACTIONFRESNEL: boolean;
  100915. EMISSIVEFRESNEL: boolean;
  100916. FRESNEL: boolean;
  100917. NORMAL: boolean;
  100918. UV1: boolean;
  100919. UV2: boolean;
  100920. VERTEXCOLOR: boolean;
  100921. VERTEXALPHA: boolean;
  100922. NUM_BONE_INFLUENCERS: number;
  100923. BonesPerMesh: number;
  100924. BONETEXTURE: boolean;
  100925. INSTANCES: boolean;
  100926. GLOSSINESS: boolean;
  100927. ROUGHNESS: boolean;
  100928. EMISSIVEASILLUMINATION: boolean;
  100929. LINKEMISSIVEWITHDIFFUSE: boolean;
  100930. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100931. LIGHTMAP: boolean;
  100932. LIGHTMAPDIRECTUV: number;
  100933. OBJECTSPACE_NORMALMAP: boolean;
  100934. USELIGHTMAPASSHADOWMAP: boolean;
  100935. REFLECTIONMAP_3D: boolean;
  100936. REFLECTIONMAP_SPHERICAL: boolean;
  100937. REFLECTIONMAP_PLANAR: boolean;
  100938. REFLECTIONMAP_CUBIC: boolean;
  100939. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100940. REFLECTIONMAP_PROJECTION: boolean;
  100941. REFLECTIONMAP_SKYBOX: boolean;
  100942. REFLECTIONMAP_EXPLICIT: boolean;
  100943. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100944. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100945. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100946. INVERTCUBICMAP: boolean;
  100947. LOGARITHMICDEPTH: boolean;
  100948. REFRACTION: boolean;
  100949. REFRACTIONMAP_3D: boolean;
  100950. REFLECTIONOVERALPHA: boolean;
  100951. TWOSIDEDLIGHTING: boolean;
  100952. SHADOWFLOAT: boolean;
  100953. MORPHTARGETS: boolean;
  100954. MORPHTARGETS_NORMAL: boolean;
  100955. MORPHTARGETS_TANGENT: boolean;
  100956. MORPHTARGETS_UV: boolean;
  100957. NUM_MORPH_INFLUENCERS: number;
  100958. NONUNIFORMSCALING: boolean;
  100959. PREMULTIPLYALPHA: boolean;
  100960. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100961. ALPHABLEND: boolean;
  100962. IMAGEPROCESSING: boolean;
  100963. VIGNETTE: boolean;
  100964. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100965. VIGNETTEBLENDMODEOPAQUE: boolean;
  100966. TONEMAPPING: boolean;
  100967. TONEMAPPING_ACES: boolean;
  100968. CONTRAST: boolean;
  100969. COLORCURVES: boolean;
  100970. COLORGRADING: boolean;
  100971. COLORGRADING3D: boolean;
  100972. SAMPLER3DGREENDEPTH: boolean;
  100973. SAMPLER3DBGRMAP: boolean;
  100974. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100975. MULTIVIEW: boolean;
  100976. /**
  100977. * If the reflection texture on this material is in linear color space
  100978. * @hidden
  100979. */
  100980. IS_REFLECTION_LINEAR: boolean;
  100981. /**
  100982. * If the refraction texture on this material is in linear color space
  100983. * @hidden
  100984. */
  100985. IS_REFRACTION_LINEAR: boolean;
  100986. EXPOSURE: boolean;
  100987. constructor();
  100988. setReflectionMode(modeToEnable: string): void;
  100989. }
  100990. /**
  100991. * This is the default material used in Babylon. It is the best trade off between quality
  100992. * and performances.
  100993. * @see http://doc.babylonjs.com/babylon101/materials
  100994. */
  100995. export class StandardMaterial extends PushMaterial {
  100996. private _diffuseTexture;
  100997. /**
  100998. * The basic texture of the material as viewed under a light.
  100999. */
  101000. diffuseTexture: Nullable<BaseTexture>;
  101001. private _ambientTexture;
  101002. /**
  101003. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101004. */
  101005. ambientTexture: Nullable<BaseTexture>;
  101006. private _opacityTexture;
  101007. /**
  101008. * Define the transparency of the material from a texture.
  101009. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101010. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101011. */
  101012. opacityTexture: Nullable<BaseTexture>;
  101013. private _reflectionTexture;
  101014. /**
  101015. * Define the texture used to display the reflection.
  101016. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101017. */
  101018. reflectionTexture: Nullable<BaseTexture>;
  101019. private _emissiveTexture;
  101020. /**
  101021. * Define texture of the material as if self lit.
  101022. * This will be mixed in the final result even in the absence of light.
  101023. */
  101024. emissiveTexture: Nullable<BaseTexture>;
  101025. private _specularTexture;
  101026. /**
  101027. * Define how the color and intensity of the highlight given by the light in the material.
  101028. */
  101029. specularTexture: Nullable<BaseTexture>;
  101030. private _bumpTexture;
  101031. /**
  101032. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101033. * 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.
  101034. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101035. */
  101036. bumpTexture: Nullable<BaseTexture>;
  101037. private _lightmapTexture;
  101038. /**
  101039. * Complex lighting can be computationally expensive to compute at runtime.
  101040. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101041. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101042. */
  101043. lightmapTexture: Nullable<BaseTexture>;
  101044. private _refractionTexture;
  101045. /**
  101046. * Define the texture used to display the refraction.
  101047. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101048. */
  101049. refractionTexture: Nullable<BaseTexture>;
  101050. /**
  101051. * The color of the material lit by the environmental background lighting.
  101052. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101053. */
  101054. ambientColor: Color3;
  101055. /**
  101056. * The basic color of the material as viewed under a light.
  101057. */
  101058. diffuseColor: Color3;
  101059. /**
  101060. * Define how the color and intensity of the highlight given by the light in the material.
  101061. */
  101062. specularColor: Color3;
  101063. /**
  101064. * Define the color of the material as if self lit.
  101065. * This will be mixed in the final result even in the absence of light.
  101066. */
  101067. emissiveColor: Color3;
  101068. /**
  101069. * Defines how sharp are the highlights in the material.
  101070. * The bigger the value the sharper giving a more glossy feeling to the result.
  101071. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101072. */
  101073. specularPower: number;
  101074. private _useAlphaFromDiffuseTexture;
  101075. /**
  101076. * Does the transparency come from the diffuse texture alpha channel.
  101077. */
  101078. useAlphaFromDiffuseTexture: boolean;
  101079. private _useEmissiveAsIllumination;
  101080. /**
  101081. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101082. */
  101083. useEmissiveAsIllumination: boolean;
  101084. private _linkEmissiveWithDiffuse;
  101085. /**
  101086. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101087. * the emissive level when the final color is close to one.
  101088. */
  101089. linkEmissiveWithDiffuse: boolean;
  101090. private _useSpecularOverAlpha;
  101091. /**
  101092. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101093. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101094. */
  101095. useSpecularOverAlpha: boolean;
  101096. private _useReflectionOverAlpha;
  101097. /**
  101098. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101099. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101100. */
  101101. useReflectionOverAlpha: boolean;
  101102. private _disableLighting;
  101103. /**
  101104. * Does lights from the scene impacts this material.
  101105. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101106. */
  101107. disableLighting: boolean;
  101108. private _useObjectSpaceNormalMap;
  101109. /**
  101110. * Allows using an object space normal map (instead of tangent space).
  101111. */
  101112. useObjectSpaceNormalMap: boolean;
  101113. private _useParallax;
  101114. /**
  101115. * Is parallax enabled or not.
  101116. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101117. */
  101118. useParallax: boolean;
  101119. private _useParallaxOcclusion;
  101120. /**
  101121. * Is parallax occlusion enabled or not.
  101122. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101123. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101124. */
  101125. useParallaxOcclusion: boolean;
  101126. /**
  101127. * 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.
  101128. */
  101129. parallaxScaleBias: number;
  101130. private _roughness;
  101131. /**
  101132. * Helps to define how blurry the reflections should appears in the material.
  101133. */
  101134. roughness: number;
  101135. /**
  101136. * In case of refraction, define the value of the index of refraction.
  101137. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101138. */
  101139. indexOfRefraction: number;
  101140. /**
  101141. * Invert the refraction texture alongside the y axis.
  101142. * It can be useful with procedural textures or probe for instance.
  101143. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101144. */
  101145. invertRefractionY: boolean;
  101146. /**
  101147. * Defines the alpha limits in alpha test mode.
  101148. */
  101149. alphaCutOff: number;
  101150. private _useLightmapAsShadowmap;
  101151. /**
  101152. * In case of light mapping, define whether the map contains light or shadow informations.
  101153. */
  101154. useLightmapAsShadowmap: boolean;
  101155. private _diffuseFresnelParameters;
  101156. /**
  101157. * Define the diffuse fresnel parameters of the material.
  101158. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101159. */
  101160. diffuseFresnelParameters: FresnelParameters;
  101161. private _opacityFresnelParameters;
  101162. /**
  101163. * Define the opacity fresnel parameters of the material.
  101164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101165. */
  101166. opacityFresnelParameters: FresnelParameters;
  101167. private _reflectionFresnelParameters;
  101168. /**
  101169. * Define the reflection fresnel parameters of the material.
  101170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101171. */
  101172. reflectionFresnelParameters: FresnelParameters;
  101173. private _refractionFresnelParameters;
  101174. /**
  101175. * Define the refraction fresnel parameters of the material.
  101176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101177. */
  101178. refractionFresnelParameters: FresnelParameters;
  101179. private _emissiveFresnelParameters;
  101180. /**
  101181. * Define the emissive fresnel parameters of the material.
  101182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101183. */
  101184. emissiveFresnelParameters: FresnelParameters;
  101185. private _useReflectionFresnelFromSpecular;
  101186. /**
  101187. * If true automatically deducts the fresnels values from the material specularity.
  101188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101189. */
  101190. useReflectionFresnelFromSpecular: boolean;
  101191. private _useGlossinessFromSpecularMapAlpha;
  101192. /**
  101193. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101194. */
  101195. useGlossinessFromSpecularMapAlpha: boolean;
  101196. private _maxSimultaneousLights;
  101197. /**
  101198. * Defines the maximum number of lights that can be used in the material
  101199. */
  101200. maxSimultaneousLights: number;
  101201. private _invertNormalMapX;
  101202. /**
  101203. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101204. */
  101205. invertNormalMapX: boolean;
  101206. private _invertNormalMapY;
  101207. /**
  101208. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101209. */
  101210. invertNormalMapY: boolean;
  101211. private _twoSidedLighting;
  101212. /**
  101213. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101214. */
  101215. twoSidedLighting: boolean;
  101216. /**
  101217. * Default configuration related to image processing available in the standard Material.
  101218. */
  101219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101220. /**
  101221. * Gets the image processing configuration used either in this material.
  101222. */
  101223. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101224. /**
  101225. * Sets the Default image processing configuration used either in the this material.
  101226. *
  101227. * If sets to null, the scene one is in use.
  101228. */
  101229. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101230. /**
  101231. * Keep track of the image processing observer to allow dispose and replace.
  101232. */
  101233. private _imageProcessingObserver;
  101234. /**
  101235. * Attaches a new image processing configuration to the Standard Material.
  101236. * @param configuration
  101237. */
  101238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101239. /**
  101240. * Gets wether the color curves effect is enabled.
  101241. */
  101242. get cameraColorCurvesEnabled(): boolean;
  101243. /**
  101244. * Sets wether the color curves effect is enabled.
  101245. */
  101246. set cameraColorCurvesEnabled(value: boolean);
  101247. /**
  101248. * Gets wether the color grading effect is enabled.
  101249. */
  101250. get cameraColorGradingEnabled(): boolean;
  101251. /**
  101252. * Gets wether the color grading effect is enabled.
  101253. */
  101254. set cameraColorGradingEnabled(value: boolean);
  101255. /**
  101256. * Gets wether tonemapping is enabled or not.
  101257. */
  101258. get cameraToneMappingEnabled(): boolean;
  101259. /**
  101260. * Sets wether tonemapping is enabled or not
  101261. */
  101262. set cameraToneMappingEnabled(value: boolean);
  101263. /**
  101264. * The camera exposure used on this material.
  101265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101266. * This corresponds to a photographic exposure.
  101267. */
  101268. get cameraExposure(): number;
  101269. /**
  101270. * The camera exposure used on this material.
  101271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101272. * This corresponds to a photographic exposure.
  101273. */
  101274. set cameraExposure(value: number);
  101275. /**
  101276. * Gets The camera contrast used on this material.
  101277. */
  101278. get cameraContrast(): number;
  101279. /**
  101280. * Sets The camera contrast used on this material.
  101281. */
  101282. set cameraContrast(value: number);
  101283. /**
  101284. * Gets the Color Grading 2D Lookup Texture.
  101285. */
  101286. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101287. /**
  101288. * Sets the Color Grading 2D Lookup Texture.
  101289. */
  101290. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101291. /**
  101292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101294. * 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;
  101295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101296. */
  101297. get cameraColorCurves(): Nullable<ColorCurves>;
  101298. /**
  101299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101301. * 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;
  101302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101303. */
  101304. set cameraColorCurves(value: Nullable<ColorCurves>);
  101305. /**
  101306. * Custom callback helping to override the default shader used in the material.
  101307. */
  101308. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101309. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101310. protected _worldViewProjectionMatrix: Matrix;
  101311. protected _globalAmbientColor: Color3;
  101312. protected _useLogarithmicDepth: boolean;
  101313. protected _rebuildInParallel: boolean;
  101314. /**
  101315. * Instantiates a new standard material.
  101316. * This is the default material used in Babylon. It is the best trade off between quality
  101317. * and performances.
  101318. * @see http://doc.babylonjs.com/babylon101/materials
  101319. * @param name Define the name of the material in the scene
  101320. * @param scene Define the scene the material belong to
  101321. */
  101322. constructor(name: string, scene: Scene);
  101323. /**
  101324. * Gets a boolean indicating that current material needs to register RTT
  101325. */
  101326. get hasRenderTargetTextures(): boolean;
  101327. /**
  101328. * Gets the current class name of the material e.g. "StandardMaterial"
  101329. * Mainly use in serialization.
  101330. * @returns the class name
  101331. */
  101332. getClassName(): string;
  101333. /**
  101334. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101335. * You can try switching to logarithmic depth.
  101336. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101337. */
  101338. get useLogarithmicDepth(): boolean;
  101339. set useLogarithmicDepth(value: boolean);
  101340. /**
  101341. * Specifies if the material will require alpha blending
  101342. * @returns a boolean specifying if alpha blending is needed
  101343. */
  101344. needAlphaBlending(): boolean;
  101345. /**
  101346. * Specifies if this material should be rendered in alpha test mode
  101347. * @returns a boolean specifying if an alpha test is needed.
  101348. */
  101349. needAlphaTesting(): boolean;
  101350. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101351. /**
  101352. * Get the texture used for alpha test purpose.
  101353. * @returns the diffuse texture in case of the standard material.
  101354. */
  101355. getAlphaTestTexture(): Nullable<BaseTexture>;
  101356. /**
  101357. * Get if the submesh is ready to be used and all its information available.
  101358. * Child classes can use it to update shaders
  101359. * @param mesh defines the mesh to check
  101360. * @param subMesh defines which submesh to check
  101361. * @param useInstances specifies that instances should be used
  101362. * @returns a boolean indicating that the submesh is ready or not
  101363. */
  101364. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101365. /**
  101366. * Builds the material UBO layouts.
  101367. * Used internally during the effect preparation.
  101368. */
  101369. buildUniformLayout(): void;
  101370. /**
  101371. * Unbinds the material from the mesh
  101372. */
  101373. unbind(): void;
  101374. /**
  101375. * Binds the submesh to this material by preparing the effect and shader to draw
  101376. * @param world defines the world transformation matrix
  101377. * @param mesh defines the mesh containing the submesh
  101378. * @param subMesh defines the submesh to bind the material to
  101379. */
  101380. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101381. /**
  101382. * Get the list of animatables in the material.
  101383. * @returns the list of animatables object used in the material
  101384. */
  101385. getAnimatables(): IAnimatable[];
  101386. /**
  101387. * Gets the active textures from the material
  101388. * @returns an array of textures
  101389. */
  101390. getActiveTextures(): BaseTexture[];
  101391. /**
  101392. * Specifies if the material uses a texture
  101393. * @param texture defines the texture to check against the material
  101394. * @returns a boolean specifying if the material uses the texture
  101395. */
  101396. hasTexture(texture: BaseTexture): boolean;
  101397. /**
  101398. * Disposes the material
  101399. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101400. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101401. */
  101402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101403. /**
  101404. * Makes a duplicate of the material, and gives it a new name
  101405. * @param name defines the new name for the duplicated material
  101406. * @returns the cloned material
  101407. */
  101408. clone(name: string): StandardMaterial;
  101409. /**
  101410. * Serializes this material in a JSON representation
  101411. * @returns the serialized material object
  101412. */
  101413. serialize(): any;
  101414. /**
  101415. * Creates a standard material from parsed material data
  101416. * @param source defines the JSON representation of the material
  101417. * @param scene defines the hosting scene
  101418. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101419. * @returns a new standard material
  101420. */
  101421. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101422. /**
  101423. * Are diffuse textures enabled in the application.
  101424. */
  101425. static get DiffuseTextureEnabled(): boolean;
  101426. static set DiffuseTextureEnabled(value: boolean);
  101427. /**
  101428. * Are ambient textures enabled in the application.
  101429. */
  101430. static get AmbientTextureEnabled(): boolean;
  101431. static set AmbientTextureEnabled(value: boolean);
  101432. /**
  101433. * Are opacity textures enabled in the application.
  101434. */
  101435. static get OpacityTextureEnabled(): boolean;
  101436. static set OpacityTextureEnabled(value: boolean);
  101437. /**
  101438. * Are reflection textures enabled in the application.
  101439. */
  101440. static get ReflectionTextureEnabled(): boolean;
  101441. static set ReflectionTextureEnabled(value: boolean);
  101442. /**
  101443. * Are emissive textures enabled in the application.
  101444. */
  101445. static get EmissiveTextureEnabled(): boolean;
  101446. static set EmissiveTextureEnabled(value: boolean);
  101447. /**
  101448. * Are specular textures enabled in the application.
  101449. */
  101450. static get SpecularTextureEnabled(): boolean;
  101451. static set SpecularTextureEnabled(value: boolean);
  101452. /**
  101453. * Are bump textures enabled in the application.
  101454. */
  101455. static get BumpTextureEnabled(): boolean;
  101456. static set BumpTextureEnabled(value: boolean);
  101457. /**
  101458. * Are lightmap textures enabled in the application.
  101459. */
  101460. static get LightmapTextureEnabled(): boolean;
  101461. static set LightmapTextureEnabled(value: boolean);
  101462. /**
  101463. * Are refraction textures enabled in the application.
  101464. */
  101465. static get RefractionTextureEnabled(): boolean;
  101466. static set RefractionTextureEnabled(value: boolean);
  101467. /**
  101468. * Are color grading textures enabled in the application.
  101469. */
  101470. static get ColorGradingTextureEnabled(): boolean;
  101471. static set ColorGradingTextureEnabled(value: boolean);
  101472. /**
  101473. * Are fresnels enabled in the application.
  101474. */
  101475. static get FresnelEnabled(): boolean;
  101476. static set FresnelEnabled(value: boolean);
  101477. }
  101478. }
  101479. declare module BABYLON {
  101480. /**
  101481. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101482. *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.
  101483. * The SPS is also a particle system. It provides some methods to manage the particles.
  101484. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101485. *
  101486. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101487. */
  101488. export class SolidParticleSystem implements IDisposable {
  101489. /**
  101490. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101491. * Example : var p = SPS.particles[i];
  101492. */
  101493. particles: SolidParticle[];
  101494. /**
  101495. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101496. */
  101497. nbParticles: number;
  101498. /**
  101499. * If the particles must ever face the camera (default false). Useful for planar particles.
  101500. */
  101501. billboard: boolean;
  101502. /**
  101503. * Recompute normals when adding a shape
  101504. */
  101505. recomputeNormals: boolean;
  101506. /**
  101507. * This a counter ofr your own usage. It's not set by any SPS functions.
  101508. */
  101509. counter: number;
  101510. /**
  101511. * The SPS name. This name is also given to the underlying mesh.
  101512. */
  101513. name: string;
  101514. /**
  101515. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101516. */
  101517. mesh: Mesh;
  101518. /**
  101519. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101520. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101521. */
  101522. vars: any;
  101523. /**
  101524. * This array is populated when the SPS is set as 'pickable'.
  101525. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101526. * Each element of this array is an object `{idx: int, faceId: int}`.
  101527. * `idx` is the picked particle index in the `SPS.particles` array
  101528. * `faceId` is the picked face index counted within this particle.
  101529. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101530. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101531. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101532. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101533. */
  101534. pickedParticles: {
  101535. idx: number;
  101536. faceId: number;
  101537. }[];
  101538. /**
  101539. * This array is populated when the SPS is set as 'pickable'
  101540. * Each key of this array is a submesh index.
  101541. * Each element of this array is a second array defined like this :
  101542. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101543. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101544. * `idx` is the picked particle index in the `SPS.particles` array
  101545. * `faceId` is the picked face index counted within this particle.
  101546. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101547. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101548. */
  101549. pickedBySubMesh: {
  101550. idx: number;
  101551. faceId: number;
  101552. }[][];
  101553. /**
  101554. * This array is populated when `enableDepthSort` is set to true.
  101555. * Each element of this array is an instance of the class DepthSortedParticle.
  101556. */
  101557. depthSortedParticles: DepthSortedParticle[];
  101558. /**
  101559. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101560. * @hidden
  101561. */
  101562. _bSphereOnly: boolean;
  101563. /**
  101564. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101565. * @hidden
  101566. */
  101567. _bSphereRadiusFactor: number;
  101568. private _scene;
  101569. private _positions;
  101570. private _indices;
  101571. private _normals;
  101572. private _colors;
  101573. private _uvs;
  101574. private _indices32;
  101575. private _positions32;
  101576. private _normals32;
  101577. private _fixedNormal32;
  101578. private _colors32;
  101579. private _uvs32;
  101580. private _index;
  101581. private _updatable;
  101582. private _pickable;
  101583. private _isVisibilityBoxLocked;
  101584. private _alwaysVisible;
  101585. private _depthSort;
  101586. private _expandable;
  101587. private _shapeCounter;
  101588. private _copy;
  101589. private _color;
  101590. private _computeParticleColor;
  101591. private _computeParticleTexture;
  101592. private _computeParticleRotation;
  101593. private _computeParticleVertex;
  101594. private _computeBoundingBox;
  101595. private _depthSortParticles;
  101596. private _camera;
  101597. private _mustUnrotateFixedNormals;
  101598. private _particlesIntersect;
  101599. private _needs32Bits;
  101600. private _isNotBuilt;
  101601. private _lastParticleId;
  101602. private _idxOfId;
  101603. private _multimaterialEnabled;
  101604. private _useModelMaterial;
  101605. private _indicesByMaterial;
  101606. private _materialIndexes;
  101607. private _depthSortFunction;
  101608. private _materialSortFunction;
  101609. private _materials;
  101610. private _multimaterial;
  101611. private _materialIndexesById;
  101612. private _defaultMaterial;
  101613. private _autoUpdateSubMeshes;
  101614. /**
  101615. * Creates a SPS (Solid Particle System) object.
  101616. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101617. * @param scene (Scene) is the scene in which the SPS is added.
  101618. * @param options defines the options of the sps e.g.
  101619. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101620. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101621. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101622. * * 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.
  101623. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101624. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101625. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101626. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101627. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101628. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101629. */
  101630. constructor(name: string, scene: Scene, options?: {
  101631. updatable?: boolean;
  101632. isPickable?: boolean;
  101633. enableDepthSort?: boolean;
  101634. particleIntersection?: boolean;
  101635. boundingSphereOnly?: boolean;
  101636. bSphereRadiusFactor?: number;
  101637. expandable?: boolean;
  101638. useModelMaterial?: boolean;
  101639. enableMultiMaterial?: boolean;
  101640. });
  101641. /**
  101642. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101643. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101644. * @returns the created mesh
  101645. */
  101646. buildMesh(): Mesh;
  101647. /**
  101648. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101649. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101650. * Thus the particles generated from `digest()` have their property `position` set yet.
  101651. * @param mesh ( Mesh ) is the mesh to be digested
  101652. * @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
  101653. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101654. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101655. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101656. * @returns the current SPS
  101657. */
  101658. digest(mesh: Mesh, options?: {
  101659. facetNb?: number;
  101660. number?: number;
  101661. delta?: number;
  101662. storage?: [];
  101663. }): SolidParticleSystem;
  101664. /**
  101665. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101666. * @hidden
  101667. */
  101668. private _unrotateFixedNormals;
  101669. /**
  101670. * Resets the temporary working copy particle
  101671. * @hidden
  101672. */
  101673. private _resetCopy;
  101674. /**
  101675. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101676. * @param p the current index in the positions array to be updated
  101677. * @param ind the current index in the indices array
  101678. * @param shape a Vector3 array, the shape geometry
  101679. * @param positions the positions array to be updated
  101680. * @param meshInd the shape indices array
  101681. * @param indices the indices array to be updated
  101682. * @param meshUV the shape uv array
  101683. * @param uvs the uv array to be updated
  101684. * @param meshCol the shape color array
  101685. * @param colors the color array to be updated
  101686. * @param meshNor the shape normals array
  101687. * @param normals the normals array to be updated
  101688. * @param idx the particle index
  101689. * @param idxInShape the particle index in its shape
  101690. * @param options the addShape() method passed options
  101691. * @model the particle model
  101692. * @hidden
  101693. */
  101694. private _meshBuilder;
  101695. /**
  101696. * Returns a shape Vector3 array from positions float array
  101697. * @param positions float array
  101698. * @returns a vector3 array
  101699. * @hidden
  101700. */
  101701. private _posToShape;
  101702. /**
  101703. * Returns a shapeUV array from a float uvs (array deep copy)
  101704. * @param uvs as a float array
  101705. * @returns a shapeUV array
  101706. * @hidden
  101707. */
  101708. private _uvsToShapeUV;
  101709. /**
  101710. * Adds a new particle object in the particles array
  101711. * @param idx particle index in particles array
  101712. * @param id particle id
  101713. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101714. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101715. * @param model particle ModelShape object
  101716. * @param shapeId model shape identifier
  101717. * @param idxInShape index of the particle in the current model
  101718. * @param bInfo model bounding info object
  101719. * @param storage target storage array, if any
  101720. * @hidden
  101721. */
  101722. private _addParticle;
  101723. /**
  101724. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101725. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101726. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101727. * @param nb (positive integer) the number of particles to be created from this model
  101728. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101729. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101730. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101731. * @returns the number of shapes in the system
  101732. */
  101733. addShape(mesh: Mesh, nb: number, options?: {
  101734. positionFunction?: any;
  101735. vertexFunction?: any;
  101736. storage?: [];
  101737. }): number;
  101738. /**
  101739. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101740. * @hidden
  101741. */
  101742. private _rebuildParticle;
  101743. /**
  101744. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101745. * @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.
  101746. * @returns the SPS.
  101747. */
  101748. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101749. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101750. * Returns an array with the removed particles.
  101751. * 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.
  101752. * The SPS can't be empty so at least one particle needs to remain in place.
  101753. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101754. * @param start index of the first particle to remove
  101755. * @param end index of the last particle to remove (included)
  101756. * @returns an array populated with the removed particles
  101757. */
  101758. removeParticles(start: number, end: number): SolidParticle[];
  101759. /**
  101760. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101761. * @param solidParticleArray an array populated with Solid Particles objects
  101762. * @returns the SPS
  101763. */
  101764. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101765. /**
  101766. * Creates a new particle and modifies the SPS mesh geometry :
  101767. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101768. * - calls _addParticle() to populate the particle array
  101769. * factorized code from addShape() and insertParticlesFromArray()
  101770. * @param idx particle index in the particles array
  101771. * @param i particle index in its shape
  101772. * @param modelShape particle ModelShape object
  101773. * @param shape shape vertex array
  101774. * @param meshInd shape indices array
  101775. * @param meshUV shape uv array
  101776. * @param meshCol shape color array
  101777. * @param meshNor shape normals array
  101778. * @param bbInfo shape bounding info
  101779. * @param storage target particle storage
  101780. * @options addShape() passed options
  101781. * @hidden
  101782. */
  101783. private _insertNewParticle;
  101784. /**
  101785. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101786. * This method calls `updateParticle()` for each particle of the SPS.
  101787. * For an animated SPS, it is usually called within the render loop.
  101788. * 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.
  101789. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101790. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101791. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101792. * @returns the SPS.
  101793. */
  101794. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101795. /**
  101796. * Disposes the SPS.
  101797. */
  101798. dispose(): void;
  101799. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101800. * idx is the particle index in the SPS
  101801. * faceId is the picked face index counted within this particle.
  101802. * Returns null if the pickInfo can't identify a picked particle.
  101803. * @param pickingInfo (PickingInfo object)
  101804. * @returns {idx: number, faceId: number} or null
  101805. */
  101806. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101807. idx: number;
  101808. faceId: number;
  101809. }>;
  101810. /**
  101811. * Returns a SolidParticle object from its identifier : particle.id
  101812. * @param id (integer) the particle Id
  101813. * @returns the searched particle or null if not found in the SPS.
  101814. */
  101815. getParticleById(id: number): Nullable<SolidParticle>;
  101816. /**
  101817. * Returns a new array populated with the particles having the passed shapeId.
  101818. * @param shapeId (integer) the shape identifier
  101819. * @returns a new solid particle array
  101820. */
  101821. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101822. /**
  101823. * Populates the passed array "ref" with the particles having the passed shapeId.
  101824. * @param shapeId the shape identifier
  101825. * @returns the SPS
  101826. * @param ref
  101827. */
  101828. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101829. /**
  101830. * Computes the required SubMeshes according the materials assigned to the particles.
  101831. * @returns the solid particle system.
  101832. * Does nothing if called before the SPS mesh is built.
  101833. */
  101834. computeSubMeshes(): SolidParticleSystem;
  101835. /**
  101836. * Sorts the solid particles by material when MultiMaterial is enabled.
  101837. * Updates the indices32 array.
  101838. * Updates the indicesByMaterial array.
  101839. * Updates the mesh indices array.
  101840. * @returns the SPS
  101841. * @hidden
  101842. */
  101843. private _sortParticlesByMaterial;
  101844. /**
  101845. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101846. * @hidden
  101847. */
  101848. private _setMaterialIndexesById;
  101849. /**
  101850. * Returns an array with unique values of Materials from the passed array
  101851. * @param array the material array to be checked and filtered
  101852. * @hidden
  101853. */
  101854. private _filterUniqueMaterialId;
  101855. /**
  101856. * Sets a new Standard Material as _defaultMaterial if not already set.
  101857. * @hidden
  101858. */
  101859. private _setDefaultMaterial;
  101860. /**
  101861. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101862. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101863. * @returns the SPS.
  101864. */
  101865. refreshVisibleSize(): SolidParticleSystem;
  101866. /**
  101867. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101868. * @param size the size (float) of the visibility box
  101869. * note : this doesn't lock the SPS mesh bounding box.
  101870. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101871. */
  101872. setVisibilityBox(size: number): void;
  101873. /**
  101874. * Gets whether the SPS as always visible or not
  101875. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101876. */
  101877. get isAlwaysVisible(): boolean;
  101878. /**
  101879. * Sets the SPS as always visible or not
  101880. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101881. */
  101882. set isAlwaysVisible(val: boolean);
  101883. /**
  101884. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101885. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101886. */
  101887. set isVisibilityBoxLocked(val: boolean);
  101888. /**
  101889. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101890. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101891. */
  101892. get isVisibilityBoxLocked(): boolean;
  101893. /**
  101894. * Tells to `setParticles()` to compute the particle rotations or not.
  101895. * Default value : true. The SPS is faster when it's set to false.
  101896. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101897. */
  101898. set computeParticleRotation(val: boolean);
  101899. /**
  101900. * Tells to `setParticles()` to compute the particle colors or not.
  101901. * Default value : true. The SPS is faster when it's set to false.
  101902. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101903. */
  101904. set computeParticleColor(val: boolean);
  101905. set computeParticleTexture(val: boolean);
  101906. /**
  101907. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101908. * Default value : false. The SPS is faster when it's set to false.
  101909. * Note : the particle custom vertex positions aren't stored values.
  101910. */
  101911. set computeParticleVertex(val: boolean);
  101912. /**
  101913. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101914. */
  101915. set computeBoundingBox(val: boolean);
  101916. /**
  101917. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101918. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101919. * Default : `true`
  101920. */
  101921. set depthSortParticles(val: boolean);
  101922. /**
  101923. * Gets if `setParticles()` computes the particle rotations or not.
  101924. * Default value : true. The SPS is faster when it's set to false.
  101925. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101926. */
  101927. get computeParticleRotation(): boolean;
  101928. /**
  101929. * Gets if `setParticles()` computes the particle colors or not.
  101930. * Default value : true. The SPS is faster when it's set to false.
  101931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101932. */
  101933. get computeParticleColor(): boolean;
  101934. /**
  101935. * Gets if `setParticles()` computes the particle textures or not.
  101936. * Default value : true. The SPS is faster when it's set to false.
  101937. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101938. */
  101939. get computeParticleTexture(): boolean;
  101940. /**
  101941. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101942. * Default value : false. The SPS is faster when it's set to false.
  101943. * Note : the particle custom vertex positions aren't stored values.
  101944. */
  101945. get computeParticleVertex(): boolean;
  101946. /**
  101947. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101948. */
  101949. get computeBoundingBox(): boolean;
  101950. /**
  101951. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101952. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101953. * Default : `true`
  101954. */
  101955. get depthSortParticles(): boolean;
  101956. /**
  101957. * Gets if the SPS is created as expandable at construction time.
  101958. * Default : `false`
  101959. */
  101960. get expandable(): boolean;
  101961. /**
  101962. * Gets if the SPS supports the Multi Materials
  101963. */
  101964. get multimaterialEnabled(): boolean;
  101965. /**
  101966. * Gets if the SPS uses the model materials for its own multimaterial.
  101967. */
  101968. get useModelMaterial(): boolean;
  101969. /**
  101970. * The SPS used material array.
  101971. */
  101972. get materials(): Material[];
  101973. /**
  101974. * Sets the SPS MultiMaterial from the passed materials.
  101975. * Note : the passed array is internally copied and not used then by reference.
  101976. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101977. */
  101978. setMultiMaterial(materials: Material[]): void;
  101979. /**
  101980. * The SPS computed multimaterial object
  101981. */
  101982. get multimaterial(): MultiMaterial;
  101983. set multimaterial(mm: MultiMaterial);
  101984. /**
  101985. * If the subMeshes must be updated on the next call to setParticles()
  101986. */
  101987. get autoUpdateSubMeshes(): boolean;
  101988. set autoUpdateSubMeshes(val: boolean);
  101989. /**
  101990. * This function does nothing. It may be overwritten to set all the particle first values.
  101991. * The SPS doesn't call this function, you may have to call it by your own.
  101992. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101993. */
  101994. initParticles(): void;
  101995. /**
  101996. * This function does nothing. It may be overwritten to recycle a particle.
  101997. * The SPS doesn't call this function, you may have to call it by your own.
  101998. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101999. * @param particle The particle to recycle
  102000. * @returns the recycled particle
  102001. */
  102002. recycleParticle(particle: SolidParticle): SolidParticle;
  102003. /**
  102004. * Updates a particle : this function should be overwritten by the user.
  102005. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  102006. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102007. * @example : just set a particle position or velocity and recycle conditions
  102008. * @param particle The particle to update
  102009. * @returns the updated particle
  102010. */
  102011. updateParticle(particle: SolidParticle): SolidParticle;
  102012. /**
  102013. * Updates a vertex of a particle : it can be overwritten by the user.
  102014. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  102015. * @param particle the current particle
  102016. * @param vertex the current index of the current particle
  102017. * @param pt the index of the current vertex in the particle shape
  102018. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  102019. * @example : just set a vertex particle position
  102020. * @returns the updated vertex
  102021. */
  102022. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  102023. /**
  102024. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  102025. * This does nothing and may be overwritten by the user.
  102026. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102027. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102028. * @param update the boolean update value actually passed to setParticles()
  102029. */
  102030. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102031. /**
  102032. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102033. * This will be passed three parameters.
  102034. * This does nothing and may be overwritten by the user.
  102035. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102036. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102037. * @param update the boolean update value actually passed to setParticles()
  102038. */
  102039. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102040. }
  102041. }
  102042. declare module BABYLON {
  102043. /**
  102044. * Represents one particle of a solid particle system.
  102045. */
  102046. export class SolidParticle {
  102047. /**
  102048. * particle global index
  102049. */
  102050. idx: number;
  102051. /**
  102052. * particle identifier
  102053. */
  102054. id: number;
  102055. /**
  102056. * The color of the particle
  102057. */
  102058. color: Nullable<Color4>;
  102059. /**
  102060. * The world space position of the particle.
  102061. */
  102062. position: Vector3;
  102063. /**
  102064. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102065. */
  102066. rotation: Vector3;
  102067. /**
  102068. * The world space rotation quaternion of the particle.
  102069. */
  102070. rotationQuaternion: Nullable<Quaternion>;
  102071. /**
  102072. * The scaling of the particle.
  102073. */
  102074. scaling: Vector3;
  102075. /**
  102076. * The uvs of the particle.
  102077. */
  102078. uvs: Vector4;
  102079. /**
  102080. * The current speed of the particle.
  102081. */
  102082. velocity: Vector3;
  102083. /**
  102084. * The pivot point in the particle local space.
  102085. */
  102086. pivot: Vector3;
  102087. /**
  102088. * Must the particle be translated from its pivot point in its local space ?
  102089. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102090. * Default : false
  102091. */
  102092. translateFromPivot: boolean;
  102093. /**
  102094. * Is the particle active or not ?
  102095. */
  102096. alive: boolean;
  102097. /**
  102098. * Is the particle visible or not ?
  102099. */
  102100. isVisible: boolean;
  102101. /**
  102102. * Index of this particle in the global "positions" array (Internal use)
  102103. * @hidden
  102104. */
  102105. _pos: number;
  102106. /**
  102107. * @hidden Index of this particle in the global "indices" array (Internal use)
  102108. */
  102109. _ind: number;
  102110. /**
  102111. * @hidden ModelShape of this particle (Internal use)
  102112. */
  102113. _model: ModelShape;
  102114. /**
  102115. * ModelShape id of this particle
  102116. */
  102117. shapeId: number;
  102118. /**
  102119. * Index of the particle in its shape id
  102120. */
  102121. idxInShape: number;
  102122. /**
  102123. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102124. */
  102125. _modelBoundingInfo: BoundingInfo;
  102126. /**
  102127. * @hidden Particle BoundingInfo object (Internal use)
  102128. */
  102129. _boundingInfo: BoundingInfo;
  102130. /**
  102131. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102132. */
  102133. _sps: SolidParticleSystem;
  102134. /**
  102135. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102136. */
  102137. _stillInvisible: boolean;
  102138. /**
  102139. * @hidden Last computed particle rotation matrix
  102140. */
  102141. _rotationMatrix: number[];
  102142. /**
  102143. * Parent particle Id, if any.
  102144. * Default null.
  102145. */
  102146. parentId: Nullable<number>;
  102147. /**
  102148. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102149. */
  102150. materialIndex: Nullable<number>;
  102151. /**
  102152. * Custom object or properties.
  102153. */
  102154. props: Nullable<any>;
  102155. /**
  102156. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102157. * The possible values are :
  102158. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102159. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102161. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102162. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102163. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102164. * */
  102165. cullingStrategy: number;
  102166. /**
  102167. * @hidden Internal global position in the SPS.
  102168. */
  102169. _globalPosition: Vector3;
  102170. /**
  102171. * Creates a Solid Particle object.
  102172. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102173. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102174. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102175. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102176. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102177. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102178. * @param shapeId (integer) is the model shape identifier in the SPS.
  102179. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102180. * @param sps defines the sps it is associated to
  102181. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102182. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102183. */
  102184. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102185. /**
  102186. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102187. * @param target the particle target
  102188. * @returns the current particle
  102189. */
  102190. copyToRef(target: SolidParticle): SolidParticle;
  102191. /**
  102192. * Legacy support, changed scale to scaling
  102193. */
  102194. get scale(): Vector3;
  102195. /**
  102196. * Legacy support, changed scale to scaling
  102197. */
  102198. set scale(scale: Vector3);
  102199. /**
  102200. * Legacy support, changed quaternion to rotationQuaternion
  102201. */
  102202. get quaternion(): Nullable<Quaternion>;
  102203. /**
  102204. * Legacy support, changed quaternion to rotationQuaternion
  102205. */
  102206. set quaternion(q: Nullable<Quaternion>);
  102207. /**
  102208. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102209. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102210. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102211. * @returns true if it intersects
  102212. */
  102213. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102214. /**
  102215. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102216. * A particle is in the frustum if its bounding box intersects the frustum
  102217. * @param frustumPlanes defines the frustum to test
  102218. * @returns true if the particle is in the frustum planes
  102219. */
  102220. isInFrustum(frustumPlanes: Plane[]): boolean;
  102221. /**
  102222. * get the rotation matrix of the particle
  102223. * @hidden
  102224. */
  102225. getRotationMatrix(m: Matrix): void;
  102226. }
  102227. /**
  102228. * Represents the shape of the model used by one particle of a solid particle system.
  102229. * SPS internal tool, don't use it manually.
  102230. */
  102231. export class ModelShape {
  102232. /**
  102233. * The shape id
  102234. * @hidden
  102235. */
  102236. shapeID: number;
  102237. /**
  102238. * flat array of model positions (internal use)
  102239. * @hidden
  102240. */
  102241. _shape: Vector3[];
  102242. /**
  102243. * flat array of model UVs (internal use)
  102244. * @hidden
  102245. */
  102246. _shapeUV: number[];
  102247. /**
  102248. * color array of the model
  102249. * @hidden
  102250. */
  102251. _shapeColors: number[];
  102252. /**
  102253. * indices array of the model
  102254. * @hidden
  102255. */
  102256. _indices: number[];
  102257. /**
  102258. * normals array of the model
  102259. * @hidden
  102260. */
  102261. _normals: number[];
  102262. /**
  102263. * length of the shape in the model indices array (internal use)
  102264. * @hidden
  102265. */
  102266. _indicesLength: number;
  102267. /**
  102268. * Custom position function (internal use)
  102269. * @hidden
  102270. */
  102271. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102272. /**
  102273. * Custom vertex function (internal use)
  102274. * @hidden
  102275. */
  102276. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102277. /**
  102278. * Model material (internal use)
  102279. * @hidden
  102280. */
  102281. _material: Nullable<Material>;
  102282. /**
  102283. * 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.
  102284. * SPS internal tool, don't use it manually.
  102285. * @hidden
  102286. */
  102287. 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>);
  102288. }
  102289. /**
  102290. * Represents a Depth Sorted Particle in the solid particle system.
  102291. * @hidden
  102292. */
  102293. export class DepthSortedParticle {
  102294. /**
  102295. * Particle index
  102296. */
  102297. idx: number;
  102298. /**
  102299. * Index of the particle in the "indices" array
  102300. */
  102301. ind: number;
  102302. /**
  102303. * Length of the particle shape in the "indices" array
  102304. */
  102305. indicesLength: number;
  102306. /**
  102307. * Squared distance from the particle to the camera
  102308. */
  102309. sqDistance: number;
  102310. /**
  102311. * Material index when used with MultiMaterials
  102312. */
  102313. materialIndex: number;
  102314. /**
  102315. * Creates a new sorted particle
  102316. * @param materialIndex
  102317. */
  102318. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102319. }
  102320. }
  102321. declare module BABYLON {
  102322. /**
  102323. * @hidden
  102324. */
  102325. export class _MeshCollisionData {
  102326. _checkCollisions: boolean;
  102327. _collisionMask: number;
  102328. _collisionGroup: number;
  102329. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102330. _collider: Nullable<Collider>;
  102331. _oldPositionForCollisions: Vector3;
  102332. _diffPositionForCollisions: Vector3;
  102333. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102334. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102335. }
  102336. }
  102337. declare module BABYLON {
  102338. /** @hidden */
  102339. class _FacetDataStorage {
  102340. facetPositions: Vector3[];
  102341. facetNormals: Vector3[];
  102342. facetPartitioning: number[][];
  102343. facetNb: number;
  102344. partitioningSubdivisions: number;
  102345. partitioningBBoxRatio: number;
  102346. facetDataEnabled: boolean;
  102347. facetParameters: any;
  102348. bbSize: Vector3;
  102349. subDiv: {
  102350. max: number;
  102351. X: number;
  102352. Y: number;
  102353. Z: number;
  102354. };
  102355. facetDepthSort: boolean;
  102356. facetDepthSortEnabled: boolean;
  102357. depthSortedIndices: IndicesArray;
  102358. depthSortedFacets: {
  102359. ind: number;
  102360. sqDistance: number;
  102361. }[];
  102362. facetDepthSortFunction: (f1: {
  102363. ind: number;
  102364. sqDistance: number;
  102365. }, f2: {
  102366. ind: number;
  102367. sqDistance: number;
  102368. }) => number;
  102369. facetDepthSortFrom: Vector3;
  102370. facetDepthSortOrigin: Vector3;
  102371. invertedMatrix: Matrix;
  102372. }
  102373. /**
  102374. * @hidden
  102375. **/
  102376. class _InternalAbstractMeshDataInfo {
  102377. _hasVertexAlpha: boolean;
  102378. _useVertexColors: boolean;
  102379. _numBoneInfluencers: number;
  102380. _applyFog: boolean;
  102381. _receiveShadows: boolean;
  102382. _facetData: _FacetDataStorage;
  102383. _visibility: number;
  102384. _skeleton: Nullable<Skeleton>;
  102385. _layerMask: number;
  102386. _computeBonesUsingShaders: boolean;
  102387. _isActive: boolean;
  102388. _onlyForInstances: boolean;
  102389. _isActiveIntermediate: boolean;
  102390. _onlyForInstancesIntermediate: boolean;
  102391. _actAsRegularMesh: boolean;
  102392. }
  102393. /**
  102394. * Class used to store all common mesh properties
  102395. */
  102396. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102397. /** No occlusion */
  102398. static OCCLUSION_TYPE_NONE: number;
  102399. /** Occlusion set to optimisitic */
  102400. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102401. /** Occlusion set to strict */
  102402. static OCCLUSION_TYPE_STRICT: number;
  102403. /** Use an accurante occlusion algorithm */
  102404. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102405. /** Use a conservative occlusion algorithm */
  102406. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102407. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102408. * Test order :
  102409. * Is the bounding sphere outside the frustum ?
  102410. * If not, are the bounding box vertices outside the frustum ?
  102411. * It not, then the cullable object is in the frustum.
  102412. */
  102413. static readonly CULLINGSTRATEGY_STANDARD: number;
  102414. /** Culling strategy : Bounding Sphere Only.
  102415. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102416. * It's also less accurate than the standard because some not visible objects can still be selected.
  102417. * Test : is the bounding sphere outside the frustum ?
  102418. * If not, then the cullable object is in the frustum.
  102419. */
  102420. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102421. /** Culling strategy : Optimistic Inclusion.
  102422. * This in an inclusion test first, then the standard exclusion test.
  102423. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102424. * 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.
  102425. * Anyway, it's as accurate as the standard strategy.
  102426. * Test :
  102427. * Is the cullable object bounding sphere center in the frustum ?
  102428. * If not, apply the default culling strategy.
  102429. */
  102430. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102431. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102432. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102433. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102434. * 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.
  102435. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102436. * Test :
  102437. * Is the cullable object bounding sphere center in the frustum ?
  102438. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102439. */
  102440. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102441. /**
  102442. * No billboard
  102443. */
  102444. static get BILLBOARDMODE_NONE(): number;
  102445. /** Billboard on X axis */
  102446. static get BILLBOARDMODE_X(): number;
  102447. /** Billboard on Y axis */
  102448. static get BILLBOARDMODE_Y(): number;
  102449. /** Billboard on Z axis */
  102450. static get BILLBOARDMODE_Z(): number;
  102451. /** Billboard on all axes */
  102452. static get BILLBOARDMODE_ALL(): number;
  102453. /** Billboard on using position instead of orientation */
  102454. static get BILLBOARDMODE_USE_POSITION(): number;
  102455. /** @hidden */
  102456. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102457. /**
  102458. * The culling strategy to use to check whether the mesh must be rendered or not.
  102459. * This value can be changed at any time and will be used on the next render mesh selection.
  102460. * The possible values are :
  102461. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102462. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102463. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102464. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102465. * Please read each static variable documentation to get details about the culling process.
  102466. * */
  102467. cullingStrategy: number;
  102468. /**
  102469. * Gets the number of facets in the mesh
  102470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102471. */
  102472. get facetNb(): number;
  102473. /**
  102474. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102476. */
  102477. get partitioningSubdivisions(): number;
  102478. set partitioningSubdivisions(nb: number);
  102479. /**
  102480. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102481. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102483. */
  102484. get partitioningBBoxRatio(): number;
  102485. set partitioningBBoxRatio(ratio: number);
  102486. /**
  102487. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102488. * Works only for updatable meshes.
  102489. * Doesn't work with multi-materials
  102490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102491. */
  102492. get mustDepthSortFacets(): boolean;
  102493. set mustDepthSortFacets(sort: boolean);
  102494. /**
  102495. * The location (Vector3) where the facet depth sort must be computed from.
  102496. * By default, the active camera position.
  102497. * Used only when facet depth sort is enabled
  102498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102499. */
  102500. get facetDepthSortFrom(): Vector3;
  102501. set facetDepthSortFrom(location: Vector3);
  102502. /**
  102503. * gets a boolean indicating if facetData is enabled
  102504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102505. */
  102506. get isFacetDataEnabled(): boolean;
  102507. /** @hidden */
  102508. _updateNonUniformScalingState(value: boolean): boolean;
  102509. /**
  102510. * An event triggered when this mesh collides with another one
  102511. */
  102512. onCollideObservable: Observable<AbstractMesh>;
  102513. /** Set a function to call when this mesh collides with another one */
  102514. set onCollide(callback: () => void);
  102515. /**
  102516. * An event triggered when the collision's position changes
  102517. */
  102518. onCollisionPositionChangeObservable: Observable<Vector3>;
  102519. /** Set a function to call when the collision's position changes */
  102520. set onCollisionPositionChange(callback: () => void);
  102521. /**
  102522. * An event triggered when material is changed
  102523. */
  102524. onMaterialChangedObservable: Observable<AbstractMesh>;
  102525. /**
  102526. * Gets or sets the orientation for POV movement & rotation
  102527. */
  102528. definedFacingForward: boolean;
  102529. /** @hidden */
  102530. _occlusionQuery: Nullable<WebGLQuery>;
  102531. /** @hidden */
  102532. _renderingGroup: Nullable<RenderingGroup>;
  102533. /**
  102534. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102535. */
  102536. get visibility(): number;
  102537. /**
  102538. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102539. */
  102540. set visibility(value: number);
  102541. /** Gets or sets the alpha index used to sort transparent meshes
  102542. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102543. */
  102544. alphaIndex: number;
  102545. /**
  102546. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102547. */
  102548. isVisible: boolean;
  102549. /**
  102550. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102551. */
  102552. isPickable: boolean;
  102553. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102554. showSubMeshesBoundingBox: boolean;
  102555. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102556. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102557. */
  102558. isBlocker: boolean;
  102559. /**
  102560. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102561. */
  102562. enablePointerMoveEvents: boolean;
  102563. /**
  102564. * Specifies the rendering group id for this mesh (0 by default)
  102565. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102566. */
  102567. renderingGroupId: number;
  102568. private _material;
  102569. /** Gets or sets current material */
  102570. get material(): Nullable<Material>;
  102571. set material(value: Nullable<Material>);
  102572. /**
  102573. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102574. * @see http://doc.babylonjs.com/babylon101/shadows
  102575. */
  102576. get receiveShadows(): boolean;
  102577. set receiveShadows(value: boolean);
  102578. /** Defines color to use when rendering outline */
  102579. outlineColor: Color3;
  102580. /** Define width to use when rendering outline */
  102581. outlineWidth: number;
  102582. /** Defines color to use when rendering overlay */
  102583. overlayColor: Color3;
  102584. /** Defines alpha to use when rendering overlay */
  102585. overlayAlpha: number;
  102586. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102587. get hasVertexAlpha(): boolean;
  102588. set hasVertexAlpha(value: boolean);
  102589. /** 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) */
  102590. get useVertexColors(): boolean;
  102591. set useVertexColors(value: boolean);
  102592. /**
  102593. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102594. */
  102595. get computeBonesUsingShaders(): boolean;
  102596. set computeBonesUsingShaders(value: boolean);
  102597. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102598. get numBoneInfluencers(): number;
  102599. set numBoneInfluencers(value: number);
  102600. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102601. get applyFog(): boolean;
  102602. set applyFog(value: boolean);
  102603. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102604. useOctreeForRenderingSelection: boolean;
  102605. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102606. useOctreeForPicking: boolean;
  102607. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102608. useOctreeForCollisions: boolean;
  102609. /**
  102610. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102611. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102612. */
  102613. get layerMask(): number;
  102614. set layerMask(value: number);
  102615. /**
  102616. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102617. */
  102618. alwaysSelectAsActiveMesh: boolean;
  102619. /**
  102620. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102621. */
  102622. doNotSyncBoundingInfo: boolean;
  102623. /**
  102624. * Gets or sets the current action manager
  102625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102626. */
  102627. actionManager: Nullable<AbstractActionManager>;
  102628. private _meshCollisionData;
  102629. /**
  102630. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102632. */
  102633. ellipsoid: Vector3;
  102634. /**
  102635. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102637. */
  102638. ellipsoidOffset: Vector3;
  102639. /**
  102640. * Gets or sets a collision mask used to mask collisions (default is -1).
  102641. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102642. */
  102643. get collisionMask(): number;
  102644. set collisionMask(mask: number);
  102645. /**
  102646. * Gets or sets the current collision group mask (-1 by default).
  102647. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102648. */
  102649. get collisionGroup(): number;
  102650. set collisionGroup(mask: number);
  102651. /**
  102652. * Gets or sets current surrounding meshes (null by default).
  102653. *
  102654. * By default collision detection is tested against every mesh in the scene.
  102655. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102656. * meshes will be tested for the collision.
  102657. *
  102658. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102659. */
  102660. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102661. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102662. /**
  102663. * Defines edge width used when edgesRenderer is enabled
  102664. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102665. */
  102666. edgesWidth: number;
  102667. /**
  102668. * Defines edge color used when edgesRenderer is enabled
  102669. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102670. */
  102671. edgesColor: Color4;
  102672. /** @hidden */
  102673. _edgesRenderer: Nullable<IEdgesRenderer>;
  102674. /** @hidden */
  102675. _masterMesh: Nullable<AbstractMesh>;
  102676. /** @hidden */
  102677. _boundingInfo: Nullable<BoundingInfo>;
  102678. /** @hidden */
  102679. _renderId: number;
  102680. /**
  102681. * Gets or sets the list of subMeshes
  102682. * @see http://doc.babylonjs.com/how_to/multi_materials
  102683. */
  102684. subMeshes: SubMesh[];
  102685. /** @hidden */
  102686. _intersectionsInProgress: AbstractMesh[];
  102687. /** @hidden */
  102688. _unIndexed: boolean;
  102689. /** @hidden */
  102690. _lightSources: Light[];
  102691. /** Gets the list of lights affecting that mesh */
  102692. get lightSources(): Light[];
  102693. /** @hidden */
  102694. get _positions(): Nullable<Vector3[]>;
  102695. /** @hidden */
  102696. _waitingData: {
  102697. lods: Nullable<any>;
  102698. actions: Nullable<any>;
  102699. freezeWorldMatrix: Nullable<boolean>;
  102700. };
  102701. /** @hidden */
  102702. _bonesTransformMatrices: Nullable<Float32Array>;
  102703. /** @hidden */
  102704. _transformMatrixTexture: Nullable<RawTexture>;
  102705. /**
  102706. * Gets or sets a skeleton to apply skining transformations
  102707. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102708. */
  102709. set skeleton(value: Nullable<Skeleton>);
  102710. get skeleton(): Nullable<Skeleton>;
  102711. /**
  102712. * An event triggered when the mesh is rebuilt.
  102713. */
  102714. onRebuildObservable: Observable<AbstractMesh>;
  102715. /**
  102716. * Creates a new AbstractMesh
  102717. * @param name defines the name of the mesh
  102718. * @param scene defines the hosting scene
  102719. */
  102720. constructor(name: string, scene?: Nullable<Scene>);
  102721. /**
  102722. * Returns the string "AbstractMesh"
  102723. * @returns "AbstractMesh"
  102724. */
  102725. getClassName(): string;
  102726. /**
  102727. * Gets a string representation of the current mesh
  102728. * @param fullDetails defines a boolean indicating if full details must be included
  102729. * @returns a string representation of the current mesh
  102730. */
  102731. toString(fullDetails?: boolean): string;
  102732. /**
  102733. * @hidden
  102734. */
  102735. protected _getEffectiveParent(): Nullable<Node>;
  102736. /** @hidden */
  102737. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102738. /** @hidden */
  102739. _rebuild(): void;
  102740. /** @hidden */
  102741. _resyncLightSources(): void;
  102742. /** @hidden */
  102743. _resyncLightSource(light: Light): void;
  102744. /** @hidden */
  102745. _unBindEffect(): void;
  102746. /** @hidden */
  102747. _removeLightSource(light: Light, dispose: boolean): void;
  102748. private _markSubMeshesAsDirty;
  102749. /** @hidden */
  102750. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102751. /** @hidden */
  102752. _markSubMeshesAsAttributesDirty(): void;
  102753. /** @hidden */
  102754. _markSubMeshesAsMiscDirty(): void;
  102755. /**
  102756. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102757. */
  102758. get scaling(): Vector3;
  102759. set scaling(newScaling: Vector3);
  102760. /**
  102761. * Returns true if the mesh is blocked. Implemented by child classes
  102762. */
  102763. get isBlocked(): boolean;
  102764. /**
  102765. * Returns the mesh itself by default. Implemented by child classes
  102766. * @param camera defines the camera to use to pick the right LOD level
  102767. * @returns the currentAbstractMesh
  102768. */
  102769. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102770. /**
  102771. * Returns 0 by default. Implemented by child classes
  102772. * @returns an integer
  102773. */
  102774. getTotalVertices(): number;
  102775. /**
  102776. * Returns a positive integer : the total number of indices in this mesh geometry.
  102777. * @returns the numner of indices or zero if the mesh has no geometry.
  102778. */
  102779. getTotalIndices(): number;
  102780. /**
  102781. * Returns null by default. Implemented by child classes
  102782. * @returns null
  102783. */
  102784. getIndices(): Nullable<IndicesArray>;
  102785. /**
  102786. * Returns the array of the requested vertex data kind. Implemented by child classes
  102787. * @param kind defines the vertex data kind to use
  102788. * @returns null
  102789. */
  102790. getVerticesData(kind: string): Nullable<FloatArray>;
  102791. /**
  102792. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102793. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102794. * Note that a new underlying VertexBuffer object is created each call.
  102795. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102796. * @param kind defines vertex data kind:
  102797. * * VertexBuffer.PositionKind
  102798. * * VertexBuffer.UVKind
  102799. * * VertexBuffer.UV2Kind
  102800. * * VertexBuffer.UV3Kind
  102801. * * VertexBuffer.UV4Kind
  102802. * * VertexBuffer.UV5Kind
  102803. * * VertexBuffer.UV6Kind
  102804. * * VertexBuffer.ColorKind
  102805. * * VertexBuffer.MatricesIndicesKind
  102806. * * VertexBuffer.MatricesIndicesExtraKind
  102807. * * VertexBuffer.MatricesWeightsKind
  102808. * * VertexBuffer.MatricesWeightsExtraKind
  102809. * @param data defines the data source
  102810. * @param updatable defines if the data must be flagged as updatable (or static)
  102811. * @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
  102812. * @returns the current mesh
  102813. */
  102814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102815. /**
  102816. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102817. * If the mesh has no geometry, it is simply returned as it is.
  102818. * @param kind defines vertex data kind:
  102819. * * VertexBuffer.PositionKind
  102820. * * VertexBuffer.UVKind
  102821. * * VertexBuffer.UV2Kind
  102822. * * VertexBuffer.UV3Kind
  102823. * * VertexBuffer.UV4Kind
  102824. * * VertexBuffer.UV5Kind
  102825. * * VertexBuffer.UV6Kind
  102826. * * VertexBuffer.ColorKind
  102827. * * VertexBuffer.MatricesIndicesKind
  102828. * * VertexBuffer.MatricesIndicesExtraKind
  102829. * * VertexBuffer.MatricesWeightsKind
  102830. * * VertexBuffer.MatricesWeightsExtraKind
  102831. * @param data defines the data source
  102832. * @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
  102833. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102834. * @returns the current mesh
  102835. */
  102836. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102837. /**
  102838. * Sets the mesh indices,
  102839. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102840. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102841. * @param totalVertices Defines the total number of vertices
  102842. * @returns the current mesh
  102843. */
  102844. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102845. /**
  102846. * Gets a boolean indicating if specific vertex data is present
  102847. * @param kind defines the vertex data kind to use
  102848. * @returns true is data kind is present
  102849. */
  102850. isVerticesDataPresent(kind: string): boolean;
  102851. /**
  102852. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102853. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102854. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102855. * @returns a BoundingInfo
  102856. */
  102857. getBoundingInfo(): BoundingInfo;
  102858. /**
  102859. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102860. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102861. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102862. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102863. * @returns the current mesh
  102864. */
  102865. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102866. /**
  102867. * Overwrite the current bounding info
  102868. * @param boundingInfo defines the new bounding info
  102869. * @returns the current mesh
  102870. */
  102871. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102872. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102873. get useBones(): boolean;
  102874. /** @hidden */
  102875. _preActivate(): void;
  102876. /** @hidden */
  102877. _preActivateForIntermediateRendering(renderId: number): void;
  102878. /** @hidden */
  102879. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102880. /** @hidden */
  102881. _postActivate(): void;
  102882. /** @hidden */
  102883. _freeze(): void;
  102884. /** @hidden */
  102885. _unFreeze(): void;
  102886. /**
  102887. * Gets the current world matrix
  102888. * @returns a Matrix
  102889. */
  102890. getWorldMatrix(): Matrix;
  102891. /** @hidden */
  102892. _getWorldMatrixDeterminant(): number;
  102893. /**
  102894. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102895. */
  102896. get isAnInstance(): boolean;
  102897. /**
  102898. * Gets a boolean indicating if this mesh has instances
  102899. */
  102900. get hasInstances(): boolean;
  102901. /**
  102902. * Perform relative position change from the point of view of behind the front of the mesh.
  102903. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102904. * Supports definition of mesh facing forward or backward
  102905. * @param amountRight defines the distance on the right axis
  102906. * @param amountUp defines the distance on the up axis
  102907. * @param amountForward defines the distance on the forward axis
  102908. * @returns the current mesh
  102909. */
  102910. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102911. /**
  102912. * Calculate relative position change from the point of view of behind the front of the mesh.
  102913. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102914. * Supports definition of mesh facing forward or backward
  102915. * @param amountRight defines the distance on the right axis
  102916. * @param amountUp defines the distance on the up axis
  102917. * @param amountForward defines the distance on the forward axis
  102918. * @returns the new displacement vector
  102919. */
  102920. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102921. /**
  102922. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102923. * Supports definition of mesh facing forward or backward
  102924. * @param flipBack defines the flip
  102925. * @param twirlClockwise defines the twirl
  102926. * @param tiltRight defines the tilt
  102927. * @returns the current mesh
  102928. */
  102929. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102930. /**
  102931. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102932. * Supports definition of mesh facing forward or backward.
  102933. * @param flipBack defines the flip
  102934. * @param twirlClockwise defines the twirl
  102935. * @param tiltRight defines the tilt
  102936. * @returns the new rotation vector
  102937. */
  102938. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102939. /**
  102940. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102941. * This means the mesh underlying bounding box and sphere are recomputed.
  102942. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102943. * @returns the current mesh
  102944. */
  102945. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102946. /** @hidden */
  102947. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102948. /** @hidden */
  102949. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102950. /** @hidden */
  102951. _updateBoundingInfo(): AbstractMesh;
  102952. /** @hidden */
  102953. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102954. /** @hidden */
  102955. protected _afterComputeWorldMatrix(): void;
  102956. /** @hidden */
  102957. get _effectiveMesh(): AbstractMesh;
  102958. /**
  102959. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102960. * A mesh is in the frustum if its bounding box intersects the frustum
  102961. * @param frustumPlanes defines the frustum to test
  102962. * @returns true if the mesh is in the frustum planes
  102963. */
  102964. isInFrustum(frustumPlanes: Plane[]): boolean;
  102965. /**
  102966. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102967. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102968. * @param frustumPlanes defines the frustum to test
  102969. * @returns true if the mesh is completely in the frustum planes
  102970. */
  102971. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102972. /**
  102973. * True if the mesh intersects another mesh or a SolidParticle object
  102974. * @param mesh defines a target mesh or SolidParticle to test
  102975. * @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)
  102976. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102977. * @returns true if there is an intersection
  102978. */
  102979. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102980. /**
  102981. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102982. * @param point defines the point to test
  102983. * @returns true if there is an intersection
  102984. */
  102985. intersectsPoint(point: Vector3): boolean;
  102986. /**
  102987. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102988. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102989. */
  102990. get checkCollisions(): boolean;
  102991. set checkCollisions(collisionEnabled: boolean);
  102992. /**
  102993. * Gets Collider object used to compute collisions (not physics)
  102994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102995. */
  102996. get collider(): Nullable<Collider>;
  102997. /**
  102998. * Move the mesh using collision engine
  102999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103000. * @param displacement defines the requested displacement vector
  103001. * @returns the current mesh
  103002. */
  103003. moveWithCollisions(displacement: Vector3): AbstractMesh;
  103004. private _onCollisionPositionChange;
  103005. /** @hidden */
  103006. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  103007. /** @hidden */
  103008. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  103009. /** @hidden */
  103010. _checkCollision(collider: Collider): AbstractMesh;
  103011. /** @hidden */
  103012. _generatePointsArray(): boolean;
  103013. /**
  103014. * Checks if the passed Ray intersects with the mesh
  103015. * @param ray defines the ray to use
  103016. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  103017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103018. * @returns the picking info
  103019. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  103020. */
  103021. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  103022. /**
  103023. * Clones the current mesh
  103024. * @param name defines the mesh name
  103025. * @param newParent defines the new mesh parent
  103026. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  103027. * @returns the new mesh
  103028. */
  103029. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103030. /**
  103031. * Disposes all the submeshes of the current meshnp
  103032. * @returns the current mesh
  103033. */
  103034. releaseSubMeshes(): AbstractMesh;
  103035. /**
  103036. * Releases resources associated with this abstract mesh.
  103037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103039. */
  103040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103041. /**
  103042. * Adds the passed mesh as a child to the current mesh
  103043. * @param mesh defines the child mesh
  103044. * @returns the current mesh
  103045. */
  103046. addChild(mesh: AbstractMesh): AbstractMesh;
  103047. /**
  103048. * Removes the passed mesh from the current mesh children list
  103049. * @param mesh defines the child mesh
  103050. * @returns the current mesh
  103051. */
  103052. removeChild(mesh: AbstractMesh): AbstractMesh;
  103053. /** @hidden */
  103054. private _initFacetData;
  103055. /**
  103056. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103057. * This method can be called within the render loop.
  103058. * 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
  103059. * @returns the current mesh
  103060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103061. */
  103062. updateFacetData(): AbstractMesh;
  103063. /**
  103064. * Returns the facetLocalNormals array.
  103065. * The normals are expressed in the mesh local spac
  103066. * @returns an array of Vector3
  103067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103068. */
  103069. getFacetLocalNormals(): Vector3[];
  103070. /**
  103071. * Returns the facetLocalPositions array.
  103072. * The facet positions are expressed in the mesh local space
  103073. * @returns an array of Vector3
  103074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103075. */
  103076. getFacetLocalPositions(): Vector3[];
  103077. /**
  103078. * Returns the facetLocalPartioning array
  103079. * @returns an array of array of numbers
  103080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103081. */
  103082. getFacetLocalPartitioning(): number[][];
  103083. /**
  103084. * Returns the i-th facet position in the world system.
  103085. * This method allocates a new Vector3 per call
  103086. * @param i defines the facet index
  103087. * @returns a new Vector3
  103088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103089. */
  103090. getFacetPosition(i: number): Vector3;
  103091. /**
  103092. * Sets the reference Vector3 with the i-th facet position in the world system
  103093. * @param i defines the facet index
  103094. * @param ref defines the target vector
  103095. * @returns the current mesh
  103096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103097. */
  103098. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103099. /**
  103100. * Returns the i-th facet normal in the world system.
  103101. * This method allocates a new Vector3 per call
  103102. * @param i defines the facet index
  103103. * @returns a new Vector3
  103104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103105. */
  103106. getFacetNormal(i: number): Vector3;
  103107. /**
  103108. * Sets the reference Vector3 with the i-th facet normal in the world system
  103109. * @param i defines the facet index
  103110. * @param ref defines the target vector
  103111. * @returns the current mesh
  103112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103113. */
  103114. getFacetNormalToRef(i: number, ref: Vector3): this;
  103115. /**
  103116. * 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)
  103117. * @param x defines x coordinate
  103118. * @param y defines y coordinate
  103119. * @param z defines z coordinate
  103120. * @returns the array of facet indexes
  103121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103122. */
  103123. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103124. /**
  103125. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103126. * @param projected sets as the (x,y,z) world projection on the facet
  103127. * @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
  103128. * @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
  103129. * @param x defines x coordinate
  103130. * @param y defines y coordinate
  103131. * @param z defines z coordinate
  103132. * @returns the face index if found (or null instead)
  103133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103134. */
  103135. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103136. /**
  103137. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103138. * @param projected sets as the (x,y,z) local projection on the facet
  103139. * @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
  103140. * @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
  103141. * @param x defines x coordinate
  103142. * @param y defines y coordinate
  103143. * @param z defines z coordinate
  103144. * @returns the face index if found (or null instead)
  103145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103146. */
  103147. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103148. /**
  103149. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103150. * @returns the parameters
  103151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103152. */
  103153. getFacetDataParameters(): any;
  103154. /**
  103155. * Disables the feature FacetData and frees the related memory
  103156. * @returns the current mesh
  103157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103158. */
  103159. disableFacetData(): AbstractMesh;
  103160. /**
  103161. * Updates the AbstractMesh indices array
  103162. * @param indices defines the data source
  103163. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103164. * @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)
  103165. * @returns the current mesh
  103166. */
  103167. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103168. /**
  103169. * Creates new normals data for the mesh
  103170. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103171. * @returns the current mesh
  103172. */
  103173. createNormals(updatable: boolean): AbstractMesh;
  103174. /**
  103175. * Align the mesh with a normal
  103176. * @param normal defines the normal to use
  103177. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103178. * @returns the current mesh
  103179. */
  103180. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103181. /** @hidden */
  103182. _checkOcclusionQuery(): boolean;
  103183. /**
  103184. * Disables the mesh edge rendering mode
  103185. * @returns the currentAbstractMesh
  103186. */
  103187. disableEdgesRendering(): AbstractMesh;
  103188. /**
  103189. * Enables the edge rendering mode on the mesh.
  103190. * This mode makes the mesh edges visible
  103191. * @param epsilon defines the maximal distance between two angles to detect a face
  103192. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103193. * @returns the currentAbstractMesh
  103194. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103195. */
  103196. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103197. }
  103198. }
  103199. declare module BABYLON {
  103200. /**
  103201. * Interface used to define ActionEvent
  103202. */
  103203. export interface IActionEvent {
  103204. /** The mesh or sprite that triggered the action */
  103205. source: any;
  103206. /** The X mouse cursor position at the time of the event */
  103207. pointerX: number;
  103208. /** The Y mouse cursor position at the time of the event */
  103209. pointerY: number;
  103210. /** The mesh that is currently pointed at (can be null) */
  103211. meshUnderPointer: Nullable<AbstractMesh>;
  103212. /** the original (browser) event that triggered the ActionEvent */
  103213. sourceEvent?: any;
  103214. /** additional data for the event */
  103215. additionalData?: any;
  103216. }
  103217. /**
  103218. * ActionEvent is the event being sent when an action is triggered.
  103219. */
  103220. export class ActionEvent implements IActionEvent {
  103221. /** The mesh or sprite that triggered the action */
  103222. source: any;
  103223. /** The X mouse cursor position at the time of the event */
  103224. pointerX: number;
  103225. /** The Y mouse cursor position at the time of the event */
  103226. pointerY: number;
  103227. /** The mesh that is currently pointed at (can be null) */
  103228. meshUnderPointer: Nullable<AbstractMesh>;
  103229. /** the original (browser) event that triggered the ActionEvent */
  103230. sourceEvent?: any;
  103231. /** additional data for the event */
  103232. additionalData?: any;
  103233. /**
  103234. * Creates a new ActionEvent
  103235. * @param source The mesh or sprite that triggered the action
  103236. * @param pointerX The X mouse cursor position at the time of the event
  103237. * @param pointerY The Y mouse cursor position at the time of the event
  103238. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103239. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103240. * @param additionalData additional data for the event
  103241. */
  103242. constructor(
  103243. /** The mesh or sprite that triggered the action */
  103244. source: any,
  103245. /** The X mouse cursor position at the time of the event */
  103246. pointerX: number,
  103247. /** The Y mouse cursor position at the time of the event */
  103248. pointerY: number,
  103249. /** The mesh that is currently pointed at (can be null) */
  103250. meshUnderPointer: Nullable<AbstractMesh>,
  103251. /** the original (browser) event that triggered the ActionEvent */
  103252. sourceEvent?: any,
  103253. /** additional data for the event */
  103254. additionalData?: any);
  103255. /**
  103256. * Helper function to auto-create an ActionEvent from a source mesh.
  103257. * @param source The source mesh that triggered the event
  103258. * @param evt The original (browser) event
  103259. * @param additionalData additional data for the event
  103260. * @returns the new ActionEvent
  103261. */
  103262. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103263. /**
  103264. * Helper function to auto-create an ActionEvent from a source sprite
  103265. * @param source The source sprite that triggered the event
  103266. * @param scene Scene associated with the sprite
  103267. * @param evt The original (browser) event
  103268. * @param additionalData additional data for the event
  103269. * @returns the new ActionEvent
  103270. */
  103271. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103272. /**
  103273. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103274. * @param scene the scene where the event occurred
  103275. * @param evt The original (browser) event
  103276. * @returns the new ActionEvent
  103277. */
  103278. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103279. /**
  103280. * Helper function to auto-create an ActionEvent from a primitive
  103281. * @param prim defines the target primitive
  103282. * @param pointerPos defines the pointer position
  103283. * @param evt The original (browser) event
  103284. * @param additionalData additional data for the event
  103285. * @returns the new ActionEvent
  103286. */
  103287. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103288. }
  103289. }
  103290. declare module BABYLON {
  103291. /**
  103292. * Abstract class used to decouple action Manager from scene and meshes.
  103293. * Do not instantiate.
  103294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103295. */
  103296. export abstract class AbstractActionManager implements IDisposable {
  103297. /** Gets the list of active triggers */
  103298. static Triggers: {
  103299. [key: string]: number;
  103300. };
  103301. /** Gets the cursor to use when hovering items */
  103302. hoverCursor: string;
  103303. /** Gets the list of actions */
  103304. actions: IAction[];
  103305. /**
  103306. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103307. */
  103308. isRecursive: boolean;
  103309. /**
  103310. * Releases all associated resources
  103311. */
  103312. abstract dispose(): void;
  103313. /**
  103314. * Does this action manager has pointer triggers
  103315. */
  103316. abstract get hasPointerTriggers(): boolean;
  103317. /**
  103318. * Does this action manager has pick triggers
  103319. */
  103320. abstract get hasPickTriggers(): boolean;
  103321. /**
  103322. * Process a specific trigger
  103323. * @param trigger defines the trigger to process
  103324. * @param evt defines the event details to be processed
  103325. */
  103326. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103327. /**
  103328. * Does this action manager handles actions of any of the given triggers
  103329. * @param triggers defines the triggers to be tested
  103330. * @return a boolean indicating whether one (or more) of the triggers is handled
  103331. */
  103332. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103333. /**
  103334. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103335. * speed.
  103336. * @param triggerA defines the trigger to be tested
  103337. * @param triggerB defines the trigger to be tested
  103338. * @return a boolean indicating whether one (or more) of the triggers is handled
  103339. */
  103340. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103341. /**
  103342. * Does this action manager handles actions of a given trigger
  103343. * @param trigger defines the trigger to be tested
  103344. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103345. * @return whether the trigger is handled
  103346. */
  103347. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103348. /**
  103349. * Serialize this manager to a JSON object
  103350. * @param name defines the property name to store this manager
  103351. * @returns a JSON representation of this manager
  103352. */
  103353. abstract serialize(name: string): any;
  103354. /**
  103355. * Registers an action to this action manager
  103356. * @param action defines the action to be registered
  103357. * @return the action amended (prepared) after registration
  103358. */
  103359. abstract registerAction(action: IAction): Nullable<IAction>;
  103360. /**
  103361. * Unregisters an action to this action manager
  103362. * @param action defines the action to be unregistered
  103363. * @return a boolean indicating whether the action has been unregistered
  103364. */
  103365. abstract unregisterAction(action: IAction): Boolean;
  103366. /**
  103367. * Does exist one action manager with at least one trigger
  103368. **/
  103369. static get HasTriggers(): boolean;
  103370. /**
  103371. * Does exist one action manager with at least one pick trigger
  103372. **/
  103373. static get HasPickTriggers(): boolean;
  103374. /**
  103375. * Does exist one action manager that handles actions of a given trigger
  103376. * @param trigger defines the trigger to be tested
  103377. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103378. **/
  103379. static HasSpecificTrigger(trigger: number): boolean;
  103380. }
  103381. }
  103382. declare module BABYLON {
  103383. /**
  103384. * Defines how a node can be built from a string name.
  103385. */
  103386. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103387. /**
  103388. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103389. */
  103390. export class Node implements IBehaviorAware<Node> {
  103391. /** @hidden */
  103392. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103393. private static _NodeConstructors;
  103394. /**
  103395. * Add a new node constructor
  103396. * @param type defines the type name of the node to construct
  103397. * @param constructorFunc defines the constructor function
  103398. */
  103399. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103400. /**
  103401. * Returns a node constructor based on type name
  103402. * @param type defines the type name
  103403. * @param name defines the new node name
  103404. * @param scene defines the hosting scene
  103405. * @param options defines optional options to transmit to constructors
  103406. * @returns the new constructor or null
  103407. */
  103408. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103409. /**
  103410. * Gets or sets the name of the node
  103411. */
  103412. name: string;
  103413. /**
  103414. * Gets or sets the id of the node
  103415. */
  103416. id: string;
  103417. /**
  103418. * Gets or sets the unique id of the node
  103419. */
  103420. uniqueId: number;
  103421. /**
  103422. * Gets or sets a string used to store user defined state for the node
  103423. */
  103424. state: string;
  103425. /**
  103426. * Gets or sets an object used to store user defined information for the node
  103427. */
  103428. metadata: any;
  103429. /**
  103430. * For internal use only. Please do not use.
  103431. */
  103432. reservedDataStore: any;
  103433. /**
  103434. * List of inspectable custom properties (used by the Inspector)
  103435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103436. */
  103437. inspectableCustomProperties: IInspectable[];
  103438. private _doNotSerialize;
  103439. /**
  103440. * Gets or sets a boolean used to define if the node must be serialized
  103441. */
  103442. get doNotSerialize(): boolean;
  103443. set doNotSerialize(value: boolean);
  103444. /** @hidden */
  103445. _isDisposed: boolean;
  103446. /**
  103447. * Gets a list of Animations associated with the node
  103448. */
  103449. animations: Animation[];
  103450. protected _ranges: {
  103451. [name: string]: Nullable<AnimationRange>;
  103452. };
  103453. /**
  103454. * Callback raised when the node is ready to be used
  103455. */
  103456. onReady: Nullable<(node: Node) => void>;
  103457. private _isEnabled;
  103458. private _isParentEnabled;
  103459. private _isReady;
  103460. /** @hidden */
  103461. _currentRenderId: number;
  103462. private _parentUpdateId;
  103463. /** @hidden */
  103464. _childUpdateId: number;
  103465. /** @hidden */
  103466. _waitingParentId: Nullable<string>;
  103467. /** @hidden */
  103468. _scene: Scene;
  103469. /** @hidden */
  103470. _cache: any;
  103471. private _parentNode;
  103472. private _children;
  103473. /** @hidden */
  103474. _worldMatrix: Matrix;
  103475. /** @hidden */
  103476. _worldMatrixDeterminant: number;
  103477. /** @hidden */
  103478. _worldMatrixDeterminantIsDirty: boolean;
  103479. /** @hidden */
  103480. private _sceneRootNodesIndex;
  103481. /**
  103482. * Gets a boolean indicating if the node has been disposed
  103483. * @returns true if the node was disposed
  103484. */
  103485. isDisposed(): boolean;
  103486. /**
  103487. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103488. * @see https://doc.babylonjs.com/how_to/parenting
  103489. */
  103490. set parent(parent: Nullable<Node>);
  103491. get parent(): Nullable<Node>;
  103492. /** @hidden */
  103493. _addToSceneRootNodes(): void;
  103494. /** @hidden */
  103495. _removeFromSceneRootNodes(): void;
  103496. private _animationPropertiesOverride;
  103497. /**
  103498. * Gets or sets the animation properties override
  103499. */
  103500. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103501. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103502. /**
  103503. * Gets a string idenfifying the name of the class
  103504. * @returns "Node" string
  103505. */
  103506. getClassName(): string;
  103507. /** @hidden */
  103508. readonly _isNode: boolean;
  103509. /**
  103510. * An event triggered when the mesh is disposed
  103511. */
  103512. onDisposeObservable: Observable<Node>;
  103513. private _onDisposeObserver;
  103514. /**
  103515. * Sets a callback that will be raised when the node will be disposed
  103516. */
  103517. set onDispose(callback: () => void);
  103518. /**
  103519. * Creates a new Node
  103520. * @param name the name and id to be given to this node
  103521. * @param scene the scene this node will be added to
  103522. */
  103523. constructor(name: string, scene?: Nullable<Scene>);
  103524. /**
  103525. * Gets the scene of the node
  103526. * @returns a scene
  103527. */
  103528. getScene(): Scene;
  103529. /**
  103530. * Gets the engine of the node
  103531. * @returns a Engine
  103532. */
  103533. getEngine(): Engine;
  103534. private _behaviors;
  103535. /**
  103536. * Attach a behavior to the node
  103537. * @see http://doc.babylonjs.com/features/behaviour
  103538. * @param behavior defines the behavior to attach
  103539. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103540. * @returns the current Node
  103541. */
  103542. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103543. /**
  103544. * Remove an attached behavior
  103545. * @see http://doc.babylonjs.com/features/behaviour
  103546. * @param behavior defines the behavior to attach
  103547. * @returns the current Node
  103548. */
  103549. removeBehavior(behavior: Behavior<Node>): Node;
  103550. /**
  103551. * Gets the list of attached behaviors
  103552. * @see http://doc.babylonjs.com/features/behaviour
  103553. */
  103554. get behaviors(): Behavior<Node>[];
  103555. /**
  103556. * Gets an attached behavior by name
  103557. * @param name defines the name of the behavior to look for
  103558. * @see http://doc.babylonjs.com/features/behaviour
  103559. * @returns null if behavior was not found else the requested behavior
  103560. */
  103561. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103562. /**
  103563. * Returns the latest update of the World matrix
  103564. * @returns a Matrix
  103565. */
  103566. getWorldMatrix(): Matrix;
  103567. /** @hidden */
  103568. _getWorldMatrixDeterminant(): number;
  103569. /**
  103570. * Returns directly the latest state of the mesh World matrix.
  103571. * A Matrix is returned.
  103572. */
  103573. get worldMatrixFromCache(): Matrix;
  103574. /** @hidden */
  103575. _initCache(): void;
  103576. /** @hidden */
  103577. updateCache(force?: boolean): void;
  103578. /** @hidden */
  103579. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103580. /** @hidden */
  103581. _updateCache(ignoreParentClass?: boolean): void;
  103582. /** @hidden */
  103583. _isSynchronized(): boolean;
  103584. /** @hidden */
  103585. _markSyncedWithParent(): void;
  103586. /** @hidden */
  103587. isSynchronizedWithParent(): boolean;
  103588. /** @hidden */
  103589. isSynchronized(): boolean;
  103590. /**
  103591. * Is this node ready to be used/rendered
  103592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103593. * @return true if the node is ready
  103594. */
  103595. isReady(completeCheck?: boolean): boolean;
  103596. /**
  103597. * Is this node enabled?
  103598. * 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
  103599. * @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
  103600. * @return whether this node (and its parent) is enabled
  103601. */
  103602. isEnabled(checkAncestors?: boolean): boolean;
  103603. /** @hidden */
  103604. protected _syncParentEnabledState(): void;
  103605. /**
  103606. * Set the enabled state of this node
  103607. * @param value defines the new enabled state
  103608. */
  103609. setEnabled(value: boolean): void;
  103610. /**
  103611. * Is this node a descendant of the given node?
  103612. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103613. * @param ancestor defines the parent node to inspect
  103614. * @returns a boolean indicating if this node is a descendant of the given node
  103615. */
  103616. isDescendantOf(ancestor: Node): boolean;
  103617. /** @hidden */
  103618. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103619. /**
  103620. * Will return all nodes that have this node as ascendant
  103621. * @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
  103622. * @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
  103623. * @return all children nodes of all types
  103624. */
  103625. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103626. /**
  103627. * Get all child-meshes of this node
  103628. * @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)
  103629. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  103630. * @returns an array of AbstractMesh
  103631. */
  103632. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103633. /**
  103634. * Get all direct children of this node
  103635. * @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
  103636. * @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)
  103637. * @returns an array of Node
  103638. */
  103639. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103640. /** @hidden */
  103641. _setReady(state: boolean): void;
  103642. /**
  103643. * Get an animation by name
  103644. * @param name defines the name of the animation to look for
  103645. * @returns null if not found else the requested animation
  103646. */
  103647. getAnimationByName(name: string): Nullable<Animation>;
  103648. /**
  103649. * Creates an animation range for this node
  103650. * @param name defines the name of the range
  103651. * @param from defines the starting key
  103652. * @param to defines the end key
  103653. */
  103654. createAnimationRange(name: string, from: number, to: number): void;
  103655. /**
  103656. * Delete a specific animation range
  103657. * @param name defines the name of the range to delete
  103658. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103659. */
  103660. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103661. /**
  103662. * Get an animation range by name
  103663. * @param name defines the name of the animation range to look for
  103664. * @returns null if not found else the requested animation range
  103665. */
  103666. getAnimationRange(name: string): Nullable<AnimationRange>;
  103667. /**
  103668. * Gets the list of all animation ranges defined on this node
  103669. * @returns an array
  103670. */
  103671. getAnimationRanges(): Nullable<AnimationRange>[];
  103672. /**
  103673. * Will start the animation sequence
  103674. * @param name defines the range frames for animation sequence
  103675. * @param loop defines if the animation should loop (false by default)
  103676. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103677. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103678. * @returns the object created for this animation. If range does not exist, it will return null
  103679. */
  103680. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103681. /**
  103682. * Serialize animation ranges into a JSON compatible object
  103683. * @returns serialization object
  103684. */
  103685. serializeAnimationRanges(): any;
  103686. /**
  103687. * Computes the world matrix of the node
  103688. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103689. * @returns the world matrix
  103690. */
  103691. computeWorldMatrix(force?: boolean): Matrix;
  103692. /**
  103693. * Releases resources associated with this node.
  103694. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103695. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103696. */
  103697. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103698. /**
  103699. * Parse animation range data from a serialization object and store them into a given node
  103700. * @param node defines where to store the animation ranges
  103701. * @param parsedNode defines the serialization object to read data from
  103702. * @param scene defines the hosting scene
  103703. */
  103704. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103705. /**
  103706. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103707. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103708. * @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
  103709. * @returns the new bounding vectors
  103710. */
  103711. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103712. min: Vector3;
  103713. max: Vector3;
  103714. };
  103715. }
  103716. }
  103717. declare module BABYLON {
  103718. /**
  103719. * @hidden
  103720. */
  103721. export class _IAnimationState {
  103722. key: number;
  103723. repeatCount: number;
  103724. workValue?: any;
  103725. loopMode?: number;
  103726. offsetValue?: any;
  103727. highLimitValue?: any;
  103728. }
  103729. /**
  103730. * Class used to store any kind of animation
  103731. */
  103732. export class Animation {
  103733. /**Name of the animation */
  103734. name: string;
  103735. /**Property to animate */
  103736. targetProperty: string;
  103737. /**The frames per second of the animation */
  103738. framePerSecond: number;
  103739. /**The data type of the animation */
  103740. dataType: number;
  103741. /**The loop mode of the animation */
  103742. loopMode?: number | undefined;
  103743. /**Specifies if blending should be enabled */
  103744. enableBlending?: boolean | undefined;
  103745. /**
  103746. * Use matrix interpolation instead of using direct key value when animating matrices
  103747. */
  103748. static AllowMatricesInterpolation: boolean;
  103749. /**
  103750. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103751. */
  103752. static AllowMatrixDecomposeForInterpolation: boolean;
  103753. /**
  103754. * Stores the key frames of the animation
  103755. */
  103756. private _keys;
  103757. /**
  103758. * Stores the easing function of the animation
  103759. */
  103760. private _easingFunction;
  103761. /**
  103762. * @hidden Internal use only
  103763. */
  103764. _runtimeAnimations: RuntimeAnimation[];
  103765. /**
  103766. * The set of event that will be linked to this animation
  103767. */
  103768. private _events;
  103769. /**
  103770. * Stores an array of target property paths
  103771. */
  103772. targetPropertyPath: string[];
  103773. /**
  103774. * Stores the blending speed of the animation
  103775. */
  103776. blendingSpeed: number;
  103777. /**
  103778. * Stores the animation ranges for the animation
  103779. */
  103780. private _ranges;
  103781. /**
  103782. * @hidden Internal use
  103783. */
  103784. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103785. /**
  103786. * Sets up an animation
  103787. * @param property The property to animate
  103788. * @param animationType The animation type to apply
  103789. * @param framePerSecond The frames per second of the animation
  103790. * @param easingFunction The easing function used in the animation
  103791. * @returns The created animation
  103792. */
  103793. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103794. /**
  103795. * Create and start an animation on a node
  103796. * @param name defines the name of the global animation that will be run on all nodes
  103797. * @param node defines the root node where the animation will take place
  103798. * @param targetProperty defines property to animate
  103799. * @param framePerSecond defines the number of frame per second yo use
  103800. * @param totalFrame defines the number of frames in total
  103801. * @param from defines the initial value
  103802. * @param to defines the final value
  103803. * @param loopMode defines which loop mode you want to use (off by default)
  103804. * @param easingFunction defines the easing function to use (linear by default)
  103805. * @param onAnimationEnd defines the callback to call when animation end
  103806. * @returns the animatable created for this animation
  103807. */
  103808. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103809. /**
  103810. * Create and start an animation on a node and its descendants
  103811. * @param name defines the name of the global animation that will be run on all nodes
  103812. * @param node defines the root node where the animation will take place
  103813. * @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
  103814. * @param targetProperty defines property to animate
  103815. * @param framePerSecond defines the number of frame per second to use
  103816. * @param totalFrame defines the number of frames in total
  103817. * @param from defines the initial value
  103818. * @param to defines the final value
  103819. * @param loopMode defines which loop mode you want to use (off by default)
  103820. * @param easingFunction defines the easing function to use (linear by default)
  103821. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103822. * @returns the list of animatables created for all nodes
  103823. * @example https://www.babylonjs-playground.com/#MH0VLI
  103824. */
  103825. 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[]>;
  103826. /**
  103827. * Creates a new animation, merges it with the existing animations and starts it
  103828. * @param name Name of the animation
  103829. * @param node Node which contains the scene that begins the animations
  103830. * @param targetProperty Specifies which property to animate
  103831. * @param framePerSecond The frames per second of the animation
  103832. * @param totalFrame The total number of frames
  103833. * @param from The frame at the beginning of the animation
  103834. * @param to The frame at the end of the animation
  103835. * @param loopMode Specifies the loop mode of the animation
  103836. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103837. * @param onAnimationEnd Callback to run once the animation is complete
  103838. * @returns Nullable animation
  103839. */
  103840. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103841. /**
  103842. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103843. * @param sourceAnimation defines the Animation containing keyframes to convert
  103844. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103845. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103846. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103847. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103848. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103849. */
  103850. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103851. /**
  103852. * Transition property of an host to the target Value
  103853. * @param property The property to transition
  103854. * @param targetValue The target Value of the property
  103855. * @param host The object where the property to animate belongs
  103856. * @param scene Scene used to run the animation
  103857. * @param frameRate Framerate (in frame/s) to use
  103858. * @param transition The transition type we want to use
  103859. * @param duration The duration of the animation, in milliseconds
  103860. * @param onAnimationEnd Callback trigger at the end of the animation
  103861. * @returns Nullable animation
  103862. */
  103863. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103864. /**
  103865. * Return the array of runtime animations currently using this animation
  103866. */
  103867. get runtimeAnimations(): RuntimeAnimation[];
  103868. /**
  103869. * Specifies if any of the runtime animations are currently running
  103870. */
  103871. get hasRunningRuntimeAnimations(): boolean;
  103872. /**
  103873. * Initializes the animation
  103874. * @param name Name of the animation
  103875. * @param targetProperty Property to animate
  103876. * @param framePerSecond The frames per second of the animation
  103877. * @param dataType The data type of the animation
  103878. * @param loopMode The loop mode of the animation
  103879. * @param enableBlending Specifies if blending should be enabled
  103880. */
  103881. constructor(
  103882. /**Name of the animation */
  103883. name: string,
  103884. /**Property to animate */
  103885. targetProperty: string,
  103886. /**The frames per second of the animation */
  103887. framePerSecond: number,
  103888. /**The data type of the animation */
  103889. dataType: number,
  103890. /**The loop mode of the animation */
  103891. loopMode?: number | undefined,
  103892. /**Specifies if blending should be enabled */
  103893. enableBlending?: boolean | undefined);
  103894. /**
  103895. * Converts the animation to a string
  103896. * @param fullDetails support for multiple levels of logging within scene loading
  103897. * @returns String form of the animation
  103898. */
  103899. toString(fullDetails?: boolean): string;
  103900. /**
  103901. * Add an event to this animation
  103902. * @param event Event to add
  103903. */
  103904. addEvent(event: AnimationEvent): void;
  103905. /**
  103906. * Remove all events found at the given frame
  103907. * @param frame The frame to remove events from
  103908. */
  103909. removeEvents(frame: number): void;
  103910. /**
  103911. * Retrieves all the events from the animation
  103912. * @returns Events from the animation
  103913. */
  103914. getEvents(): AnimationEvent[];
  103915. /**
  103916. * Creates an animation range
  103917. * @param name Name of the animation range
  103918. * @param from Starting frame of the animation range
  103919. * @param to Ending frame of the animation
  103920. */
  103921. createRange(name: string, from: number, to: number): void;
  103922. /**
  103923. * Deletes an animation range by name
  103924. * @param name Name of the animation range to delete
  103925. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103926. */
  103927. deleteRange(name: string, deleteFrames?: boolean): void;
  103928. /**
  103929. * Gets the animation range by name, or null if not defined
  103930. * @param name Name of the animation range
  103931. * @returns Nullable animation range
  103932. */
  103933. getRange(name: string): Nullable<AnimationRange>;
  103934. /**
  103935. * Gets the key frames from the animation
  103936. * @returns The key frames of the animation
  103937. */
  103938. getKeys(): Array<IAnimationKey>;
  103939. /**
  103940. * Gets the highest frame rate of the animation
  103941. * @returns Highest frame rate of the animation
  103942. */
  103943. getHighestFrame(): number;
  103944. /**
  103945. * Gets the easing function of the animation
  103946. * @returns Easing function of the animation
  103947. */
  103948. getEasingFunction(): IEasingFunction;
  103949. /**
  103950. * Sets the easing function of the animation
  103951. * @param easingFunction A custom mathematical formula for animation
  103952. */
  103953. setEasingFunction(easingFunction: EasingFunction): void;
  103954. /**
  103955. * Interpolates a scalar linearly
  103956. * @param startValue Start value of the animation curve
  103957. * @param endValue End value of the animation curve
  103958. * @param gradient Scalar amount to interpolate
  103959. * @returns Interpolated scalar value
  103960. */
  103961. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103962. /**
  103963. * Interpolates a scalar cubically
  103964. * @param startValue Start value of the animation curve
  103965. * @param outTangent End tangent of the animation
  103966. * @param endValue End value of the animation curve
  103967. * @param inTangent Start tangent of the animation curve
  103968. * @param gradient Scalar amount to interpolate
  103969. * @returns Interpolated scalar value
  103970. */
  103971. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103972. /**
  103973. * Interpolates a quaternion using a spherical linear interpolation
  103974. * @param startValue Start value of the animation curve
  103975. * @param endValue End value of the animation curve
  103976. * @param gradient Scalar amount to interpolate
  103977. * @returns Interpolated quaternion value
  103978. */
  103979. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103980. /**
  103981. * Interpolates a quaternion cubically
  103982. * @param startValue Start value of the animation curve
  103983. * @param outTangent End tangent of the animation curve
  103984. * @param endValue End value of the animation curve
  103985. * @param inTangent Start tangent of the animation curve
  103986. * @param gradient Scalar amount to interpolate
  103987. * @returns Interpolated quaternion value
  103988. */
  103989. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103990. /**
  103991. * Interpolates a Vector3 linearl
  103992. * @param startValue Start value of the animation curve
  103993. * @param endValue End value of the animation curve
  103994. * @param gradient Scalar amount to interpolate
  103995. * @returns Interpolated scalar value
  103996. */
  103997. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103998. /**
  103999. * Interpolates a Vector3 cubically
  104000. * @param startValue Start value of the animation curve
  104001. * @param outTangent End tangent of the animation
  104002. * @param endValue End value of the animation curve
  104003. * @param inTangent Start tangent of the animation curve
  104004. * @param gradient Scalar amount to interpolate
  104005. * @returns InterpolatedVector3 value
  104006. */
  104007. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  104008. /**
  104009. * Interpolates a Vector2 linearly
  104010. * @param startValue Start value of the animation curve
  104011. * @param endValue End value of the animation curve
  104012. * @param gradient Scalar amount to interpolate
  104013. * @returns Interpolated Vector2 value
  104014. */
  104015. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  104016. /**
  104017. * Interpolates a Vector2 cubically
  104018. * @param startValue Start value of the animation curve
  104019. * @param outTangent End tangent of the animation
  104020. * @param endValue End value of the animation curve
  104021. * @param inTangent Start tangent of the animation curve
  104022. * @param gradient Scalar amount to interpolate
  104023. * @returns Interpolated Vector2 value
  104024. */
  104025. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  104026. /**
  104027. * Interpolates a size linearly
  104028. * @param startValue Start value of the animation curve
  104029. * @param endValue End value of the animation curve
  104030. * @param gradient Scalar amount to interpolate
  104031. * @returns Interpolated Size value
  104032. */
  104033. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104034. /**
  104035. * Interpolates a Color3 linearly
  104036. * @param startValue Start value of the animation curve
  104037. * @param endValue End value of the animation curve
  104038. * @param gradient Scalar amount to interpolate
  104039. * @returns Interpolated Color3 value
  104040. */
  104041. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104042. /**
  104043. * Interpolates a Color4 linearly
  104044. * @param startValue Start value of the animation curve
  104045. * @param endValue End value of the animation curve
  104046. * @param gradient Scalar amount to interpolate
  104047. * @returns Interpolated Color3 value
  104048. */
  104049. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104050. /**
  104051. * @hidden Internal use only
  104052. */
  104053. _getKeyValue(value: any): any;
  104054. /**
  104055. * @hidden Internal use only
  104056. */
  104057. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104058. /**
  104059. * Defines the function to use to interpolate matrices
  104060. * @param startValue defines the start matrix
  104061. * @param endValue defines the end matrix
  104062. * @param gradient defines the gradient between both matrices
  104063. * @param result defines an optional target matrix where to store the interpolation
  104064. * @returns the interpolated matrix
  104065. */
  104066. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104067. /**
  104068. * Makes a copy of the animation
  104069. * @returns Cloned animation
  104070. */
  104071. clone(): Animation;
  104072. /**
  104073. * Sets the key frames of the animation
  104074. * @param values The animation key frames to set
  104075. */
  104076. setKeys(values: Array<IAnimationKey>): void;
  104077. /**
  104078. * Serializes the animation to an object
  104079. * @returns Serialized object
  104080. */
  104081. serialize(): any;
  104082. /**
  104083. * Float animation type
  104084. */
  104085. static readonly ANIMATIONTYPE_FLOAT: number;
  104086. /**
  104087. * Vector3 animation type
  104088. */
  104089. static readonly ANIMATIONTYPE_VECTOR3: number;
  104090. /**
  104091. * Quaternion animation type
  104092. */
  104093. static readonly ANIMATIONTYPE_QUATERNION: number;
  104094. /**
  104095. * Matrix animation type
  104096. */
  104097. static readonly ANIMATIONTYPE_MATRIX: number;
  104098. /**
  104099. * Color3 animation type
  104100. */
  104101. static readonly ANIMATIONTYPE_COLOR3: number;
  104102. /**
  104103. * Color3 animation type
  104104. */
  104105. static readonly ANIMATIONTYPE_COLOR4: number;
  104106. /**
  104107. * Vector2 animation type
  104108. */
  104109. static readonly ANIMATIONTYPE_VECTOR2: number;
  104110. /**
  104111. * Size animation type
  104112. */
  104113. static readonly ANIMATIONTYPE_SIZE: number;
  104114. /**
  104115. * Relative Loop Mode
  104116. */
  104117. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104118. /**
  104119. * Cycle Loop Mode
  104120. */
  104121. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104122. /**
  104123. * Constant Loop Mode
  104124. */
  104125. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104126. /** @hidden */
  104127. static _UniversalLerp(left: any, right: any, amount: number): any;
  104128. /**
  104129. * Parses an animation object and creates an animation
  104130. * @param parsedAnimation Parsed animation object
  104131. * @returns Animation object
  104132. */
  104133. static Parse(parsedAnimation: any): Animation;
  104134. /**
  104135. * Appends the serialized animations from the source animations
  104136. * @param source Source containing the animations
  104137. * @param destination Target to store the animations
  104138. */
  104139. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104140. }
  104141. }
  104142. declare module BABYLON {
  104143. /**
  104144. * Interface containing an array of animations
  104145. */
  104146. export interface IAnimatable {
  104147. /**
  104148. * Array of animations
  104149. */
  104150. animations: Nullable<Array<Animation>>;
  104151. }
  104152. }
  104153. declare module BABYLON {
  104154. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104155. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104156. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104157. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104158. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104159. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104160. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104161. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104162. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104163. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104164. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104165. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104166. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104167. /**
  104168. * Decorator used to define property that can be serialized as reference to a camera
  104169. * @param sourceName defines the name of the property to decorate
  104170. */
  104171. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104172. /**
  104173. * Class used to help serialization objects
  104174. */
  104175. export class SerializationHelper {
  104176. /** @hidden */
  104177. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104178. /** @hidden */
  104179. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104180. /** @hidden */
  104181. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104182. /** @hidden */
  104183. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104184. /**
  104185. * Appends the serialized animations from the source animations
  104186. * @param source Source containing the animations
  104187. * @param destination Target to store the animations
  104188. */
  104189. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104190. /**
  104191. * Static function used to serialized a specific entity
  104192. * @param entity defines the entity to serialize
  104193. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104194. * @returns a JSON compatible object representing the serialization of the entity
  104195. */
  104196. static Serialize<T>(entity: T, serializationObject?: any): any;
  104197. /**
  104198. * Creates a new entity from a serialization data object
  104199. * @param creationFunction defines a function used to instanciated the new entity
  104200. * @param source defines the source serialization data
  104201. * @param scene defines the hosting scene
  104202. * @param rootUrl defines the root url for resources
  104203. * @returns a new entity
  104204. */
  104205. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104206. /**
  104207. * Clones an object
  104208. * @param creationFunction defines the function used to instanciate the new object
  104209. * @param source defines the source object
  104210. * @returns the cloned object
  104211. */
  104212. static Clone<T>(creationFunction: () => T, source: T): T;
  104213. /**
  104214. * Instanciates a new object based on a source one (some data will be shared between both object)
  104215. * @param creationFunction defines the function used to instanciate the new object
  104216. * @param source defines the source object
  104217. * @returns the new object
  104218. */
  104219. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104220. }
  104221. }
  104222. declare module BABYLON {
  104223. /**
  104224. * Class used to manipulate GUIDs
  104225. */
  104226. export class GUID {
  104227. /**
  104228. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104229. * Be aware Math.random() could cause collisions, but:
  104230. * "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"
  104231. * @returns a pseudo random id
  104232. */
  104233. static RandomId(): string;
  104234. }
  104235. }
  104236. declare module BABYLON {
  104237. /**
  104238. * Base class of all the textures in babylon.
  104239. * It groups all the common properties the materials, post process, lights... might need
  104240. * in order to make a correct use of the texture.
  104241. */
  104242. export class BaseTexture implements IAnimatable {
  104243. /**
  104244. * Default anisotropic filtering level for the application.
  104245. * It is set to 4 as a good tradeoff between perf and quality.
  104246. */
  104247. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104248. /**
  104249. * Gets or sets the unique id of the texture
  104250. */
  104251. uniqueId: number;
  104252. /**
  104253. * Define the name of the texture.
  104254. */
  104255. name: string;
  104256. /**
  104257. * Gets or sets an object used to store user defined information.
  104258. */
  104259. metadata: any;
  104260. /**
  104261. * For internal use only. Please do not use.
  104262. */
  104263. reservedDataStore: any;
  104264. private _hasAlpha;
  104265. /**
  104266. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104267. */
  104268. set hasAlpha(value: boolean);
  104269. get hasAlpha(): boolean;
  104270. /**
  104271. * Defines if the alpha value should be determined via the rgb values.
  104272. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104273. */
  104274. getAlphaFromRGB: boolean;
  104275. /**
  104276. * Intensity or strength of the texture.
  104277. * It is commonly used by materials to fine tune the intensity of the texture
  104278. */
  104279. level: number;
  104280. /**
  104281. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104282. * This is part of the texture as textures usually maps to one uv set.
  104283. */
  104284. coordinatesIndex: number;
  104285. private _coordinatesMode;
  104286. /**
  104287. * How a texture is mapped.
  104288. *
  104289. * | Value | Type | Description |
  104290. * | ----- | ----------------------------------- | ----------- |
  104291. * | 0 | EXPLICIT_MODE | |
  104292. * | 1 | SPHERICAL_MODE | |
  104293. * | 2 | PLANAR_MODE | |
  104294. * | 3 | CUBIC_MODE | |
  104295. * | 4 | PROJECTION_MODE | |
  104296. * | 5 | SKYBOX_MODE | |
  104297. * | 6 | INVCUBIC_MODE | |
  104298. * | 7 | EQUIRECTANGULAR_MODE | |
  104299. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104300. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104301. */
  104302. set coordinatesMode(value: number);
  104303. get coordinatesMode(): number;
  104304. /**
  104305. * | Value | Type | Description |
  104306. * | ----- | ------------------ | ----------- |
  104307. * | 0 | CLAMP_ADDRESSMODE | |
  104308. * | 1 | WRAP_ADDRESSMODE | |
  104309. * | 2 | MIRROR_ADDRESSMODE | |
  104310. */
  104311. wrapU: number;
  104312. /**
  104313. * | Value | Type | Description |
  104314. * | ----- | ------------------ | ----------- |
  104315. * | 0 | CLAMP_ADDRESSMODE | |
  104316. * | 1 | WRAP_ADDRESSMODE | |
  104317. * | 2 | MIRROR_ADDRESSMODE | |
  104318. */
  104319. wrapV: number;
  104320. /**
  104321. * | Value | Type | Description |
  104322. * | ----- | ------------------ | ----------- |
  104323. * | 0 | CLAMP_ADDRESSMODE | |
  104324. * | 1 | WRAP_ADDRESSMODE | |
  104325. * | 2 | MIRROR_ADDRESSMODE | |
  104326. */
  104327. wrapR: number;
  104328. /**
  104329. * With compliant hardware and browser (supporting anisotropic filtering)
  104330. * this defines the level of anisotropic filtering in the texture.
  104331. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104332. */
  104333. anisotropicFilteringLevel: number;
  104334. /**
  104335. * Define if the texture is a cube texture or if false a 2d texture.
  104336. */
  104337. get isCube(): boolean;
  104338. set isCube(value: boolean);
  104339. /**
  104340. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104341. */
  104342. get is3D(): boolean;
  104343. set is3D(value: boolean);
  104344. /**
  104345. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104346. */
  104347. get is2DArray(): boolean;
  104348. set is2DArray(value: boolean);
  104349. /**
  104350. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104351. * HDR texture are usually stored in linear space.
  104352. * This only impacts the PBR and Background materials
  104353. */
  104354. gammaSpace: boolean;
  104355. /**
  104356. * Gets or sets whether or not the texture contains RGBD data.
  104357. */
  104358. get isRGBD(): boolean;
  104359. set isRGBD(value: boolean);
  104360. /**
  104361. * Is Z inverted in the texture (useful in a cube texture).
  104362. */
  104363. invertZ: boolean;
  104364. /**
  104365. * Are mip maps generated for this texture or not.
  104366. */
  104367. get noMipmap(): boolean;
  104368. /**
  104369. * @hidden
  104370. */
  104371. lodLevelInAlpha: boolean;
  104372. /**
  104373. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104374. */
  104375. get lodGenerationOffset(): number;
  104376. set lodGenerationOffset(value: number);
  104377. /**
  104378. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104379. */
  104380. get lodGenerationScale(): number;
  104381. set lodGenerationScale(value: number);
  104382. /**
  104383. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104384. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104385. * average roughness values.
  104386. */
  104387. get linearSpecularLOD(): boolean;
  104388. set linearSpecularLOD(value: boolean);
  104389. /**
  104390. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104391. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104392. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104393. */
  104394. get irradianceTexture(): Nullable<BaseTexture>;
  104395. set irradianceTexture(value: Nullable<BaseTexture>);
  104396. /**
  104397. * Define if the texture is a render target.
  104398. */
  104399. isRenderTarget: boolean;
  104400. /**
  104401. * Define the unique id of the texture in the scene.
  104402. */
  104403. get uid(): string;
  104404. /**
  104405. * Return a string representation of the texture.
  104406. * @returns the texture as a string
  104407. */
  104408. toString(): string;
  104409. /**
  104410. * Get the class name of the texture.
  104411. * @returns "BaseTexture"
  104412. */
  104413. getClassName(): string;
  104414. /**
  104415. * Define the list of animation attached to the texture.
  104416. */
  104417. animations: Animation[];
  104418. /**
  104419. * An event triggered when the texture is disposed.
  104420. */
  104421. onDisposeObservable: Observable<BaseTexture>;
  104422. private _onDisposeObserver;
  104423. /**
  104424. * Callback triggered when the texture has been disposed.
  104425. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104426. */
  104427. set onDispose(callback: () => void);
  104428. /**
  104429. * Define the current state of the loading sequence when in delayed load mode.
  104430. */
  104431. delayLoadState: number;
  104432. private _scene;
  104433. /** @hidden */
  104434. _texture: Nullable<InternalTexture>;
  104435. private _uid;
  104436. /**
  104437. * Define if the texture is preventinga material to render or not.
  104438. * If not and the texture is not ready, the engine will use a default black texture instead.
  104439. */
  104440. get isBlocking(): boolean;
  104441. /**
  104442. * Instantiates a new BaseTexture.
  104443. * Base class of all the textures in babylon.
  104444. * It groups all the common properties the materials, post process, lights... might need
  104445. * in order to make a correct use of the texture.
  104446. * @param scene Define the scene the texture blongs to
  104447. */
  104448. constructor(scene: Nullable<Scene>);
  104449. /**
  104450. * Get the scene the texture belongs to.
  104451. * @returns the scene or null if undefined
  104452. */
  104453. getScene(): Nullable<Scene>;
  104454. /**
  104455. * Get the texture transform matrix used to offset tile the texture for istance.
  104456. * @returns the transformation matrix
  104457. */
  104458. getTextureMatrix(): Matrix;
  104459. /**
  104460. * Get the texture reflection matrix used to rotate/transform the reflection.
  104461. * @returns the reflection matrix
  104462. */
  104463. getReflectionTextureMatrix(): Matrix;
  104464. /**
  104465. * Get the underlying lower level texture from Babylon.
  104466. * @returns the insternal texture
  104467. */
  104468. getInternalTexture(): Nullable<InternalTexture>;
  104469. /**
  104470. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104471. * @returns true if ready or not blocking
  104472. */
  104473. isReadyOrNotBlocking(): boolean;
  104474. /**
  104475. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104476. * @returns true if fully ready
  104477. */
  104478. isReady(): boolean;
  104479. private _cachedSize;
  104480. /**
  104481. * Get the size of the texture.
  104482. * @returns the texture size.
  104483. */
  104484. getSize(): ISize;
  104485. /**
  104486. * Get the base size of the texture.
  104487. * It can be different from the size if the texture has been resized for POT for instance
  104488. * @returns the base size
  104489. */
  104490. getBaseSize(): ISize;
  104491. /**
  104492. * Update the sampling mode of the texture.
  104493. * Default is Trilinear mode.
  104494. *
  104495. * | Value | Type | Description |
  104496. * | ----- | ------------------ | ----------- |
  104497. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104498. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104499. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104500. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104501. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104502. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104503. * | 7 | NEAREST_LINEAR | |
  104504. * | 8 | NEAREST_NEAREST | |
  104505. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104506. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104507. * | 11 | LINEAR_LINEAR | |
  104508. * | 12 | LINEAR_NEAREST | |
  104509. *
  104510. * > _mag_: magnification filter (close to the viewer)
  104511. * > _min_: minification filter (far from the viewer)
  104512. * > _mip_: filter used between mip map levels
  104513. *@param samplingMode Define the new sampling mode of the texture
  104514. */
  104515. updateSamplingMode(samplingMode: number): void;
  104516. /**
  104517. * Scales the texture if is `canRescale()`
  104518. * @param ratio the resize factor we want to use to rescale
  104519. */
  104520. scale(ratio: number): void;
  104521. /**
  104522. * Get if the texture can rescale.
  104523. */
  104524. get canRescale(): boolean;
  104525. /** @hidden */
  104526. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104527. /** @hidden */
  104528. _rebuild(): void;
  104529. /**
  104530. * Triggers the load sequence in delayed load mode.
  104531. */
  104532. delayLoad(): void;
  104533. /**
  104534. * Clones the texture.
  104535. * @returns the cloned texture
  104536. */
  104537. clone(): Nullable<BaseTexture>;
  104538. /**
  104539. * Get the texture underlying type (INT, FLOAT...)
  104540. */
  104541. get textureType(): number;
  104542. /**
  104543. * Get the texture underlying format (RGB, RGBA...)
  104544. */
  104545. get textureFormat(): number;
  104546. /**
  104547. * Indicates that textures need to be re-calculated for all materials
  104548. */
  104549. protected _markAllSubMeshesAsTexturesDirty(): void;
  104550. /**
  104551. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104552. * This will returns an RGBA array buffer containing either in values (0-255) or
  104553. * float values (0-1) depending of the underlying buffer type.
  104554. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104555. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104556. * @param buffer defines a user defined buffer to fill with data (can be null)
  104557. * @returns The Array buffer containing the pixels data.
  104558. */
  104559. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104560. /**
  104561. * Release and destroy the underlying lower level texture aka internalTexture.
  104562. */
  104563. releaseInternalTexture(): void;
  104564. /** @hidden */
  104565. get _lodTextureHigh(): Nullable<BaseTexture>;
  104566. /** @hidden */
  104567. get _lodTextureMid(): Nullable<BaseTexture>;
  104568. /** @hidden */
  104569. get _lodTextureLow(): Nullable<BaseTexture>;
  104570. /**
  104571. * Dispose the texture and release its associated resources.
  104572. */
  104573. dispose(): void;
  104574. /**
  104575. * Serialize the texture into a JSON representation that can be parsed later on.
  104576. * @returns the JSON representation of the texture
  104577. */
  104578. serialize(): any;
  104579. /**
  104580. * Helper function to be called back once a list of texture contains only ready textures.
  104581. * @param textures Define the list of textures to wait for
  104582. * @param callback Define the callback triggered once the entire list will be ready
  104583. */
  104584. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104585. }
  104586. }
  104587. declare module BABYLON {
  104588. /**
  104589. * Options to be used when creating an effect.
  104590. */
  104591. export interface IEffectCreationOptions {
  104592. /**
  104593. * Atrributes that will be used in the shader.
  104594. */
  104595. attributes: string[];
  104596. /**
  104597. * Uniform varible names that will be set in the shader.
  104598. */
  104599. uniformsNames: string[];
  104600. /**
  104601. * Uniform buffer variable names that will be set in the shader.
  104602. */
  104603. uniformBuffersNames: string[];
  104604. /**
  104605. * Sampler texture variable names that will be set in the shader.
  104606. */
  104607. samplers: string[];
  104608. /**
  104609. * Define statements that will be set in the shader.
  104610. */
  104611. defines: any;
  104612. /**
  104613. * Possible fallbacks for this effect to improve performance when needed.
  104614. */
  104615. fallbacks: Nullable<IEffectFallbacks>;
  104616. /**
  104617. * Callback that will be called when the shader is compiled.
  104618. */
  104619. onCompiled: Nullable<(effect: Effect) => void>;
  104620. /**
  104621. * Callback that will be called if an error occurs during shader compilation.
  104622. */
  104623. onError: Nullable<(effect: Effect, errors: string) => void>;
  104624. /**
  104625. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104626. */
  104627. indexParameters?: any;
  104628. /**
  104629. * Max number of lights that can be used in the shader.
  104630. */
  104631. maxSimultaneousLights?: number;
  104632. /**
  104633. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104634. */
  104635. transformFeedbackVaryings?: Nullable<string[]>;
  104636. }
  104637. /**
  104638. * Effect containing vertex and fragment shader that can be executed on an object.
  104639. */
  104640. export class Effect implements IDisposable {
  104641. /**
  104642. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104643. */
  104644. static ShadersRepository: string;
  104645. /**
  104646. * Enable logging of the shader code when a compilation error occurs
  104647. */
  104648. static LogShaderCodeOnCompilationError: boolean;
  104649. /**
  104650. * Name of the effect.
  104651. */
  104652. name: any;
  104653. /**
  104654. * String container all the define statements that should be set on the shader.
  104655. */
  104656. defines: string;
  104657. /**
  104658. * Callback that will be called when the shader is compiled.
  104659. */
  104660. onCompiled: Nullable<(effect: Effect) => void>;
  104661. /**
  104662. * Callback that will be called if an error occurs during shader compilation.
  104663. */
  104664. onError: Nullable<(effect: Effect, errors: string) => void>;
  104665. /**
  104666. * Callback that will be called when effect is bound.
  104667. */
  104668. onBind: Nullable<(effect: Effect) => void>;
  104669. /**
  104670. * Unique ID of the effect.
  104671. */
  104672. uniqueId: number;
  104673. /**
  104674. * Observable that will be called when the shader is compiled.
  104675. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104676. */
  104677. onCompileObservable: Observable<Effect>;
  104678. /**
  104679. * Observable that will be called if an error occurs during shader compilation.
  104680. */
  104681. onErrorObservable: Observable<Effect>;
  104682. /** @hidden */
  104683. _onBindObservable: Nullable<Observable<Effect>>;
  104684. /**
  104685. * @hidden
  104686. * Specifies if the effect was previously ready
  104687. */
  104688. _wasPreviouslyReady: boolean;
  104689. /**
  104690. * Observable that will be called when effect is bound.
  104691. */
  104692. get onBindObservable(): Observable<Effect>;
  104693. /** @hidden */
  104694. _bonesComputationForcedToCPU: boolean;
  104695. private static _uniqueIdSeed;
  104696. private _engine;
  104697. private _uniformBuffersNames;
  104698. private _uniformsNames;
  104699. private _samplerList;
  104700. private _samplers;
  104701. private _isReady;
  104702. private _compilationError;
  104703. private _allFallbacksProcessed;
  104704. private _attributesNames;
  104705. private _attributes;
  104706. private _attributeLocationByName;
  104707. private _uniforms;
  104708. /**
  104709. * Key for the effect.
  104710. * @hidden
  104711. */
  104712. _key: string;
  104713. private _indexParameters;
  104714. private _fallbacks;
  104715. private _vertexSourceCode;
  104716. private _fragmentSourceCode;
  104717. private _vertexSourceCodeOverride;
  104718. private _fragmentSourceCodeOverride;
  104719. private _transformFeedbackVaryings;
  104720. /**
  104721. * Compiled shader to webGL program.
  104722. * @hidden
  104723. */
  104724. _pipelineContext: Nullable<IPipelineContext>;
  104725. private _valueCache;
  104726. private static _baseCache;
  104727. /**
  104728. * Instantiates an effect.
  104729. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104730. * @param baseName Name of the effect.
  104731. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104732. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104733. * @param samplers List of sampler variables that will be passed to the shader.
  104734. * @param engine Engine to be used to render the effect
  104735. * @param defines Define statements to be added to the shader.
  104736. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104737. * @param onCompiled Callback that will be called when the shader is compiled.
  104738. * @param onError Callback that will be called if an error occurs during shader compilation.
  104739. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104740. */
  104741. 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);
  104742. private _useFinalCode;
  104743. /**
  104744. * Unique key for this effect
  104745. */
  104746. get key(): string;
  104747. /**
  104748. * If the effect has been compiled and prepared.
  104749. * @returns if the effect is compiled and prepared.
  104750. */
  104751. isReady(): boolean;
  104752. private _isReadyInternal;
  104753. /**
  104754. * The engine the effect was initialized with.
  104755. * @returns the engine.
  104756. */
  104757. getEngine(): Engine;
  104758. /**
  104759. * The pipeline context for this effect
  104760. * @returns the associated pipeline context
  104761. */
  104762. getPipelineContext(): Nullable<IPipelineContext>;
  104763. /**
  104764. * The set of names of attribute variables for the shader.
  104765. * @returns An array of attribute names.
  104766. */
  104767. getAttributesNames(): string[];
  104768. /**
  104769. * Returns the attribute at the given index.
  104770. * @param index The index of the attribute.
  104771. * @returns The location of the attribute.
  104772. */
  104773. getAttributeLocation(index: number): number;
  104774. /**
  104775. * Returns the attribute based on the name of the variable.
  104776. * @param name of the attribute to look up.
  104777. * @returns the attribute location.
  104778. */
  104779. getAttributeLocationByName(name: string): number;
  104780. /**
  104781. * The number of attributes.
  104782. * @returns the numnber of attributes.
  104783. */
  104784. getAttributesCount(): number;
  104785. /**
  104786. * Gets the index of a uniform variable.
  104787. * @param uniformName of the uniform to look up.
  104788. * @returns the index.
  104789. */
  104790. getUniformIndex(uniformName: string): number;
  104791. /**
  104792. * Returns the attribute based on the name of the variable.
  104793. * @param uniformName of the uniform to look up.
  104794. * @returns the location of the uniform.
  104795. */
  104796. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104797. /**
  104798. * Returns an array of sampler variable names
  104799. * @returns The array of sampler variable neames.
  104800. */
  104801. getSamplers(): string[];
  104802. /**
  104803. * The error from the last compilation.
  104804. * @returns the error string.
  104805. */
  104806. getCompilationError(): string;
  104807. /**
  104808. * Gets a boolean indicating that all fallbacks were used during compilation
  104809. * @returns true if all fallbacks were used
  104810. */
  104811. allFallbacksProcessed(): boolean;
  104812. /**
  104813. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104814. * @param func The callback to be used.
  104815. */
  104816. executeWhenCompiled(func: (effect: Effect) => void): void;
  104817. private _checkIsReady;
  104818. private _loadShader;
  104819. /**
  104820. * Recompiles the webGL program
  104821. * @param vertexSourceCode The source code for the vertex shader.
  104822. * @param fragmentSourceCode The source code for the fragment shader.
  104823. * @param onCompiled Callback called when completed.
  104824. * @param onError Callback called on error.
  104825. * @hidden
  104826. */
  104827. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104828. /**
  104829. * Prepares the effect
  104830. * @hidden
  104831. */
  104832. _prepareEffect(): void;
  104833. private _getShaderCodeAndErrorLine;
  104834. private _processCompilationErrors;
  104835. /**
  104836. * Checks if the effect is supported. (Must be called after compilation)
  104837. */
  104838. get isSupported(): boolean;
  104839. /**
  104840. * Binds a texture to the engine to be used as output of the shader.
  104841. * @param channel Name of the output variable.
  104842. * @param texture Texture to bind.
  104843. * @hidden
  104844. */
  104845. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104846. /**
  104847. * Sets a texture on the engine to be used in the shader.
  104848. * @param channel Name of the sampler variable.
  104849. * @param texture Texture to set.
  104850. */
  104851. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104852. /**
  104853. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104854. * @param channel Name of the sampler variable.
  104855. * @param texture Texture to set.
  104856. */
  104857. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104858. /**
  104859. * Sets an array of textures on the engine to be used in the shader.
  104860. * @param channel Name of the variable.
  104861. * @param textures Textures to set.
  104862. */
  104863. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104864. /**
  104865. * 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)
  104866. * @param channel Name of the sampler variable.
  104867. * @param postProcess Post process to get the input texture from.
  104868. */
  104869. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104870. /**
  104871. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104872. * 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)
  104873. * @param channel Name of the sampler variable.
  104874. * @param postProcess Post process to get the output texture from.
  104875. */
  104876. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104877. /** @hidden */
  104878. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104879. /** @hidden */
  104880. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104881. /** @hidden */
  104882. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104883. /** @hidden */
  104884. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104885. /**
  104886. * Binds a buffer to a uniform.
  104887. * @param buffer Buffer to bind.
  104888. * @param name Name of the uniform variable to bind to.
  104889. */
  104890. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104891. /**
  104892. * Binds block to a uniform.
  104893. * @param blockName Name of the block to bind.
  104894. * @param index Index to bind.
  104895. */
  104896. bindUniformBlock(blockName: string, index: number): void;
  104897. /**
  104898. * Sets an interger value on a uniform variable.
  104899. * @param uniformName Name of the variable.
  104900. * @param value Value to be set.
  104901. * @returns this effect.
  104902. */
  104903. setInt(uniformName: string, value: number): Effect;
  104904. /**
  104905. * Sets an int array on a uniform variable.
  104906. * @param uniformName Name of the variable.
  104907. * @param array array to be set.
  104908. * @returns this effect.
  104909. */
  104910. setIntArray(uniformName: string, array: Int32Array): Effect;
  104911. /**
  104912. * 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)
  104913. * @param uniformName Name of the variable.
  104914. * @param array array to be set.
  104915. * @returns this effect.
  104916. */
  104917. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104918. /**
  104919. * 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)
  104920. * @param uniformName Name of the variable.
  104921. * @param array array to be set.
  104922. * @returns this effect.
  104923. */
  104924. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104925. /**
  104926. * 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)
  104927. * @param uniformName Name of the variable.
  104928. * @param array array to be set.
  104929. * @returns this effect.
  104930. */
  104931. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104932. /**
  104933. * Sets an float array on a uniform variable.
  104934. * @param uniformName Name of the variable.
  104935. * @param array array to be set.
  104936. * @returns this effect.
  104937. */
  104938. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104939. /**
  104940. * 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)
  104941. * @param uniformName Name of the variable.
  104942. * @param array array to be set.
  104943. * @returns this effect.
  104944. */
  104945. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104946. /**
  104947. * 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)
  104948. * @param uniformName Name of the variable.
  104949. * @param array array to be set.
  104950. * @returns this effect.
  104951. */
  104952. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104953. /**
  104954. * 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)
  104955. * @param uniformName Name of the variable.
  104956. * @param array array to be set.
  104957. * @returns this effect.
  104958. */
  104959. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104960. /**
  104961. * Sets an array on a uniform variable.
  104962. * @param uniformName Name of the variable.
  104963. * @param array array to be set.
  104964. * @returns this effect.
  104965. */
  104966. setArray(uniformName: string, array: number[]): Effect;
  104967. /**
  104968. * 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)
  104969. * @param uniformName Name of the variable.
  104970. * @param array array to be set.
  104971. * @returns this effect.
  104972. */
  104973. setArray2(uniformName: string, array: number[]): Effect;
  104974. /**
  104975. * 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)
  104976. * @param uniformName Name of the variable.
  104977. * @param array array to be set.
  104978. * @returns this effect.
  104979. */
  104980. setArray3(uniformName: string, array: number[]): Effect;
  104981. /**
  104982. * 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)
  104983. * @param uniformName Name of the variable.
  104984. * @param array array to be set.
  104985. * @returns this effect.
  104986. */
  104987. setArray4(uniformName: string, array: number[]): Effect;
  104988. /**
  104989. * Sets matrices on a uniform variable.
  104990. * @param uniformName Name of the variable.
  104991. * @param matrices matrices to be set.
  104992. * @returns this effect.
  104993. */
  104994. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104995. /**
  104996. * Sets matrix on a uniform variable.
  104997. * @param uniformName Name of the variable.
  104998. * @param matrix matrix to be set.
  104999. * @returns this effect.
  105000. */
  105001. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  105002. /**
  105003. * 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)
  105004. * @param uniformName Name of the variable.
  105005. * @param matrix matrix to be set.
  105006. * @returns this effect.
  105007. */
  105008. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  105009. /**
  105010. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  105011. * @param uniformName Name of the variable.
  105012. * @param matrix matrix to be set.
  105013. * @returns this effect.
  105014. */
  105015. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  105016. /**
  105017. * Sets a float on a uniform variable.
  105018. * @param uniformName Name of the variable.
  105019. * @param value value to be set.
  105020. * @returns this effect.
  105021. */
  105022. setFloat(uniformName: string, value: number): Effect;
  105023. /**
  105024. * Sets a boolean on a uniform variable.
  105025. * @param uniformName Name of the variable.
  105026. * @param bool value to be set.
  105027. * @returns this effect.
  105028. */
  105029. setBool(uniformName: string, bool: boolean): Effect;
  105030. /**
  105031. * Sets a Vector2 on a uniform variable.
  105032. * @param uniformName Name of the variable.
  105033. * @param vector2 vector2 to be set.
  105034. * @returns this effect.
  105035. */
  105036. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105037. /**
  105038. * Sets a float2 on a uniform variable.
  105039. * @param uniformName Name of the variable.
  105040. * @param x First float in float2.
  105041. * @param y Second float in float2.
  105042. * @returns this effect.
  105043. */
  105044. setFloat2(uniformName: string, x: number, y: number): Effect;
  105045. /**
  105046. * Sets a Vector3 on a uniform variable.
  105047. * @param uniformName Name of the variable.
  105048. * @param vector3 Value to be set.
  105049. * @returns this effect.
  105050. */
  105051. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105052. /**
  105053. * Sets a float3 on a uniform variable.
  105054. * @param uniformName Name of the variable.
  105055. * @param x First float in float3.
  105056. * @param y Second float in float3.
  105057. * @param z Third float in float3.
  105058. * @returns this effect.
  105059. */
  105060. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105061. /**
  105062. * Sets a Vector4 on a uniform variable.
  105063. * @param uniformName Name of the variable.
  105064. * @param vector4 Value to be set.
  105065. * @returns this effect.
  105066. */
  105067. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105068. /**
  105069. * Sets a float4 on a uniform variable.
  105070. * @param uniformName Name of the variable.
  105071. * @param x First float in float4.
  105072. * @param y Second float in float4.
  105073. * @param z Third float in float4.
  105074. * @param w Fourth float in float4.
  105075. * @returns this effect.
  105076. */
  105077. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105078. /**
  105079. * Sets a Color3 on a uniform variable.
  105080. * @param uniformName Name of the variable.
  105081. * @param color3 Value to be set.
  105082. * @returns this effect.
  105083. */
  105084. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105085. /**
  105086. * Sets a Color4 on a uniform variable.
  105087. * @param uniformName Name of the variable.
  105088. * @param color3 Value to be set.
  105089. * @param alpha Alpha value to be set.
  105090. * @returns this effect.
  105091. */
  105092. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105093. /**
  105094. * Sets a Color4 on a uniform variable
  105095. * @param uniformName defines the name of the variable
  105096. * @param color4 defines the value to be set
  105097. * @returns this effect.
  105098. */
  105099. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105100. /** Release all associated resources */
  105101. dispose(): void;
  105102. /**
  105103. * This function will add a new shader to the shader store
  105104. * @param name the name of the shader
  105105. * @param pixelShader optional pixel shader content
  105106. * @param vertexShader optional vertex shader content
  105107. */
  105108. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105109. /**
  105110. * Store of each shader (The can be looked up using effect.key)
  105111. */
  105112. static ShadersStore: {
  105113. [key: string]: string;
  105114. };
  105115. /**
  105116. * Store of each included file for a shader (The can be looked up using effect.key)
  105117. */
  105118. static IncludesShadersStore: {
  105119. [key: string]: string;
  105120. };
  105121. /**
  105122. * Resets the cache of effects.
  105123. */
  105124. static ResetCache(): void;
  105125. }
  105126. }
  105127. declare module BABYLON {
  105128. /**
  105129. * Interface used to describe the capabilities of the engine relatively to the current browser
  105130. */
  105131. export interface EngineCapabilities {
  105132. /** Maximum textures units per fragment shader */
  105133. maxTexturesImageUnits: number;
  105134. /** Maximum texture units per vertex shader */
  105135. maxVertexTextureImageUnits: number;
  105136. /** Maximum textures units in the entire pipeline */
  105137. maxCombinedTexturesImageUnits: number;
  105138. /** Maximum texture size */
  105139. maxTextureSize: number;
  105140. /** Maximum texture samples */
  105141. maxSamples?: number;
  105142. /** Maximum cube texture size */
  105143. maxCubemapTextureSize: number;
  105144. /** Maximum render texture size */
  105145. maxRenderTextureSize: number;
  105146. /** Maximum number of vertex attributes */
  105147. maxVertexAttribs: number;
  105148. /** Maximum number of varyings */
  105149. maxVaryingVectors: number;
  105150. /** Maximum number of uniforms per vertex shader */
  105151. maxVertexUniformVectors: number;
  105152. /** Maximum number of uniforms per fragment shader */
  105153. maxFragmentUniformVectors: number;
  105154. /** Defines if standard derivates (dx/dy) are supported */
  105155. standardDerivatives: boolean;
  105156. /** Defines if s3tc texture compression is supported */
  105157. s3tc?: WEBGL_compressed_texture_s3tc;
  105158. /** Defines if pvrtc texture compression is supported */
  105159. pvrtc: any;
  105160. /** Defines if etc1 texture compression is supported */
  105161. etc1: any;
  105162. /** Defines if etc2 texture compression is supported */
  105163. etc2: any;
  105164. /** Defines if astc texture compression is supported */
  105165. astc: any;
  105166. /** Defines if float textures are supported */
  105167. textureFloat: boolean;
  105168. /** Defines if vertex array objects are supported */
  105169. vertexArrayObject: boolean;
  105170. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105171. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105172. /** Gets the maximum level of anisotropy supported */
  105173. maxAnisotropy: number;
  105174. /** Defines if instancing is supported */
  105175. instancedArrays: boolean;
  105176. /** Defines if 32 bits indices are supported */
  105177. uintIndices: boolean;
  105178. /** Defines if high precision shaders are supported */
  105179. highPrecisionShaderSupported: boolean;
  105180. /** Defines if depth reading in the fragment shader is supported */
  105181. fragmentDepthSupported: boolean;
  105182. /** Defines if float texture linear filtering is supported*/
  105183. textureFloatLinearFiltering: boolean;
  105184. /** Defines if rendering to float textures is supported */
  105185. textureFloatRender: boolean;
  105186. /** Defines if half float textures are supported*/
  105187. textureHalfFloat: boolean;
  105188. /** Defines if half float texture linear filtering is supported*/
  105189. textureHalfFloatLinearFiltering: boolean;
  105190. /** Defines if rendering to half float textures is supported */
  105191. textureHalfFloatRender: boolean;
  105192. /** Defines if textureLOD shader command is supported */
  105193. textureLOD: boolean;
  105194. /** Defines if draw buffers extension is supported */
  105195. drawBuffersExtension: boolean;
  105196. /** Defines if depth textures are supported */
  105197. depthTextureExtension: boolean;
  105198. /** Defines if float color buffer are supported */
  105199. colorBufferFloat: boolean;
  105200. /** Gets disjoint timer query extension (null if not supported) */
  105201. timerQuery?: EXT_disjoint_timer_query;
  105202. /** Defines if timestamp can be used with timer query */
  105203. canUseTimestampForTimerQuery: boolean;
  105204. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105205. multiview?: any;
  105206. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105207. oculusMultiview?: any;
  105208. /** Function used to let the system compiles shaders in background */
  105209. parallelShaderCompile?: {
  105210. COMPLETION_STATUS_KHR: number;
  105211. };
  105212. /** Max number of texture samples for MSAA */
  105213. maxMSAASamples: number;
  105214. /** Defines if the blend min max extension is supported */
  105215. blendMinMax: boolean;
  105216. }
  105217. }
  105218. declare module BABYLON {
  105219. /**
  105220. * @hidden
  105221. **/
  105222. export class DepthCullingState {
  105223. private _isDepthTestDirty;
  105224. private _isDepthMaskDirty;
  105225. private _isDepthFuncDirty;
  105226. private _isCullFaceDirty;
  105227. private _isCullDirty;
  105228. private _isZOffsetDirty;
  105229. private _isFrontFaceDirty;
  105230. private _depthTest;
  105231. private _depthMask;
  105232. private _depthFunc;
  105233. private _cull;
  105234. private _cullFace;
  105235. private _zOffset;
  105236. private _frontFace;
  105237. /**
  105238. * Initializes the state.
  105239. */
  105240. constructor();
  105241. get isDirty(): boolean;
  105242. get zOffset(): number;
  105243. set zOffset(value: number);
  105244. get cullFace(): Nullable<number>;
  105245. set cullFace(value: Nullable<number>);
  105246. get cull(): Nullable<boolean>;
  105247. set cull(value: Nullable<boolean>);
  105248. get depthFunc(): Nullable<number>;
  105249. set depthFunc(value: Nullable<number>);
  105250. get depthMask(): boolean;
  105251. set depthMask(value: boolean);
  105252. get depthTest(): boolean;
  105253. set depthTest(value: boolean);
  105254. get frontFace(): Nullable<number>;
  105255. set frontFace(value: Nullable<number>);
  105256. reset(): void;
  105257. apply(gl: WebGLRenderingContext): void;
  105258. }
  105259. }
  105260. declare module BABYLON {
  105261. /**
  105262. * @hidden
  105263. **/
  105264. export class StencilState {
  105265. /** 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 */
  105266. static readonly ALWAYS: number;
  105267. /** Passed to stencilOperation to specify that stencil value must be kept */
  105268. static readonly KEEP: number;
  105269. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105270. static readonly REPLACE: number;
  105271. private _isStencilTestDirty;
  105272. private _isStencilMaskDirty;
  105273. private _isStencilFuncDirty;
  105274. private _isStencilOpDirty;
  105275. private _stencilTest;
  105276. private _stencilMask;
  105277. private _stencilFunc;
  105278. private _stencilFuncRef;
  105279. private _stencilFuncMask;
  105280. private _stencilOpStencilFail;
  105281. private _stencilOpDepthFail;
  105282. private _stencilOpStencilDepthPass;
  105283. get isDirty(): boolean;
  105284. get stencilFunc(): number;
  105285. set stencilFunc(value: number);
  105286. get stencilFuncRef(): number;
  105287. set stencilFuncRef(value: number);
  105288. get stencilFuncMask(): number;
  105289. set stencilFuncMask(value: number);
  105290. get stencilOpStencilFail(): number;
  105291. set stencilOpStencilFail(value: number);
  105292. get stencilOpDepthFail(): number;
  105293. set stencilOpDepthFail(value: number);
  105294. get stencilOpStencilDepthPass(): number;
  105295. set stencilOpStencilDepthPass(value: number);
  105296. get stencilMask(): number;
  105297. set stencilMask(value: number);
  105298. get stencilTest(): boolean;
  105299. set stencilTest(value: boolean);
  105300. constructor();
  105301. reset(): void;
  105302. apply(gl: WebGLRenderingContext): void;
  105303. }
  105304. }
  105305. declare module BABYLON {
  105306. /**
  105307. * @hidden
  105308. **/
  105309. export class AlphaState {
  105310. private _isAlphaBlendDirty;
  105311. private _isBlendFunctionParametersDirty;
  105312. private _isBlendEquationParametersDirty;
  105313. private _isBlendConstantsDirty;
  105314. private _alphaBlend;
  105315. private _blendFunctionParameters;
  105316. private _blendEquationParameters;
  105317. private _blendConstants;
  105318. /**
  105319. * Initializes the state.
  105320. */
  105321. constructor();
  105322. get isDirty(): boolean;
  105323. get alphaBlend(): boolean;
  105324. set alphaBlend(value: boolean);
  105325. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105326. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105327. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105328. reset(): void;
  105329. apply(gl: WebGLRenderingContext): void;
  105330. }
  105331. }
  105332. declare module BABYLON {
  105333. /** @hidden */
  105334. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105335. attributeProcessor(attribute: string): string;
  105336. varyingProcessor(varying: string, isFragment: boolean): string;
  105337. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105338. }
  105339. }
  105340. declare module BABYLON {
  105341. /**
  105342. * Interface for attribute information associated with buffer instanciation
  105343. */
  105344. export interface InstancingAttributeInfo {
  105345. /**
  105346. * Name of the GLSL attribute
  105347. * if attribute index is not specified, this is used to retrieve the index from the effect
  105348. */
  105349. attributeName: string;
  105350. /**
  105351. * Index/offset of the attribute in the vertex shader
  105352. * if not specified, this will be computes from the name.
  105353. */
  105354. index?: number;
  105355. /**
  105356. * size of the attribute, 1, 2, 3 or 4
  105357. */
  105358. attributeSize: number;
  105359. /**
  105360. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105361. */
  105362. offset: number;
  105363. /**
  105364. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105365. * default to 1
  105366. */
  105367. divisor?: number;
  105368. /**
  105369. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105370. * default is FLOAT
  105371. */
  105372. attributeType?: number;
  105373. /**
  105374. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105375. */
  105376. normalized?: boolean;
  105377. }
  105378. }
  105379. declare module BABYLON {
  105380. interface ThinEngine {
  105381. /**
  105382. * Update a video texture
  105383. * @param texture defines the texture to update
  105384. * @param video defines the video element to use
  105385. * @param invertY defines if data must be stored with Y axis inverted
  105386. */
  105387. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105388. }
  105389. }
  105390. declare module BABYLON {
  105391. /**
  105392. * Settings for finer control over video usage
  105393. */
  105394. export interface VideoTextureSettings {
  105395. /**
  105396. * Applies `autoplay` to video, if specified
  105397. */
  105398. autoPlay?: boolean;
  105399. /**
  105400. * Applies `loop` to video, if specified
  105401. */
  105402. loop?: boolean;
  105403. /**
  105404. * Automatically updates internal texture from video at every frame in the render loop
  105405. */
  105406. autoUpdateTexture: boolean;
  105407. /**
  105408. * Image src displayed during the video loading or until the user interacts with the video.
  105409. */
  105410. poster?: string;
  105411. }
  105412. /**
  105413. * If you want to display a video in your scene, this is the special texture for that.
  105414. * This special texture works similar to other textures, with the exception of a few parameters.
  105415. * @see https://doc.babylonjs.com/how_to/video_texture
  105416. */
  105417. export class VideoTexture extends Texture {
  105418. /**
  105419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105420. */
  105421. readonly autoUpdateTexture: boolean;
  105422. /**
  105423. * The video instance used by the texture internally
  105424. */
  105425. readonly video: HTMLVideoElement;
  105426. private _onUserActionRequestedObservable;
  105427. /**
  105428. * Event triggerd when a dom action is required by the user to play the video.
  105429. * This happens due to recent changes in browser policies preventing video to auto start.
  105430. */
  105431. get onUserActionRequestedObservable(): Observable<Texture>;
  105432. private _generateMipMaps;
  105433. private _engine;
  105434. private _stillImageCaptured;
  105435. private _displayingPosterTexture;
  105436. private _settings;
  105437. private _createInternalTextureOnEvent;
  105438. private _frameId;
  105439. private _currentSrc;
  105440. /**
  105441. * Creates a video texture.
  105442. * If you want to display a video in your scene, this is the special texture for that.
  105443. * This special texture works similar to other textures, with the exception of a few parameters.
  105444. * @see https://doc.babylonjs.com/how_to/video_texture
  105445. * @param name optional name, will detect from video source, if not defined
  105446. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105447. * @param scene is obviously the current scene.
  105448. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105449. * @param invertY is false by default but can be used to invert video on Y axis
  105450. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105451. * @param settings allows finer control over video usage
  105452. */
  105453. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105454. private _getName;
  105455. private _getVideo;
  105456. private _createInternalTexture;
  105457. private reset;
  105458. /**
  105459. * @hidden Internal method to initiate `update`.
  105460. */
  105461. _rebuild(): void;
  105462. /**
  105463. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105464. */
  105465. update(): void;
  105466. /**
  105467. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105468. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105469. */
  105470. updateTexture(isVisible: boolean): void;
  105471. protected _updateInternalTexture: () => void;
  105472. /**
  105473. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105474. * @param url New url.
  105475. */
  105476. updateURL(url: string): void;
  105477. /**
  105478. * Clones the texture.
  105479. * @returns the cloned texture
  105480. */
  105481. clone(): VideoTexture;
  105482. /**
  105483. * Dispose the texture and release its associated resources.
  105484. */
  105485. dispose(): void;
  105486. /**
  105487. * Creates a video texture straight from a stream.
  105488. * @param scene Define the scene the texture should be created in
  105489. * @param stream Define the stream the texture should be created from
  105490. * @returns The created video texture as a promise
  105491. */
  105492. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105493. /**
  105494. * Creates a video texture straight from your WebCam video feed.
  105495. * @param scene Define the scene the texture should be created in
  105496. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105497. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105498. * @returns The created video texture as a promise
  105499. */
  105500. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105501. minWidth: number;
  105502. maxWidth: number;
  105503. minHeight: number;
  105504. maxHeight: number;
  105505. deviceId: string;
  105506. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105507. /**
  105508. * Creates a video texture straight from your WebCam video feed.
  105509. * @param scene Define the scene the texture should be created in
  105510. * @param onReady Define a callback to triggered once the texture will be ready
  105511. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105512. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105513. */
  105514. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105515. minWidth: number;
  105516. maxWidth: number;
  105517. minHeight: number;
  105518. maxHeight: number;
  105519. deviceId: string;
  105520. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105521. }
  105522. }
  105523. declare module BABYLON {
  105524. /**
  105525. * Defines the interface used by objects working like Scene
  105526. * @hidden
  105527. */
  105528. export interface ISceneLike {
  105529. _addPendingData(data: any): void;
  105530. _removePendingData(data: any): void;
  105531. offlineProvider: IOfflineProvider;
  105532. }
  105533. /** Interface defining initialization parameters for Engine class */
  105534. export interface EngineOptions extends WebGLContextAttributes {
  105535. /**
  105536. * Defines if the engine should no exceed a specified device ratio
  105537. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105538. */
  105539. limitDeviceRatio?: number;
  105540. /**
  105541. * Defines if webvr should be enabled automatically
  105542. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105543. */
  105544. autoEnableWebVR?: boolean;
  105545. /**
  105546. * Defines if webgl2 should be turned off even if supported
  105547. * @see http://doc.babylonjs.com/features/webgl2
  105548. */
  105549. disableWebGL2Support?: boolean;
  105550. /**
  105551. * Defines if webaudio should be initialized as well
  105552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105553. */
  105554. audioEngine?: boolean;
  105555. /**
  105556. * Defines if animations should run using a deterministic lock step
  105557. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105558. */
  105559. deterministicLockstep?: boolean;
  105560. /** Defines the maximum steps to use with deterministic lock step mode */
  105561. lockstepMaxSteps?: number;
  105562. /** Defines the seconds between each deterministic lock step */
  105563. timeStep?: number;
  105564. /**
  105565. * Defines that engine should ignore context lost events
  105566. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105567. */
  105568. doNotHandleContextLost?: boolean;
  105569. /**
  105570. * Defines that engine should ignore modifying touch action attribute and style
  105571. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105572. */
  105573. doNotHandleTouchAction?: boolean;
  105574. /**
  105575. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105576. */
  105577. useHighPrecisionFloats?: boolean;
  105578. }
  105579. /**
  105580. * The base engine class (root of all engines)
  105581. */
  105582. export class ThinEngine {
  105583. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105584. static ExceptionList: ({
  105585. key: string;
  105586. capture: string;
  105587. captureConstraint: number;
  105588. targets: string[];
  105589. } | {
  105590. key: string;
  105591. capture: null;
  105592. captureConstraint: null;
  105593. targets: string[];
  105594. })[];
  105595. /** @hidden */
  105596. static _TextureLoaders: IInternalTextureLoader[];
  105597. /**
  105598. * Returns the current npm package of the sdk
  105599. */
  105600. static get NpmPackage(): string;
  105601. /**
  105602. * Returns the current version of the framework
  105603. */
  105604. static get Version(): string;
  105605. /**
  105606. * Returns a string describing the current engine
  105607. */
  105608. get description(): string;
  105609. /**
  105610. * Gets or sets the epsilon value used by collision engine
  105611. */
  105612. static CollisionsEpsilon: number;
  105613. /**
  105614. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105615. */
  105616. static get ShadersRepository(): string;
  105617. static set ShadersRepository(value: string);
  105618. /** @hidden */
  105619. _shaderProcessor: IShaderProcessor;
  105620. /**
  105621. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105622. */
  105623. forcePOTTextures: boolean;
  105624. /**
  105625. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105626. */
  105627. isFullscreen: boolean;
  105628. /**
  105629. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105630. */
  105631. cullBackFaces: boolean;
  105632. /**
  105633. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105634. */
  105635. renderEvenInBackground: boolean;
  105636. /**
  105637. * Gets or sets a boolean indicating that cache can be kept between frames
  105638. */
  105639. preventCacheWipeBetweenFrames: boolean;
  105640. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105641. validateShaderPrograms: boolean;
  105642. /**
  105643. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105644. * This can provide greater z depth for distant objects.
  105645. */
  105646. useReverseDepthBuffer: boolean;
  105647. /**
  105648. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105649. */
  105650. disableUniformBuffers: boolean;
  105651. /** @hidden */
  105652. _uniformBuffers: UniformBuffer[];
  105653. /**
  105654. * Gets a boolean indicating that the engine supports uniform buffers
  105655. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105656. */
  105657. get supportsUniformBuffers(): boolean;
  105658. /** @hidden */
  105659. _gl: WebGLRenderingContext;
  105660. /** @hidden */
  105661. _webGLVersion: number;
  105662. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105663. protected _windowIsBackground: boolean;
  105664. protected _creationOptions: EngineOptions;
  105665. protected _highPrecisionShadersAllowed: boolean;
  105666. /** @hidden */
  105667. get _shouldUseHighPrecisionShader(): boolean;
  105668. /**
  105669. * Gets a boolean indicating that only power of 2 textures are supported
  105670. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105671. */
  105672. get needPOTTextures(): boolean;
  105673. /** @hidden */
  105674. _badOS: boolean;
  105675. /** @hidden */
  105676. _badDesktopOS: boolean;
  105677. private _hardwareScalingLevel;
  105678. /** @hidden */
  105679. _caps: EngineCapabilities;
  105680. private _isStencilEnable;
  105681. private _glVersion;
  105682. private _glRenderer;
  105683. private _glVendor;
  105684. /** @hidden */
  105685. _videoTextureSupported: boolean;
  105686. protected _renderingQueueLaunched: boolean;
  105687. protected _activeRenderLoops: (() => void)[];
  105688. /**
  105689. * Observable signaled when a context lost event is raised
  105690. */
  105691. onContextLostObservable: Observable<ThinEngine>;
  105692. /**
  105693. * Observable signaled when a context restored event is raised
  105694. */
  105695. onContextRestoredObservable: Observable<ThinEngine>;
  105696. private _onContextLost;
  105697. private _onContextRestored;
  105698. protected _contextWasLost: boolean;
  105699. /** @hidden */
  105700. _doNotHandleContextLost: boolean;
  105701. /**
  105702. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105704. */
  105705. get doNotHandleContextLost(): boolean;
  105706. set doNotHandleContextLost(value: boolean);
  105707. /**
  105708. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105709. */
  105710. disableVertexArrayObjects: boolean;
  105711. /** @hidden */
  105712. protected _colorWrite: boolean;
  105713. /** @hidden */
  105714. protected _colorWriteChanged: boolean;
  105715. /** @hidden */
  105716. protected _depthCullingState: DepthCullingState;
  105717. /** @hidden */
  105718. protected _stencilState: StencilState;
  105719. /** @hidden */
  105720. _alphaState: AlphaState;
  105721. /** @hidden */
  105722. _alphaMode: number;
  105723. /** @hidden */
  105724. _alphaEquation: number;
  105725. /** @hidden */
  105726. _internalTexturesCache: InternalTexture[];
  105727. /** @hidden */
  105728. protected _activeChannel: number;
  105729. private _currentTextureChannel;
  105730. /** @hidden */
  105731. protected _boundTexturesCache: {
  105732. [key: string]: Nullable<InternalTexture>;
  105733. };
  105734. /** @hidden */
  105735. protected _currentEffect: Nullable<Effect>;
  105736. /** @hidden */
  105737. protected _currentProgram: Nullable<WebGLProgram>;
  105738. private _compiledEffects;
  105739. private _vertexAttribArraysEnabled;
  105740. /** @hidden */
  105741. protected _cachedViewport: Nullable<IViewportLike>;
  105742. private _cachedVertexArrayObject;
  105743. /** @hidden */
  105744. protected _cachedVertexBuffers: any;
  105745. /** @hidden */
  105746. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105747. /** @hidden */
  105748. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105749. /** @hidden */
  105750. _currentRenderTarget: Nullable<InternalTexture>;
  105751. private _uintIndicesCurrentlySet;
  105752. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105753. /** @hidden */
  105754. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105755. private _currentBufferPointers;
  105756. private _currentInstanceLocations;
  105757. private _currentInstanceBuffers;
  105758. private _textureUnits;
  105759. /** @hidden */
  105760. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105761. /** @hidden */
  105762. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105763. /** @hidden */
  105764. _boundRenderFunction: any;
  105765. private _vaoRecordInProgress;
  105766. private _mustWipeVertexAttributes;
  105767. private _emptyTexture;
  105768. private _emptyCubeTexture;
  105769. private _emptyTexture3D;
  105770. private _emptyTexture2DArray;
  105771. /** @hidden */
  105772. _frameHandler: number;
  105773. private _nextFreeTextureSlots;
  105774. private _maxSimultaneousTextures;
  105775. private _activeRequests;
  105776. /** @hidden */
  105777. _transformTextureUrl: Nullable<(url: string) => string>;
  105778. protected get _supportsHardwareTextureRescaling(): boolean;
  105779. private _framebufferDimensionsObject;
  105780. /**
  105781. * sets the object from which width and height will be taken from when getting render width and height
  105782. * Will fallback to the gl object
  105783. * @param dimensions the framebuffer width and height that will be used.
  105784. */
  105785. set framebufferDimensionsObject(dimensions: Nullable<{
  105786. framebufferWidth: number;
  105787. framebufferHeight: number;
  105788. }>);
  105789. /**
  105790. * Gets the current viewport
  105791. */
  105792. get currentViewport(): Nullable<IViewportLike>;
  105793. /**
  105794. * Gets the default empty texture
  105795. */
  105796. get emptyTexture(): InternalTexture;
  105797. /**
  105798. * Gets the default empty 3D texture
  105799. */
  105800. get emptyTexture3D(): InternalTexture;
  105801. /**
  105802. * Gets the default empty 2D array texture
  105803. */
  105804. get emptyTexture2DArray(): InternalTexture;
  105805. /**
  105806. * Gets the default empty cube texture
  105807. */
  105808. get emptyCubeTexture(): InternalTexture;
  105809. /**
  105810. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105811. */
  105812. readonly premultipliedAlpha: boolean;
  105813. /**
  105814. * Observable event triggered before each texture is initialized
  105815. */
  105816. onBeforeTextureInitObservable: Observable<Texture>;
  105817. /**
  105818. * Creates a new engine
  105819. * @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
  105820. * @param antialias defines enable antialiasing (default: false)
  105821. * @param options defines further options to be sent to the getContext() function
  105822. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105823. */
  105824. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105825. private _rebuildInternalTextures;
  105826. private _rebuildEffects;
  105827. /**
  105828. * Gets a boolean indicating if all created effects are ready
  105829. * @returns true if all effects are ready
  105830. */
  105831. areAllEffectsReady(): boolean;
  105832. protected _rebuildBuffers(): void;
  105833. protected _initGLContext(): void;
  105834. /**
  105835. * Gets version of the current webGL context
  105836. */
  105837. get webGLVersion(): number;
  105838. /**
  105839. * Gets a string idenfifying the name of the class
  105840. * @returns "Engine" string
  105841. */
  105842. getClassName(): string;
  105843. /**
  105844. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105845. */
  105846. get isStencilEnable(): boolean;
  105847. /** @hidden */
  105848. _prepareWorkingCanvas(): void;
  105849. /**
  105850. * Reset the texture cache to empty state
  105851. */
  105852. resetTextureCache(): void;
  105853. /**
  105854. * Gets an object containing information about the current webGL context
  105855. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105856. */
  105857. getGlInfo(): {
  105858. vendor: string;
  105859. renderer: string;
  105860. version: string;
  105861. };
  105862. /**
  105863. * Defines the hardware scaling level.
  105864. * By default the hardware scaling level is computed from the window device ratio.
  105865. * 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.
  105866. * @param level defines the level to use
  105867. */
  105868. setHardwareScalingLevel(level: number): void;
  105869. /**
  105870. * Gets the current hardware scaling level.
  105871. * By default the hardware scaling level is computed from the window device ratio.
  105872. * 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.
  105873. * @returns a number indicating the current hardware scaling level
  105874. */
  105875. getHardwareScalingLevel(): number;
  105876. /**
  105877. * Gets the list of loaded textures
  105878. * @returns an array containing all loaded textures
  105879. */
  105880. getLoadedTexturesCache(): InternalTexture[];
  105881. /**
  105882. * Gets the object containing all engine capabilities
  105883. * @returns the EngineCapabilities object
  105884. */
  105885. getCaps(): EngineCapabilities;
  105886. /**
  105887. * stop executing a render loop function and remove it from the execution array
  105888. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105889. */
  105890. stopRenderLoop(renderFunction?: () => void): void;
  105891. /** @hidden */
  105892. _renderLoop(): void;
  105893. /**
  105894. * Gets the HTML canvas attached with the current webGL context
  105895. * @returns a HTML canvas
  105896. */
  105897. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105898. /**
  105899. * Gets host window
  105900. * @returns the host window object
  105901. */
  105902. getHostWindow(): Nullable<Window>;
  105903. /**
  105904. * Gets the current render width
  105905. * @param useScreen defines if screen size must be used (or the current render target if any)
  105906. * @returns a number defining the current render width
  105907. */
  105908. getRenderWidth(useScreen?: boolean): number;
  105909. /**
  105910. * Gets the current render height
  105911. * @param useScreen defines if screen size must be used (or the current render target if any)
  105912. * @returns a number defining the current render height
  105913. */
  105914. getRenderHeight(useScreen?: boolean): number;
  105915. /**
  105916. * Can be used to override the current requestAnimationFrame requester.
  105917. * @hidden
  105918. */
  105919. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105920. /**
  105921. * Register and execute a render loop. The engine can have more than one render function
  105922. * @param renderFunction defines the function to continuously execute
  105923. */
  105924. runRenderLoop(renderFunction: () => void): void;
  105925. /**
  105926. * Clear the current render buffer or the current render target (if any is set up)
  105927. * @param color defines the color to use
  105928. * @param backBuffer defines if the back buffer must be cleared
  105929. * @param depth defines if the depth buffer must be cleared
  105930. * @param stencil defines if the stencil buffer must be cleared
  105931. */
  105932. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105933. private _viewportCached;
  105934. /** @hidden */
  105935. _viewport(x: number, y: number, width: number, height: number): void;
  105936. /**
  105937. * Set the WebGL's viewport
  105938. * @param viewport defines the viewport element to be used
  105939. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105940. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105941. */
  105942. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105943. /**
  105944. * Begin a new frame
  105945. */
  105946. beginFrame(): void;
  105947. /**
  105948. * Enf the current frame
  105949. */
  105950. endFrame(): void;
  105951. /**
  105952. * Resize the view according to the canvas' size
  105953. */
  105954. resize(): void;
  105955. /**
  105956. * Force a specific size of the canvas
  105957. * @param width defines the new canvas' width
  105958. * @param height defines the new canvas' height
  105959. */
  105960. setSize(width: number, height: number): void;
  105961. /**
  105962. * Binds the frame buffer to the specified texture.
  105963. * @param texture The texture to render to or null for the default canvas
  105964. * @param faceIndex The face of the texture to render to in case of cube texture
  105965. * @param requiredWidth The width of the target to render to
  105966. * @param requiredHeight The height of the target to render to
  105967. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105968. * @param lodLevel defines the lod level to bind to the frame buffer
  105969. * @param layer defines the 2d array index to bind to frame buffer to
  105970. */
  105971. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105972. /** @hidden */
  105973. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105974. /**
  105975. * Unbind the current render target texture from the webGL context
  105976. * @param texture defines the render target texture to unbind
  105977. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105978. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105979. */
  105980. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105981. /**
  105982. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105983. */
  105984. flushFramebuffer(): void;
  105985. /**
  105986. * Unbind the current render target and bind the default framebuffer
  105987. */
  105988. restoreDefaultFramebuffer(): void;
  105989. /** @hidden */
  105990. protected _resetVertexBufferBinding(): void;
  105991. /**
  105992. * Creates a vertex buffer
  105993. * @param data the data for the vertex buffer
  105994. * @returns the new WebGL static buffer
  105995. */
  105996. createVertexBuffer(data: DataArray): DataBuffer;
  105997. private _createVertexBuffer;
  105998. /**
  105999. * Creates a dynamic vertex buffer
  106000. * @param data the data for the dynamic vertex buffer
  106001. * @returns the new WebGL dynamic buffer
  106002. */
  106003. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  106004. protected _resetIndexBufferBinding(): void;
  106005. /**
  106006. * Creates a new index buffer
  106007. * @param indices defines the content of the index buffer
  106008. * @param updatable defines if the index buffer must be updatable
  106009. * @returns a new webGL buffer
  106010. */
  106011. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  106012. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  106013. /**
  106014. * Bind a webGL buffer to the webGL context
  106015. * @param buffer defines the buffer to bind
  106016. */
  106017. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  106018. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  106019. private bindBuffer;
  106020. /**
  106021. * update the bound buffer with the given data
  106022. * @param data defines the data to update
  106023. */
  106024. updateArrayBuffer(data: Float32Array): void;
  106025. private _vertexAttribPointer;
  106026. /** @hidden */
  106027. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  106028. private _bindVertexBuffersAttributes;
  106029. /**
  106030. * Records a vertex array object
  106031. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106032. * @param vertexBuffers defines the list of vertex buffers to store
  106033. * @param indexBuffer defines the index buffer to store
  106034. * @param effect defines the effect to store
  106035. * @returns the new vertex array object
  106036. */
  106037. recordVertexArrayObject(vertexBuffers: {
  106038. [key: string]: VertexBuffer;
  106039. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106040. /**
  106041. * Bind a specific vertex array object
  106042. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106043. * @param vertexArrayObject defines the vertex array object to bind
  106044. * @param indexBuffer defines the index buffer to bind
  106045. */
  106046. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106047. /**
  106048. * Bind webGl buffers directly to the webGL context
  106049. * @param vertexBuffer defines the vertex buffer to bind
  106050. * @param indexBuffer defines the index buffer to bind
  106051. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106052. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106053. * @param effect defines the effect associated with the vertex buffer
  106054. */
  106055. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106056. private _unbindVertexArrayObject;
  106057. /**
  106058. * Bind a list of vertex buffers to the webGL context
  106059. * @param vertexBuffers defines the list of vertex buffers to bind
  106060. * @param indexBuffer defines the index buffer to bind
  106061. * @param effect defines the effect associated with the vertex buffers
  106062. */
  106063. bindBuffers(vertexBuffers: {
  106064. [key: string]: Nullable<VertexBuffer>;
  106065. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106066. /**
  106067. * Unbind all instance attributes
  106068. */
  106069. unbindInstanceAttributes(): void;
  106070. /**
  106071. * Release and free the memory of a vertex array object
  106072. * @param vao defines the vertex array object to delete
  106073. */
  106074. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106075. /** @hidden */
  106076. _releaseBuffer(buffer: DataBuffer): boolean;
  106077. protected _deleteBuffer(buffer: DataBuffer): void;
  106078. /**
  106079. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106080. * @param instancesBuffer defines the webGL buffer to update and bind
  106081. * @param data defines the data to store in the buffer
  106082. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106083. */
  106084. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106085. /**
  106086. * Bind the content of a webGL buffer used with instantiation
  106087. * @param instancesBuffer defines the webGL buffer to bind
  106088. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106089. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106090. */
  106091. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106092. /**
  106093. * Disable the instance attribute corresponding to the name in parameter
  106094. * @param name defines the name of the attribute to disable
  106095. */
  106096. disableInstanceAttributeByName(name: string): void;
  106097. /**
  106098. * Disable the instance attribute corresponding to the location in parameter
  106099. * @param attributeLocation defines the attribute location of the attribute to disable
  106100. */
  106101. disableInstanceAttribute(attributeLocation: number): void;
  106102. /**
  106103. * Disable the attribute corresponding to the location in parameter
  106104. * @param attributeLocation defines the attribute location of the attribute to disable
  106105. */
  106106. disableAttributeByIndex(attributeLocation: number): void;
  106107. /**
  106108. * Send a draw order
  106109. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  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. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106115. /**
  106116. * Draw a list of points
  106117. * @param verticesStart defines the index of first vertex to draw
  106118. * @param verticesCount defines the count of vertices to draw
  106119. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106120. */
  106121. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106122. /**
  106123. * Draw a list of unindexed primitives
  106124. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106125. * @param verticesStart defines the index of first vertex to draw
  106126. * @param verticesCount defines the count of vertices to draw
  106127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106128. */
  106129. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106130. /**
  106131. * Draw a list of indexed primitives
  106132. * @param fillMode defines the primitive to use
  106133. * @param indexStart defines the starting index
  106134. * @param indexCount defines the number of index to draw
  106135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106136. */
  106137. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106138. /**
  106139. * Draw a list of unindexed primitives
  106140. * @param fillMode defines the primitive to use
  106141. * @param verticesStart defines the index of first vertex to draw
  106142. * @param verticesCount defines the count of vertices to draw
  106143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106144. */
  106145. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106146. private _drawMode;
  106147. /** @hidden */
  106148. protected _reportDrawCall(): void;
  106149. /** @hidden */
  106150. _releaseEffect(effect: Effect): void;
  106151. /** @hidden */
  106152. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106153. /**
  106154. * Create a new effect (used to store vertex/fragment shaders)
  106155. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106156. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106157. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106158. * @param samplers defines an array of string used to represent textures
  106159. * @param defines defines the string containing the defines to use to compile the shaders
  106160. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106161. * @param onCompiled defines a function to call when the effect creation is successful
  106162. * @param onError defines a function to call when the effect creation has failed
  106163. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106164. * @returns the new Effect
  106165. */
  106166. 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;
  106167. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106168. private _compileShader;
  106169. private _compileRawShader;
  106170. /** @hidden */
  106171. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106172. /**
  106173. * Directly creates a webGL program
  106174. * @param pipelineContext defines the pipeline context to attach to
  106175. * @param vertexCode defines the vertex shader code to use
  106176. * @param fragmentCode defines the fragment shader code to use
  106177. * @param context defines the webGL context to use (if not set, the current one will be used)
  106178. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106179. * @returns the new webGL program
  106180. */
  106181. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106182. /**
  106183. * Creates a webGL program
  106184. * @param pipelineContext defines the pipeline context to attach to
  106185. * @param vertexCode defines the vertex shader code to use
  106186. * @param fragmentCode defines the fragment shader code to use
  106187. * @param defines defines the string containing the defines to use to compile the shaders
  106188. * @param context defines the webGL context to use (if not set, the current one will be used)
  106189. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106190. * @returns the new webGL program
  106191. */
  106192. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106193. /**
  106194. * Creates a new pipeline context
  106195. * @returns the new pipeline
  106196. */
  106197. createPipelineContext(): IPipelineContext;
  106198. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106199. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106200. /** @hidden */
  106201. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106202. /** @hidden */
  106203. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106204. /** @hidden */
  106205. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106206. /**
  106207. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106208. * @param pipelineContext defines the pipeline context to use
  106209. * @param uniformsNames defines the list of uniform names
  106210. * @returns an array of webGL uniform locations
  106211. */
  106212. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106213. /**
  106214. * Gets the lsit of active attributes for a given webGL program
  106215. * @param pipelineContext defines the pipeline context to use
  106216. * @param attributesNames defines the list of attribute names to get
  106217. * @returns an array of indices indicating the offset of each attribute
  106218. */
  106219. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106220. /**
  106221. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106222. * @param effect defines the effect to activate
  106223. */
  106224. enableEffect(effect: Nullable<Effect>): void;
  106225. /**
  106226. * Set the value of an uniform to a number (int)
  106227. * @param uniform defines the webGL uniform location where to store the value
  106228. * @param value defines the int number to store
  106229. */
  106230. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106231. /**
  106232. * Set the value of an uniform to an array of int32
  106233. * @param uniform defines the webGL uniform location where to store the value
  106234. * @param array defines the array of int32 to store
  106235. */
  106236. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106237. /**
  106238. * Set the value of an uniform to an array of int32 (stored as vec2)
  106239. * @param uniform defines the webGL uniform location where to store the value
  106240. * @param array defines the array of int32 to store
  106241. */
  106242. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106243. /**
  106244. * Set the value of an uniform to an array of int32 (stored as vec3)
  106245. * @param uniform defines the webGL uniform location where to store the value
  106246. * @param array defines the array of int32 to store
  106247. */
  106248. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106249. /**
  106250. * Set the value of an uniform to an array of int32 (stored as vec4)
  106251. * @param uniform defines the webGL uniform location where to store the value
  106252. * @param array defines the array of int32 to store
  106253. */
  106254. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106255. /**
  106256. * Set the value of an uniform to an array of number
  106257. * @param uniform defines the webGL uniform location where to store the value
  106258. * @param array defines the array of number to store
  106259. */
  106260. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106261. /**
  106262. * Set the value of an uniform to an array of number (stored as vec2)
  106263. * @param uniform defines the webGL uniform location where to store the value
  106264. * @param array defines the array of number to store
  106265. */
  106266. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106267. /**
  106268. * Set the value of an uniform to an array of number (stored as vec3)
  106269. * @param uniform defines the webGL uniform location where to store the value
  106270. * @param array defines the array of number to store
  106271. */
  106272. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106273. /**
  106274. * Set the value of an uniform to an array of number (stored as vec4)
  106275. * @param uniform defines the webGL uniform location where to store the value
  106276. * @param array defines the array of number to store
  106277. */
  106278. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106279. /**
  106280. * Set the value of an uniform to an array of float32 (stored as matrices)
  106281. * @param uniform defines the webGL uniform location where to store the value
  106282. * @param matrices defines the array of float32 to store
  106283. */
  106284. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106285. /**
  106286. * Set the value of an uniform to a matrix (3x3)
  106287. * @param uniform defines the webGL uniform location where to store the value
  106288. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106289. */
  106290. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106291. /**
  106292. * Set the value of an uniform to a matrix (2x2)
  106293. * @param uniform defines the webGL uniform location where to store the value
  106294. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106295. */
  106296. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106297. /**
  106298. * Set the value of an uniform to a number (float)
  106299. * @param uniform defines the webGL uniform location where to store the value
  106300. * @param value defines the float number to store
  106301. */
  106302. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106303. /**
  106304. * Set the value of an uniform to a vec2
  106305. * @param uniform defines the webGL uniform location where to store the value
  106306. * @param x defines the 1st component of the value
  106307. * @param y defines the 2nd component of the value
  106308. */
  106309. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106310. /**
  106311. * Set the value of an uniform to a vec3
  106312. * @param uniform defines the webGL uniform location where to store the value
  106313. * @param x defines the 1st component of the value
  106314. * @param y defines the 2nd component of the value
  106315. * @param z defines the 3rd component of the value
  106316. */
  106317. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106318. /**
  106319. * Set the value of an uniform to a vec4
  106320. * @param uniform defines the webGL uniform location where to store the value
  106321. * @param x defines the 1st component of the value
  106322. * @param y defines the 2nd component of the value
  106323. * @param z defines the 3rd component of the value
  106324. * @param w defines the 4th component of the value
  106325. */
  106326. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106327. /**
  106328. * Apply all cached states (depth, culling, stencil and alpha)
  106329. */
  106330. applyStates(): void;
  106331. /**
  106332. * Enable or disable color writing
  106333. * @param enable defines the state to set
  106334. */
  106335. setColorWrite(enable: boolean): void;
  106336. /**
  106337. * Gets a boolean indicating if color writing is enabled
  106338. * @returns the current color writing state
  106339. */
  106340. getColorWrite(): boolean;
  106341. /**
  106342. * Gets the depth culling state manager
  106343. */
  106344. get depthCullingState(): DepthCullingState;
  106345. /**
  106346. * Gets the alpha state manager
  106347. */
  106348. get alphaState(): AlphaState;
  106349. /**
  106350. * Gets the stencil state manager
  106351. */
  106352. get stencilState(): StencilState;
  106353. /**
  106354. * Clears the list of texture accessible through engine.
  106355. * This can help preventing texture load conflict due to name collision.
  106356. */
  106357. clearInternalTexturesCache(): void;
  106358. /**
  106359. * Force the entire cache to be cleared
  106360. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106361. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106362. */
  106363. wipeCaches(bruteForce?: boolean): void;
  106364. /** @hidden */
  106365. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106366. min: number;
  106367. mag: number;
  106368. };
  106369. /** @hidden */
  106370. _createTexture(): WebGLTexture;
  106371. /**
  106372. * Usually called from Texture.ts.
  106373. * Passed information to create a WebGLTexture
  106374. * @param url defines a value which contains one of the following:
  106375. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106376. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106377. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106378. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106379. * @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)
  106380. * @param scene needed for loading to the correct scene
  106381. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106382. * @param onLoad optional callback to be called upon successful completion
  106383. * @param onError optional callback to be called upon failure
  106384. * @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
  106385. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106386. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106387. * @param forcedExtension defines the extension to use to pick the right loader
  106388. * @param mimeType defines an optional mime type
  106389. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106390. */
  106391. 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;
  106392. /**
  106393. * Loads an image as an HTMLImageElement.
  106394. * @param input url string, ArrayBuffer, or Blob to load
  106395. * @param onLoad callback called when the image successfully loads
  106396. * @param onError callback called when the image fails to load
  106397. * @param offlineProvider offline provider for caching
  106398. * @param mimeType optional mime type
  106399. * @returns the HTMLImageElement of the loaded image
  106400. * @hidden
  106401. */
  106402. 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>;
  106403. /**
  106404. * @hidden
  106405. */
  106406. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106407. /**
  106408. * Creates a raw texture
  106409. * @param data defines the data to store in the texture
  106410. * @param width defines the width of the texture
  106411. * @param height defines the height of the texture
  106412. * @param format defines the format of the data
  106413. * @param generateMipMaps defines if the engine should generate the mip levels
  106414. * @param invertY defines if data must be stored with Y axis inverted
  106415. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106416. * @param compression defines the compression used (null by default)
  106417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106418. * @returns the raw texture inside an InternalTexture
  106419. */
  106420. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106421. /**
  106422. * Creates a new raw cube texture
  106423. * @param data defines the array of data to use to create each face
  106424. * @param size defines the size of the textures
  106425. * @param format defines the format of the data
  106426. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106427. * @param generateMipMaps defines if the engine should generate the mip levels
  106428. * @param invertY defines if data must be stored with Y axis inverted
  106429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106430. * @param compression defines the compression used (null by default)
  106431. * @returns the cube texture as an InternalTexture
  106432. */
  106433. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106434. /**
  106435. * Creates a new raw 3D texture
  106436. * @param data defines the data used to create the texture
  106437. * @param width defines the width of the texture
  106438. * @param height defines the height of the texture
  106439. * @param depth defines the depth of the texture
  106440. * @param format defines the format of the texture
  106441. * @param generateMipMaps defines if the engine must generate mip levels
  106442. * @param invertY defines if data must be stored with Y axis inverted
  106443. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106444. * @param compression defines the compressed used (can be null)
  106445. * @param textureType defines the compressed used (can be null)
  106446. * @returns a new raw 3D texture (stored in an InternalTexture)
  106447. */
  106448. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106449. /**
  106450. * Creates a new raw 2D array texture
  106451. * @param data defines the data used to create the texture
  106452. * @param width defines the width of the texture
  106453. * @param height defines the height of the texture
  106454. * @param depth defines the number of layers of the texture
  106455. * @param format defines the format of the texture
  106456. * @param generateMipMaps defines if the engine must generate mip levels
  106457. * @param invertY defines if data must be stored with Y axis inverted
  106458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106459. * @param compression defines the compressed used (can be null)
  106460. * @param textureType defines the compressed used (can be null)
  106461. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106462. */
  106463. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106464. private _unpackFlipYCached;
  106465. /**
  106466. * In case you are sharing the context with other applications, it might
  106467. * be interested to not cache the unpack flip y state to ensure a consistent
  106468. * value would be set.
  106469. */
  106470. enableUnpackFlipYCached: boolean;
  106471. /** @hidden */
  106472. _unpackFlipY(value: boolean): void;
  106473. /** @hidden */
  106474. _getUnpackAlignement(): number;
  106475. private _getTextureTarget;
  106476. /**
  106477. * Update the sampling mode of a given texture
  106478. * @param samplingMode defines the required sampling mode
  106479. * @param texture defines the texture to update
  106480. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106481. */
  106482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106483. /**
  106484. * Update the sampling mode of a given texture
  106485. * @param texture defines the texture to update
  106486. * @param wrapU defines the texture wrap mode of the u coordinates
  106487. * @param wrapV defines the texture wrap mode of the v coordinates
  106488. * @param wrapR defines the texture wrap mode of the r coordinates
  106489. */
  106490. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106491. /** @hidden */
  106492. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106493. width: number;
  106494. height: number;
  106495. layers?: number;
  106496. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106497. /** @hidden */
  106498. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106499. /** @hidden */
  106500. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106501. /**
  106502. * Update a portion of an internal texture
  106503. * @param texture defines the texture to update
  106504. * @param imageData defines the data to store into the texture
  106505. * @param xOffset defines the x coordinates of the update rectangle
  106506. * @param yOffset defines the y coordinates of the update rectangle
  106507. * @param width defines the width of the update rectangle
  106508. * @param height defines the height of the update rectangle
  106509. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106510. * @param lod defines the lod level to update (0 by default)
  106511. */
  106512. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106513. /** @hidden */
  106514. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106515. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106516. private _prepareWebGLTexture;
  106517. /** @hidden */
  106518. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106519. private _getDepthStencilBuffer;
  106520. /** @hidden */
  106521. _releaseFramebufferObjects(texture: InternalTexture): void;
  106522. /** @hidden */
  106523. _releaseTexture(texture: InternalTexture): void;
  106524. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106525. protected _setProgram(program: WebGLProgram): void;
  106526. protected _boundUniforms: {
  106527. [key: number]: WebGLUniformLocation;
  106528. };
  106529. /**
  106530. * Binds an effect to the webGL context
  106531. * @param effect defines the effect to bind
  106532. */
  106533. bindSamplers(effect: Effect): void;
  106534. private _activateCurrentTexture;
  106535. /** @hidden */
  106536. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106537. /** @hidden */
  106538. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106539. /**
  106540. * Unbind all textures from the webGL context
  106541. */
  106542. unbindAllTextures(): void;
  106543. /**
  106544. * Sets a texture to the according uniform.
  106545. * @param channel The texture channel
  106546. * @param uniform The uniform to set
  106547. * @param texture The texture to apply
  106548. */
  106549. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106550. private _bindSamplerUniformToChannel;
  106551. private _getTextureWrapMode;
  106552. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106553. /**
  106554. * Sets an array of texture to the webGL context
  106555. * @param channel defines the channel where the texture array must be set
  106556. * @param uniform defines the associated uniform location
  106557. * @param textures defines the array of textures to bind
  106558. */
  106559. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106560. /** @hidden */
  106561. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106562. private _setTextureParameterFloat;
  106563. private _setTextureParameterInteger;
  106564. /**
  106565. * Unbind all vertex attributes from the webGL context
  106566. */
  106567. unbindAllAttributes(): void;
  106568. /**
  106569. * 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
  106570. */
  106571. releaseEffects(): void;
  106572. /**
  106573. * Dispose and release all associated resources
  106574. */
  106575. dispose(): void;
  106576. /**
  106577. * Attach a new callback raised when context lost event is fired
  106578. * @param callback defines the callback to call
  106579. */
  106580. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106581. /**
  106582. * Attach a new callback raised when context restored event is fired
  106583. * @param callback defines the callback to call
  106584. */
  106585. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106586. /**
  106587. * Get the current error code of the webGL context
  106588. * @returns the error code
  106589. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106590. */
  106591. getError(): number;
  106592. private _canRenderToFloatFramebuffer;
  106593. private _canRenderToHalfFloatFramebuffer;
  106594. private _canRenderToFramebuffer;
  106595. /** @hidden */
  106596. _getWebGLTextureType(type: number): number;
  106597. /** @hidden */
  106598. _getInternalFormat(format: number): number;
  106599. /** @hidden */
  106600. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106601. /** @hidden */
  106602. _getRGBAMultiSampleBufferFormat(type: number): number;
  106603. /** @hidden */
  106604. _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;
  106605. /**
  106606. * Loads a file from a url
  106607. * @param url url to load
  106608. * @param onSuccess callback called when the file successfully loads
  106609. * @param onProgress callback called while file is loading (if the server supports this mode)
  106610. * @param offlineProvider defines the offline provider for caching
  106611. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106612. * @param onError callback called when the file fails to load
  106613. * @returns a file request object
  106614. * @hidden
  106615. */
  106616. 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;
  106617. /**
  106618. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106619. * @param x defines the x coordinate of the rectangle where pixels must be read
  106620. * @param y defines the y coordinate of the rectangle where pixels must be read
  106621. * @param width defines the width of the rectangle where pixels must be read
  106622. * @param height defines the height of the rectangle where pixels must be read
  106623. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106624. * @returns a Uint8Array containing RGBA colors
  106625. */
  106626. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106627. private static _isSupported;
  106628. /**
  106629. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106630. * @returns true if the engine can be created
  106631. * @ignorenaming
  106632. */
  106633. static isSupported(): boolean;
  106634. /**
  106635. * Find the next highest power of two.
  106636. * @param x Number to start search from.
  106637. * @return Next highest power of two.
  106638. */
  106639. static CeilingPOT(x: number): number;
  106640. /**
  106641. * Find the next lowest power of two.
  106642. * @param x Number to start search from.
  106643. * @return Next lowest power of two.
  106644. */
  106645. static FloorPOT(x: number): number;
  106646. /**
  106647. * Find the nearest power of two.
  106648. * @param x Number to start search from.
  106649. * @return Next nearest power of two.
  106650. */
  106651. static NearestPOT(x: number): number;
  106652. /**
  106653. * Get the closest exponent of two
  106654. * @param value defines the value to approximate
  106655. * @param max defines the maximum value to return
  106656. * @param mode defines how to define the closest value
  106657. * @returns closest exponent of two of the given value
  106658. */
  106659. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106660. /**
  106661. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106662. * @param func - the function to be called
  106663. * @param requester - the object that will request the next frame. Falls back to window.
  106664. * @returns frame number
  106665. */
  106666. static QueueNewFrame(func: () => void, requester?: any): number;
  106667. /**
  106668. * Gets host document
  106669. * @returns the host document object
  106670. */
  106671. getHostDocument(): Nullable<Document>;
  106672. }
  106673. }
  106674. declare module BABYLON {
  106675. /**
  106676. * Class representing spherical harmonics coefficients to the 3rd degree
  106677. */
  106678. export class SphericalHarmonics {
  106679. /**
  106680. * Defines whether or not the harmonics have been prescaled for rendering.
  106681. */
  106682. preScaled: boolean;
  106683. /**
  106684. * The l0,0 coefficients of the spherical harmonics
  106685. */
  106686. l00: Vector3;
  106687. /**
  106688. * The l1,-1 coefficients of the spherical harmonics
  106689. */
  106690. l1_1: Vector3;
  106691. /**
  106692. * The l1,0 coefficients of the spherical harmonics
  106693. */
  106694. l10: Vector3;
  106695. /**
  106696. * The l1,1 coefficients of the spherical harmonics
  106697. */
  106698. l11: Vector3;
  106699. /**
  106700. * The l2,-2 coefficients of the spherical harmonics
  106701. */
  106702. l2_2: Vector3;
  106703. /**
  106704. * The l2,-1 coefficients of the spherical harmonics
  106705. */
  106706. l2_1: Vector3;
  106707. /**
  106708. * The l2,0 coefficients of the spherical harmonics
  106709. */
  106710. l20: Vector3;
  106711. /**
  106712. * The l2,1 coefficients of the spherical harmonics
  106713. */
  106714. l21: Vector3;
  106715. /**
  106716. * The l2,2 coefficients of the spherical harmonics
  106717. */
  106718. l22: Vector3;
  106719. /**
  106720. * Adds a light to the spherical harmonics
  106721. * @param direction the direction of the light
  106722. * @param color the color of the light
  106723. * @param deltaSolidAngle the delta solid angle of the light
  106724. */
  106725. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106726. /**
  106727. * Scales the spherical harmonics by the given amount
  106728. * @param scale the amount to scale
  106729. */
  106730. scaleInPlace(scale: number): void;
  106731. /**
  106732. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106733. *
  106734. * ```
  106735. * E_lm = A_l * L_lm
  106736. * ```
  106737. *
  106738. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106739. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106740. * the scaling factors are given in equation 9.
  106741. */
  106742. convertIncidentRadianceToIrradiance(): void;
  106743. /**
  106744. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106745. *
  106746. * ```
  106747. * L = (1/pi) * E * rho
  106748. * ```
  106749. *
  106750. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106751. */
  106752. convertIrradianceToLambertianRadiance(): void;
  106753. /**
  106754. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106755. * required operations at run time.
  106756. *
  106757. * This is simply done by scaling back the SH with Ylm constants parameter.
  106758. * The trigonometric part being applied by the shader at run time.
  106759. */
  106760. preScaleForRendering(): void;
  106761. /**
  106762. * Constructs a spherical harmonics from an array.
  106763. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106764. * @returns the spherical harmonics
  106765. */
  106766. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106767. /**
  106768. * Gets the spherical harmonics from polynomial
  106769. * @param polynomial the spherical polynomial
  106770. * @returns the spherical harmonics
  106771. */
  106772. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106773. }
  106774. /**
  106775. * Class representing spherical polynomial coefficients to the 3rd degree
  106776. */
  106777. export class SphericalPolynomial {
  106778. private _harmonics;
  106779. /**
  106780. * The spherical harmonics used to create the polynomials.
  106781. */
  106782. get preScaledHarmonics(): SphericalHarmonics;
  106783. /**
  106784. * The x coefficients of the spherical polynomial
  106785. */
  106786. x: Vector3;
  106787. /**
  106788. * The y coefficients of the spherical polynomial
  106789. */
  106790. y: Vector3;
  106791. /**
  106792. * The z coefficients of the spherical polynomial
  106793. */
  106794. z: Vector3;
  106795. /**
  106796. * The xx coefficients of the spherical polynomial
  106797. */
  106798. xx: Vector3;
  106799. /**
  106800. * The yy coefficients of the spherical polynomial
  106801. */
  106802. yy: Vector3;
  106803. /**
  106804. * The zz coefficients of the spherical polynomial
  106805. */
  106806. zz: Vector3;
  106807. /**
  106808. * The xy coefficients of the spherical polynomial
  106809. */
  106810. xy: Vector3;
  106811. /**
  106812. * The yz coefficients of the spherical polynomial
  106813. */
  106814. yz: Vector3;
  106815. /**
  106816. * The zx coefficients of the spherical polynomial
  106817. */
  106818. zx: Vector3;
  106819. /**
  106820. * Adds an ambient color to the spherical polynomial
  106821. * @param color the color to add
  106822. */
  106823. addAmbient(color: Color3): void;
  106824. /**
  106825. * Scales the spherical polynomial by the given amount
  106826. * @param scale the amount to scale
  106827. */
  106828. scaleInPlace(scale: number): void;
  106829. /**
  106830. * Gets the spherical polynomial from harmonics
  106831. * @param harmonics the spherical harmonics
  106832. * @returns the spherical polynomial
  106833. */
  106834. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106835. /**
  106836. * Constructs a spherical polynomial from an array.
  106837. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106838. * @returns the spherical polynomial
  106839. */
  106840. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106841. }
  106842. }
  106843. declare module BABYLON {
  106844. /**
  106845. * Defines the source of the internal texture
  106846. */
  106847. export enum InternalTextureSource {
  106848. /**
  106849. * The source of the texture data is unknown
  106850. */
  106851. Unknown = 0,
  106852. /**
  106853. * Texture data comes from an URL
  106854. */
  106855. Url = 1,
  106856. /**
  106857. * Texture data is only used for temporary storage
  106858. */
  106859. Temp = 2,
  106860. /**
  106861. * Texture data comes from raw data (ArrayBuffer)
  106862. */
  106863. Raw = 3,
  106864. /**
  106865. * Texture content is dynamic (video or dynamic texture)
  106866. */
  106867. Dynamic = 4,
  106868. /**
  106869. * Texture content is generated by rendering to it
  106870. */
  106871. RenderTarget = 5,
  106872. /**
  106873. * Texture content is part of a multi render target process
  106874. */
  106875. MultiRenderTarget = 6,
  106876. /**
  106877. * Texture data comes from a cube data file
  106878. */
  106879. Cube = 7,
  106880. /**
  106881. * Texture data comes from a raw cube data
  106882. */
  106883. CubeRaw = 8,
  106884. /**
  106885. * Texture data come from a prefiltered cube data file
  106886. */
  106887. CubePrefiltered = 9,
  106888. /**
  106889. * Texture content is raw 3D data
  106890. */
  106891. Raw3D = 10,
  106892. /**
  106893. * Texture content is raw 2D array data
  106894. */
  106895. Raw2DArray = 11,
  106896. /**
  106897. * Texture content is a depth texture
  106898. */
  106899. Depth = 12,
  106900. /**
  106901. * Texture data comes from a raw cube data encoded with RGBD
  106902. */
  106903. CubeRawRGBD = 13
  106904. }
  106905. /**
  106906. * Class used to store data associated with WebGL texture data for the engine
  106907. * This class should not be used directly
  106908. */
  106909. export class InternalTexture {
  106910. /** @hidden */
  106911. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106912. /**
  106913. * Defines if the texture is ready
  106914. */
  106915. isReady: boolean;
  106916. /**
  106917. * Defines if the texture is a cube texture
  106918. */
  106919. isCube: boolean;
  106920. /**
  106921. * Defines if the texture contains 3D data
  106922. */
  106923. is3D: boolean;
  106924. /**
  106925. * Defines if the texture contains 2D array data
  106926. */
  106927. is2DArray: boolean;
  106928. /**
  106929. * Defines if the texture contains multiview data
  106930. */
  106931. isMultiview: boolean;
  106932. /**
  106933. * Gets the URL used to load this texture
  106934. */
  106935. url: string;
  106936. /**
  106937. * Gets the sampling mode of the texture
  106938. */
  106939. samplingMode: number;
  106940. /**
  106941. * Gets a boolean indicating if the texture needs mipmaps generation
  106942. */
  106943. generateMipMaps: boolean;
  106944. /**
  106945. * Gets the number of samples used by the texture (WebGL2+ only)
  106946. */
  106947. samples: number;
  106948. /**
  106949. * Gets the type of the texture (int, float...)
  106950. */
  106951. type: number;
  106952. /**
  106953. * Gets the format of the texture (RGB, RGBA...)
  106954. */
  106955. format: number;
  106956. /**
  106957. * Observable called when the texture is loaded
  106958. */
  106959. onLoadedObservable: Observable<InternalTexture>;
  106960. /**
  106961. * Gets the width of the texture
  106962. */
  106963. width: number;
  106964. /**
  106965. * Gets the height of the texture
  106966. */
  106967. height: number;
  106968. /**
  106969. * Gets the depth of the texture
  106970. */
  106971. depth: number;
  106972. /**
  106973. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106974. */
  106975. baseWidth: number;
  106976. /**
  106977. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106978. */
  106979. baseHeight: number;
  106980. /**
  106981. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106982. */
  106983. baseDepth: number;
  106984. /**
  106985. * Gets a boolean indicating if the texture is inverted on Y axis
  106986. */
  106987. invertY: boolean;
  106988. /** @hidden */
  106989. _invertVScale: boolean;
  106990. /** @hidden */
  106991. _associatedChannel: number;
  106992. /** @hidden */
  106993. _source: InternalTextureSource;
  106994. /** @hidden */
  106995. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106996. /** @hidden */
  106997. _bufferView: Nullable<ArrayBufferView>;
  106998. /** @hidden */
  106999. _bufferViewArray: Nullable<ArrayBufferView[]>;
  107000. /** @hidden */
  107001. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  107002. /** @hidden */
  107003. _size: number;
  107004. /** @hidden */
  107005. _extension: string;
  107006. /** @hidden */
  107007. _files: Nullable<string[]>;
  107008. /** @hidden */
  107009. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107010. /** @hidden */
  107011. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107012. /** @hidden */
  107013. _framebuffer: Nullable<WebGLFramebuffer>;
  107014. /** @hidden */
  107015. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  107016. /** @hidden */
  107017. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  107018. /** @hidden */
  107019. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  107020. /** @hidden */
  107021. _attachments: Nullable<number[]>;
  107022. /** @hidden */
  107023. _cachedCoordinatesMode: Nullable<number>;
  107024. /** @hidden */
  107025. _cachedWrapU: Nullable<number>;
  107026. /** @hidden */
  107027. _cachedWrapV: Nullable<number>;
  107028. /** @hidden */
  107029. _cachedWrapR: Nullable<number>;
  107030. /** @hidden */
  107031. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107032. /** @hidden */
  107033. _isDisabled: boolean;
  107034. /** @hidden */
  107035. _compression: Nullable<string>;
  107036. /** @hidden */
  107037. _generateStencilBuffer: boolean;
  107038. /** @hidden */
  107039. _generateDepthBuffer: boolean;
  107040. /** @hidden */
  107041. _comparisonFunction: number;
  107042. /** @hidden */
  107043. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107044. /** @hidden */
  107045. _lodGenerationScale: number;
  107046. /** @hidden */
  107047. _lodGenerationOffset: number;
  107048. /** @hidden */
  107049. _depthStencilTexture: Nullable<InternalTexture>;
  107050. /** @hidden */
  107051. _colorTextureArray: Nullable<WebGLTexture>;
  107052. /** @hidden */
  107053. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107054. /** @hidden */
  107055. _lodTextureHigh: Nullable<BaseTexture>;
  107056. /** @hidden */
  107057. _lodTextureMid: Nullable<BaseTexture>;
  107058. /** @hidden */
  107059. _lodTextureLow: Nullable<BaseTexture>;
  107060. /** @hidden */
  107061. _isRGBD: boolean;
  107062. /** @hidden */
  107063. _linearSpecularLOD: boolean;
  107064. /** @hidden */
  107065. _irradianceTexture: Nullable<BaseTexture>;
  107066. /** @hidden */
  107067. _webGLTexture: Nullable<WebGLTexture>;
  107068. /** @hidden */
  107069. _references: number;
  107070. private _engine;
  107071. /**
  107072. * Gets the Engine the texture belongs to.
  107073. * @returns The babylon engine
  107074. */
  107075. getEngine(): ThinEngine;
  107076. /**
  107077. * Gets the data source type of the texture
  107078. */
  107079. get source(): InternalTextureSource;
  107080. /**
  107081. * Creates a new InternalTexture
  107082. * @param engine defines the engine to use
  107083. * @param source defines the type of data that will be used
  107084. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107085. */
  107086. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107087. /**
  107088. * Increments the number of references (ie. the number of Texture that point to it)
  107089. */
  107090. incrementReferences(): void;
  107091. /**
  107092. * Change the size of the texture (not the size of the content)
  107093. * @param width defines the new width
  107094. * @param height defines the new height
  107095. * @param depth defines the new depth (1 by default)
  107096. */
  107097. updateSize(width: int, height: int, depth?: int): void;
  107098. /** @hidden */
  107099. _rebuild(): void;
  107100. /** @hidden */
  107101. _swapAndDie(target: InternalTexture): void;
  107102. /**
  107103. * Dispose the current allocated resources
  107104. */
  107105. dispose(): void;
  107106. }
  107107. }
  107108. declare module BABYLON {
  107109. /**
  107110. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107112. */
  107113. export class Analyser {
  107114. /**
  107115. * Gets or sets the smoothing
  107116. * @ignorenaming
  107117. */
  107118. SMOOTHING: number;
  107119. /**
  107120. * Gets or sets the FFT table size
  107121. * @ignorenaming
  107122. */
  107123. FFT_SIZE: number;
  107124. /**
  107125. * Gets or sets the bar graph amplitude
  107126. * @ignorenaming
  107127. */
  107128. BARGRAPHAMPLITUDE: number;
  107129. /**
  107130. * Gets or sets the position of the debug canvas
  107131. * @ignorenaming
  107132. */
  107133. DEBUGCANVASPOS: {
  107134. x: number;
  107135. y: number;
  107136. };
  107137. /**
  107138. * Gets or sets the debug canvas size
  107139. * @ignorenaming
  107140. */
  107141. DEBUGCANVASSIZE: {
  107142. width: number;
  107143. height: number;
  107144. };
  107145. private _byteFreqs;
  107146. private _byteTime;
  107147. private _floatFreqs;
  107148. private _webAudioAnalyser;
  107149. private _debugCanvas;
  107150. private _debugCanvasContext;
  107151. private _scene;
  107152. private _registerFunc;
  107153. private _audioEngine;
  107154. /**
  107155. * Creates a new analyser
  107156. * @param scene defines hosting scene
  107157. */
  107158. constructor(scene: Scene);
  107159. /**
  107160. * Get the number of data values you will have to play with for the visualization
  107161. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107162. * @returns a number
  107163. */
  107164. getFrequencyBinCount(): number;
  107165. /**
  107166. * Gets the current frequency data as a byte array
  107167. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107168. * @returns a Uint8Array
  107169. */
  107170. getByteFrequencyData(): Uint8Array;
  107171. /**
  107172. * Gets the current waveform as a byte array
  107173. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107174. * @returns a Uint8Array
  107175. */
  107176. getByteTimeDomainData(): Uint8Array;
  107177. /**
  107178. * Gets the current frequency data as a float array
  107179. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107180. * @returns a Float32Array
  107181. */
  107182. getFloatFrequencyData(): Float32Array;
  107183. /**
  107184. * Renders the debug canvas
  107185. */
  107186. drawDebugCanvas(): void;
  107187. /**
  107188. * Stops rendering the debug canvas and removes it
  107189. */
  107190. stopDebugCanvas(): void;
  107191. /**
  107192. * Connects two audio nodes
  107193. * @param inputAudioNode defines first node to connect
  107194. * @param outputAudioNode defines second node to connect
  107195. */
  107196. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107197. /**
  107198. * Releases all associated resources
  107199. */
  107200. dispose(): void;
  107201. }
  107202. }
  107203. declare module BABYLON {
  107204. /**
  107205. * This represents an audio engine and it is responsible
  107206. * to play, synchronize and analyse sounds throughout the application.
  107207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107208. */
  107209. export interface IAudioEngine extends IDisposable {
  107210. /**
  107211. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107212. */
  107213. readonly canUseWebAudio: boolean;
  107214. /**
  107215. * Gets the current AudioContext if available.
  107216. */
  107217. readonly audioContext: Nullable<AudioContext>;
  107218. /**
  107219. * The master gain node defines the global audio volume of your audio engine.
  107220. */
  107221. readonly masterGain: GainNode;
  107222. /**
  107223. * Gets whether or not mp3 are supported by your browser.
  107224. */
  107225. readonly isMP3supported: boolean;
  107226. /**
  107227. * Gets whether or not ogg are supported by your browser.
  107228. */
  107229. readonly isOGGsupported: boolean;
  107230. /**
  107231. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107232. * @ignoreNaming
  107233. */
  107234. WarnedWebAudioUnsupported: boolean;
  107235. /**
  107236. * Defines if the audio engine relies on a custom unlocked button.
  107237. * In this case, the embedded button will not be displayed.
  107238. */
  107239. useCustomUnlockedButton: boolean;
  107240. /**
  107241. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107242. */
  107243. readonly unlocked: boolean;
  107244. /**
  107245. * Event raised when audio has been unlocked on the browser.
  107246. */
  107247. onAudioUnlockedObservable: Observable<AudioEngine>;
  107248. /**
  107249. * Event raised when audio has been locked on the browser.
  107250. */
  107251. onAudioLockedObservable: Observable<AudioEngine>;
  107252. /**
  107253. * Flags the audio engine in Locked state.
  107254. * This happens due to new browser policies preventing audio to autoplay.
  107255. */
  107256. lock(): void;
  107257. /**
  107258. * Unlocks the audio engine once a user action has been done on the dom.
  107259. * This is helpful to resume play once browser policies have been satisfied.
  107260. */
  107261. unlock(): void;
  107262. /**
  107263. * Gets the global volume sets on the master gain.
  107264. * @returns the global volume if set or -1 otherwise
  107265. */
  107266. getGlobalVolume(): number;
  107267. /**
  107268. * Sets the global volume of your experience (sets on the master gain).
  107269. * @param newVolume Defines the new global volume of the application
  107270. */
  107271. setGlobalVolume(newVolume: number): void;
  107272. /**
  107273. * Connect the audio engine to an audio analyser allowing some amazing
  107274. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107276. * @param analyser The analyser to connect to the engine
  107277. */
  107278. connectToAnalyser(analyser: Analyser): void;
  107279. }
  107280. /**
  107281. * This represents the default audio engine used in babylon.
  107282. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107284. */
  107285. export class AudioEngine implements IAudioEngine {
  107286. private _audioContext;
  107287. private _audioContextInitialized;
  107288. private _muteButton;
  107289. private _hostElement;
  107290. /**
  107291. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107292. */
  107293. canUseWebAudio: boolean;
  107294. /**
  107295. * The master gain node defines the global audio volume of your audio engine.
  107296. */
  107297. masterGain: GainNode;
  107298. /**
  107299. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107300. * @ignoreNaming
  107301. */
  107302. WarnedWebAudioUnsupported: boolean;
  107303. /**
  107304. * Gets whether or not mp3 are supported by your browser.
  107305. */
  107306. isMP3supported: boolean;
  107307. /**
  107308. * Gets whether or not ogg are supported by your browser.
  107309. */
  107310. isOGGsupported: boolean;
  107311. /**
  107312. * Gets whether audio has been unlocked on the device.
  107313. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107314. * a user interaction has happened.
  107315. */
  107316. unlocked: boolean;
  107317. /**
  107318. * Defines if the audio engine relies on a custom unlocked button.
  107319. * In this case, the embedded button will not be displayed.
  107320. */
  107321. useCustomUnlockedButton: boolean;
  107322. /**
  107323. * Event raised when audio has been unlocked on the browser.
  107324. */
  107325. onAudioUnlockedObservable: Observable<AudioEngine>;
  107326. /**
  107327. * Event raised when audio has been locked on the browser.
  107328. */
  107329. onAudioLockedObservable: Observable<AudioEngine>;
  107330. /**
  107331. * Gets the current AudioContext if available.
  107332. */
  107333. get audioContext(): Nullable<AudioContext>;
  107334. private _connectedAnalyser;
  107335. /**
  107336. * Instantiates a new audio engine.
  107337. *
  107338. * There should be only one per page as some browsers restrict the number
  107339. * of audio contexts you can create.
  107340. * @param hostElement defines the host element where to display the mute icon if necessary
  107341. */
  107342. constructor(hostElement?: Nullable<HTMLElement>);
  107343. /**
  107344. * Flags the audio engine in Locked state.
  107345. * This happens due to new browser policies preventing audio to autoplay.
  107346. */
  107347. lock(): void;
  107348. /**
  107349. * Unlocks the audio engine once a user action has been done on the dom.
  107350. * This is helpful to resume play once browser policies have been satisfied.
  107351. */
  107352. unlock(): void;
  107353. private _resumeAudioContext;
  107354. private _initializeAudioContext;
  107355. private _tryToRun;
  107356. private _triggerRunningState;
  107357. private _triggerSuspendedState;
  107358. private _displayMuteButton;
  107359. private _moveButtonToTopLeft;
  107360. private _onResize;
  107361. private _hideMuteButton;
  107362. /**
  107363. * Destroy and release the resources associated with the audio ccontext.
  107364. */
  107365. dispose(): void;
  107366. /**
  107367. * Gets the global volume sets on the master gain.
  107368. * @returns the global volume if set or -1 otherwise
  107369. */
  107370. getGlobalVolume(): number;
  107371. /**
  107372. * Sets the global volume of your experience (sets on the master gain).
  107373. * @param newVolume Defines the new global volume of the application
  107374. */
  107375. setGlobalVolume(newVolume: number): void;
  107376. /**
  107377. * Connect the audio engine to an audio analyser allowing some amazing
  107378. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107380. * @param analyser The analyser to connect to the engine
  107381. */
  107382. connectToAnalyser(analyser: Analyser): void;
  107383. }
  107384. }
  107385. declare module BABYLON {
  107386. /**
  107387. * Interface used to present a loading screen while loading a scene
  107388. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107389. */
  107390. export interface ILoadingScreen {
  107391. /**
  107392. * Function called to display the loading screen
  107393. */
  107394. displayLoadingUI: () => void;
  107395. /**
  107396. * Function called to hide the loading screen
  107397. */
  107398. hideLoadingUI: () => void;
  107399. /**
  107400. * Gets or sets the color to use for the background
  107401. */
  107402. loadingUIBackgroundColor: string;
  107403. /**
  107404. * Gets or sets the text to display while loading
  107405. */
  107406. loadingUIText: string;
  107407. }
  107408. /**
  107409. * Class used for the default loading screen
  107410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107411. */
  107412. export class DefaultLoadingScreen implements ILoadingScreen {
  107413. private _renderingCanvas;
  107414. private _loadingText;
  107415. private _loadingDivBackgroundColor;
  107416. private _loadingDiv;
  107417. private _loadingTextDiv;
  107418. /** Gets or sets the logo url to use for the default loading screen */
  107419. static DefaultLogoUrl: string;
  107420. /** Gets or sets the spinner url to use for the default loading screen */
  107421. static DefaultSpinnerUrl: string;
  107422. /**
  107423. * Creates a new default loading screen
  107424. * @param _renderingCanvas defines the canvas used to render the scene
  107425. * @param _loadingText defines the default text to display
  107426. * @param _loadingDivBackgroundColor defines the default background color
  107427. */
  107428. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107429. /**
  107430. * Function called to display the loading screen
  107431. */
  107432. displayLoadingUI(): void;
  107433. /**
  107434. * Function called to hide the loading screen
  107435. */
  107436. hideLoadingUI(): void;
  107437. /**
  107438. * Gets or sets the text to display while loading
  107439. */
  107440. set loadingUIText(text: string);
  107441. get loadingUIText(): string;
  107442. /**
  107443. * Gets or sets the color to use for the background
  107444. */
  107445. get loadingUIBackgroundColor(): string;
  107446. set loadingUIBackgroundColor(color: string);
  107447. private _resizeLoadingUI;
  107448. }
  107449. }
  107450. declare module BABYLON {
  107451. /**
  107452. * Interface for any object that can request an animation frame
  107453. */
  107454. export interface ICustomAnimationFrameRequester {
  107455. /**
  107456. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107457. */
  107458. renderFunction?: Function;
  107459. /**
  107460. * Called to request the next frame to render to
  107461. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107462. */
  107463. requestAnimationFrame: Function;
  107464. /**
  107465. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107466. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107467. */
  107468. requestID?: number;
  107469. }
  107470. }
  107471. declare module BABYLON {
  107472. /**
  107473. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107474. */
  107475. export class PerformanceMonitor {
  107476. private _enabled;
  107477. private _rollingFrameTime;
  107478. private _lastFrameTimeMs;
  107479. /**
  107480. * constructor
  107481. * @param frameSampleSize The number of samples required to saturate the sliding window
  107482. */
  107483. constructor(frameSampleSize?: number);
  107484. /**
  107485. * Samples current frame
  107486. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107487. */
  107488. sampleFrame(timeMs?: number): void;
  107489. /**
  107490. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107491. */
  107492. get averageFrameTime(): number;
  107493. /**
  107494. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107495. */
  107496. get averageFrameTimeVariance(): number;
  107497. /**
  107498. * Returns the frame time of the most recent frame
  107499. */
  107500. get instantaneousFrameTime(): number;
  107501. /**
  107502. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107503. */
  107504. get averageFPS(): number;
  107505. /**
  107506. * Returns the average framerate in frames per second using the most recent frame time
  107507. */
  107508. get instantaneousFPS(): number;
  107509. /**
  107510. * Returns true if enough samples have been taken to completely fill the sliding window
  107511. */
  107512. get isSaturated(): boolean;
  107513. /**
  107514. * Enables contributions to the sliding window sample set
  107515. */
  107516. enable(): void;
  107517. /**
  107518. * Disables contributions to the sliding window sample set
  107519. * Samples will not be interpolated over the disabled period
  107520. */
  107521. disable(): void;
  107522. /**
  107523. * Returns true if sampling is enabled
  107524. */
  107525. get isEnabled(): boolean;
  107526. /**
  107527. * Resets performance monitor
  107528. */
  107529. reset(): void;
  107530. }
  107531. /**
  107532. * RollingAverage
  107533. *
  107534. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107535. */
  107536. export class RollingAverage {
  107537. /**
  107538. * Current average
  107539. */
  107540. average: number;
  107541. /**
  107542. * Current variance
  107543. */
  107544. variance: number;
  107545. protected _samples: Array<number>;
  107546. protected _sampleCount: number;
  107547. protected _pos: number;
  107548. protected _m2: number;
  107549. /**
  107550. * constructor
  107551. * @param length The number of samples required to saturate the sliding window
  107552. */
  107553. constructor(length: number);
  107554. /**
  107555. * Adds a sample to the sample set
  107556. * @param v The sample value
  107557. */
  107558. add(v: number): void;
  107559. /**
  107560. * Returns previously added values or null if outside of history or outside the sliding window domain
  107561. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107562. * @return Value previously recorded with add() or null if outside of range
  107563. */
  107564. history(i: number): number;
  107565. /**
  107566. * Returns true if enough samples have been taken to completely fill the sliding window
  107567. * @return true if sample-set saturated
  107568. */
  107569. isSaturated(): boolean;
  107570. /**
  107571. * Resets the rolling average (equivalent to 0 samples taken so far)
  107572. */
  107573. reset(): void;
  107574. /**
  107575. * Wraps a value around the sample range boundaries
  107576. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107577. * @return Wrapped position in sample range
  107578. */
  107579. protected _wrapPosition(i: number): number;
  107580. }
  107581. }
  107582. declare module BABYLON {
  107583. /**
  107584. * This class is used to track a performance counter which is number based.
  107585. * The user has access to many properties which give statistics of different nature.
  107586. *
  107587. * The implementer can track two kinds of Performance Counter: time and count.
  107588. * 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.
  107589. * 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.
  107590. */
  107591. export class PerfCounter {
  107592. /**
  107593. * Gets or sets a global boolean to turn on and off all the counters
  107594. */
  107595. static Enabled: boolean;
  107596. /**
  107597. * Returns the smallest value ever
  107598. */
  107599. get min(): number;
  107600. /**
  107601. * Returns the biggest value ever
  107602. */
  107603. get max(): number;
  107604. /**
  107605. * Returns the average value since the performance counter is running
  107606. */
  107607. get average(): number;
  107608. /**
  107609. * Returns the average value of the last second the counter was monitored
  107610. */
  107611. get lastSecAverage(): number;
  107612. /**
  107613. * Returns the current value
  107614. */
  107615. get current(): number;
  107616. /**
  107617. * Gets the accumulated total
  107618. */
  107619. get total(): number;
  107620. /**
  107621. * Gets the total value count
  107622. */
  107623. get count(): number;
  107624. /**
  107625. * Creates a new counter
  107626. */
  107627. constructor();
  107628. /**
  107629. * Call this method to start monitoring a new frame.
  107630. * 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.
  107631. */
  107632. fetchNewFrame(): void;
  107633. /**
  107634. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107635. * @param newCount the count value to add to the monitored count
  107636. * @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.
  107637. */
  107638. addCount(newCount: number, fetchResult: boolean): void;
  107639. /**
  107640. * Start monitoring this performance counter
  107641. */
  107642. beginMonitoring(): void;
  107643. /**
  107644. * Compute the time lapsed since the previous beginMonitoring() call.
  107645. * @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
  107646. */
  107647. endMonitoring(newFrame?: boolean): void;
  107648. private _fetchResult;
  107649. private _startMonitoringTime;
  107650. private _min;
  107651. private _max;
  107652. private _average;
  107653. private _current;
  107654. private _totalValueCount;
  107655. private _totalAccumulated;
  107656. private _lastSecAverage;
  107657. private _lastSecAccumulated;
  107658. private _lastSecTime;
  107659. private _lastSecValueCount;
  107660. }
  107661. }
  107662. declare module BABYLON {
  107663. interface ThinEngine {
  107664. /**
  107665. * Sets alpha constants used by some alpha blending modes
  107666. * @param r defines the red component
  107667. * @param g defines the green component
  107668. * @param b defines the blue component
  107669. * @param a defines the alpha component
  107670. */
  107671. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107672. /**
  107673. * Sets the current alpha mode
  107674. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107675. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107677. */
  107678. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107679. /**
  107680. * Gets the current alpha mode
  107681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107682. * @returns the current alpha mode
  107683. */
  107684. getAlphaMode(): number;
  107685. /**
  107686. * Sets the current alpha equation
  107687. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107688. */
  107689. setAlphaEquation(equation: number): void;
  107690. /**
  107691. * Gets the current alpha equation.
  107692. * @returns the current alpha equation
  107693. */
  107694. getAlphaEquation(): number;
  107695. }
  107696. }
  107697. declare module BABYLON {
  107698. /**
  107699. * Defines the interface used by display changed events
  107700. */
  107701. export interface IDisplayChangedEventArgs {
  107702. /** Gets the vrDisplay object (if any) */
  107703. vrDisplay: Nullable<any>;
  107704. /** Gets a boolean indicating if webVR is supported */
  107705. vrSupported: boolean;
  107706. }
  107707. /**
  107708. * Defines the interface used by objects containing a viewport (like a camera)
  107709. */
  107710. interface IViewportOwnerLike {
  107711. /**
  107712. * Gets or sets the viewport
  107713. */
  107714. viewport: IViewportLike;
  107715. }
  107716. /**
  107717. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107718. */
  107719. export class Engine extends ThinEngine {
  107720. /** Defines that alpha blending is disabled */
  107721. static readonly ALPHA_DISABLE: number;
  107722. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107723. static readonly ALPHA_ADD: number;
  107724. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107725. static readonly ALPHA_COMBINE: number;
  107726. /** Defines that alpha blending to DEST - SRC * DEST */
  107727. static readonly ALPHA_SUBTRACT: number;
  107728. /** Defines that alpha blending to SRC * DEST */
  107729. static readonly ALPHA_MULTIPLY: number;
  107730. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107731. static readonly ALPHA_MAXIMIZED: number;
  107732. /** Defines that alpha blending to SRC + DEST */
  107733. static readonly ALPHA_ONEONE: number;
  107734. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107735. static readonly ALPHA_PREMULTIPLIED: number;
  107736. /**
  107737. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107738. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107739. */
  107740. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107741. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107742. static readonly ALPHA_INTERPOLATE: number;
  107743. /**
  107744. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107745. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107746. */
  107747. static readonly ALPHA_SCREENMODE: number;
  107748. /** Defines that the ressource is not delayed*/
  107749. static readonly DELAYLOADSTATE_NONE: number;
  107750. /** Defines that the ressource was successfully delay loaded */
  107751. static readonly DELAYLOADSTATE_LOADED: number;
  107752. /** Defines that the ressource is currently delay loading */
  107753. static readonly DELAYLOADSTATE_LOADING: number;
  107754. /** Defines that the ressource is delayed and has not started loading */
  107755. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107757. static readonly NEVER: number;
  107758. /** 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 */
  107759. static readonly ALWAYS: number;
  107760. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107761. static readonly LESS: number;
  107762. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107763. static readonly EQUAL: number;
  107764. /** 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 */
  107765. static readonly LEQUAL: number;
  107766. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107767. static readonly GREATER: number;
  107768. /** 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 */
  107769. static readonly GEQUAL: number;
  107770. /** 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 */
  107771. static readonly NOTEQUAL: number;
  107772. /** Passed to stencilOperation to specify that stencil value must be kept */
  107773. static readonly KEEP: number;
  107774. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107775. static readonly REPLACE: number;
  107776. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107777. static readonly INCR: number;
  107778. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107779. static readonly DECR: number;
  107780. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107781. static readonly INVERT: number;
  107782. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107783. static readonly INCR_WRAP: number;
  107784. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107785. static readonly DECR_WRAP: number;
  107786. /** Texture is not repeating outside of 0..1 UVs */
  107787. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107788. /** Texture is repeating outside of 0..1 UVs */
  107789. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107790. /** Texture is repeating and mirrored */
  107791. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107792. /** ALPHA */
  107793. static readonly TEXTUREFORMAT_ALPHA: number;
  107794. /** LUMINANCE */
  107795. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107796. /** LUMINANCE_ALPHA */
  107797. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107798. /** RGB */
  107799. static readonly TEXTUREFORMAT_RGB: number;
  107800. /** RGBA */
  107801. static readonly TEXTUREFORMAT_RGBA: number;
  107802. /** RED */
  107803. static readonly TEXTUREFORMAT_RED: number;
  107804. /** RED (2nd reference) */
  107805. static readonly TEXTUREFORMAT_R: number;
  107806. /** RG */
  107807. static readonly TEXTUREFORMAT_RG: number;
  107808. /** RED_INTEGER */
  107809. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107810. /** RED_INTEGER (2nd reference) */
  107811. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107812. /** RG_INTEGER */
  107813. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107814. /** RGB_INTEGER */
  107815. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107816. /** RGBA_INTEGER */
  107817. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107818. /** UNSIGNED_BYTE */
  107819. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107820. /** UNSIGNED_BYTE (2nd reference) */
  107821. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107822. /** FLOAT */
  107823. static readonly TEXTURETYPE_FLOAT: number;
  107824. /** HALF_FLOAT */
  107825. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107826. /** BYTE */
  107827. static readonly TEXTURETYPE_BYTE: number;
  107828. /** SHORT */
  107829. static readonly TEXTURETYPE_SHORT: number;
  107830. /** UNSIGNED_SHORT */
  107831. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107832. /** INT */
  107833. static readonly TEXTURETYPE_INT: number;
  107834. /** UNSIGNED_INT */
  107835. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107836. /** UNSIGNED_SHORT_4_4_4_4 */
  107837. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107838. /** UNSIGNED_SHORT_5_5_5_1 */
  107839. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107840. /** UNSIGNED_SHORT_5_6_5 */
  107841. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107842. /** UNSIGNED_INT_2_10_10_10_REV */
  107843. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107844. /** UNSIGNED_INT_24_8 */
  107845. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107846. /** UNSIGNED_INT_10F_11F_11F_REV */
  107847. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107848. /** UNSIGNED_INT_5_9_9_9_REV */
  107849. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107850. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107851. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107852. /** nearest is mag = nearest and min = nearest and mip = linear */
  107853. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107854. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107855. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107856. /** Trilinear is mag = linear and min = linear and mip = linear */
  107857. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107858. /** nearest is mag = nearest and min = nearest and mip = linear */
  107859. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107860. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107861. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107862. /** Trilinear is mag = linear and min = linear and mip = linear */
  107863. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107864. /** mag = nearest and min = nearest and mip = nearest */
  107865. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107866. /** mag = nearest and min = linear and mip = nearest */
  107867. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107868. /** mag = nearest and min = linear and mip = linear */
  107869. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107870. /** mag = nearest and min = linear and mip = none */
  107871. static readonly TEXTURE_NEAREST_LINEAR: number;
  107872. /** mag = nearest and min = nearest and mip = none */
  107873. static readonly TEXTURE_NEAREST_NEAREST: number;
  107874. /** mag = linear and min = nearest and mip = nearest */
  107875. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107876. /** mag = linear and min = nearest and mip = linear */
  107877. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107878. /** mag = linear and min = linear and mip = none */
  107879. static readonly TEXTURE_LINEAR_LINEAR: number;
  107880. /** mag = linear and min = nearest and mip = none */
  107881. static readonly TEXTURE_LINEAR_NEAREST: number;
  107882. /** Explicit coordinates mode */
  107883. static readonly TEXTURE_EXPLICIT_MODE: number;
  107884. /** Spherical coordinates mode */
  107885. static readonly TEXTURE_SPHERICAL_MODE: number;
  107886. /** Planar coordinates mode */
  107887. static readonly TEXTURE_PLANAR_MODE: number;
  107888. /** Cubic coordinates mode */
  107889. static readonly TEXTURE_CUBIC_MODE: number;
  107890. /** Projection coordinates mode */
  107891. static readonly TEXTURE_PROJECTION_MODE: number;
  107892. /** Skybox coordinates mode */
  107893. static readonly TEXTURE_SKYBOX_MODE: number;
  107894. /** Inverse Cubic coordinates mode */
  107895. static readonly TEXTURE_INVCUBIC_MODE: number;
  107896. /** Equirectangular coordinates mode */
  107897. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107898. /** Equirectangular Fixed coordinates mode */
  107899. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107900. /** Equirectangular Fixed Mirrored coordinates mode */
  107901. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107902. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107903. static readonly SCALEMODE_FLOOR: number;
  107904. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107905. static readonly SCALEMODE_NEAREST: number;
  107906. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107907. static readonly SCALEMODE_CEILING: number;
  107908. /**
  107909. * Returns the current npm package of the sdk
  107910. */
  107911. static get NpmPackage(): string;
  107912. /**
  107913. * Returns the current version of the framework
  107914. */
  107915. static get Version(): string;
  107916. /** Gets the list of created engines */
  107917. static get Instances(): Engine[];
  107918. /**
  107919. * Gets the latest created engine
  107920. */
  107921. static get LastCreatedEngine(): Nullable<Engine>;
  107922. /**
  107923. * Gets the latest created scene
  107924. */
  107925. static get LastCreatedScene(): Nullable<Scene>;
  107926. /**
  107927. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107928. * @param flag defines which part of the materials must be marked as dirty
  107929. * @param predicate defines a predicate used to filter which materials should be affected
  107930. */
  107931. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107932. /**
  107933. * Method called to create the default loading screen.
  107934. * This can be overriden in your own app.
  107935. * @param canvas The rendering canvas element
  107936. * @returns The loading screen
  107937. */
  107938. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107939. /**
  107940. * Method called to create the default rescale post process on each engine.
  107941. */
  107942. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107943. /**
  107944. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107945. **/
  107946. enableOfflineSupport: boolean;
  107947. /**
  107948. * 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)
  107949. **/
  107950. disableManifestCheck: boolean;
  107951. /**
  107952. * Gets the list of created scenes
  107953. */
  107954. scenes: Scene[];
  107955. /**
  107956. * Event raised when a new scene is created
  107957. */
  107958. onNewSceneAddedObservable: Observable<Scene>;
  107959. /**
  107960. * Gets the list of created postprocesses
  107961. */
  107962. postProcesses: PostProcess[];
  107963. /**
  107964. * Gets a boolean indicating if the pointer is currently locked
  107965. */
  107966. isPointerLock: boolean;
  107967. /**
  107968. * Observable event triggered each time the rendering canvas is resized
  107969. */
  107970. onResizeObservable: Observable<Engine>;
  107971. /**
  107972. * Observable event triggered each time the canvas loses focus
  107973. */
  107974. onCanvasBlurObservable: Observable<Engine>;
  107975. /**
  107976. * Observable event triggered each time the canvas gains focus
  107977. */
  107978. onCanvasFocusObservable: Observable<Engine>;
  107979. /**
  107980. * Observable event triggered each time the canvas receives pointerout event
  107981. */
  107982. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107983. /**
  107984. * Observable raised when the engine begins a new frame
  107985. */
  107986. onBeginFrameObservable: Observable<Engine>;
  107987. /**
  107988. * If set, will be used to request the next animation frame for the render loop
  107989. */
  107990. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107991. /**
  107992. * Observable raised when the engine ends the current frame
  107993. */
  107994. onEndFrameObservable: Observable<Engine>;
  107995. /**
  107996. * Observable raised when the engine is about to compile a shader
  107997. */
  107998. onBeforeShaderCompilationObservable: Observable<Engine>;
  107999. /**
  108000. * Observable raised when the engine has jsut compiled a shader
  108001. */
  108002. onAfterShaderCompilationObservable: Observable<Engine>;
  108003. /**
  108004. * Gets the audio engine
  108005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108006. * @ignorenaming
  108007. */
  108008. static audioEngine: IAudioEngine;
  108009. /**
  108010. * Default AudioEngine factory responsible of creating the Audio Engine.
  108011. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  108012. */
  108013. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  108014. /**
  108015. * Default offline support factory responsible of creating a tool used to store data locally.
  108016. * By default, this will create a Database object if the workload has been embedded.
  108017. */
  108018. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  108019. private _loadingScreen;
  108020. private _pointerLockRequested;
  108021. private _dummyFramebuffer;
  108022. private _rescalePostProcess;
  108023. private _deterministicLockstep;
  108024. private _lockstepMaxSteps;
  108025. private _timeStep;
  108026. protected get _supportsHardwareTextureRescaling(): boolean;
  108027. private _fps;
  108028. private _deltaTime;
  108029. /** @hidden */
  108030. _drawCalls: PerfCounter;
  108031. /** 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 */
  108032. canvasTabIndex: number;
  108033. /**
  108034. * Turn this value on if you want to pause FPS computation when in background
  108035. */
  108036. disablePerformanceMonitorInBackground: boolean;
  108037. private _performanceMonitor;
  108038. /**
  108039. * Gets the performance monitor attached to this engine
  108040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108041. */
  108042. get performanceMonitor(): PerformanceMonitor;
  108043. private _onFocus;
  108044. private _onBlur;
  108045. private _onCanvasPointerOut;
  108046. private _onCanvasBlur;
  108047. private _onCanvasFocus;
  108048. private _onFullscreenChange;
  108049. private _onPointerLockChange;
  108050. /**
  108051. * Gets the HTML element used to attach event listeners
  108052. * @returns a HTML element
  108053. */
  108054. getInputElement(): Nullable<HTMLElement>;
  108055. /**
  108056. * Creates a new engine
  108057. * @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
  108058. * @param antialias defines enable antialiasing (default: false)
  108059. * @param options defines further options to be sent to the getContext() function
  108060. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108061. */
  108062. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108063. /**
  108064. * Gets current aspect ratio
  108065. * @param viewportOwner defines the camera to use to get the aspect ratio
  108066. * @param useScreen defines if screen size must be used (or the current render target if any)
  108067. * @returns a number defining the aspect ratio
  108068. */
  108069. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108070. /**
  108071. * Gets current screen aspect ratio
  108072. * @returns a number defining the aspect ratio
  108073. */
  108074. getScreenAspectRatio(): number;
  108075. /**
  108076. * Gets the client rect of the HTML canvas attached with the current webGL context
  108077. * @returns a client rectanglee
  108078. */
  108079. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108080. /**
  108081. * Gets the client rect of the HTML element used for events
  108082. * @returns a client rectanglee
  108083. */
  108084. getInputElementClientRect(): Nullable<ClientRect>;
  108085. /**
  108086. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108088. * @returns true if engine is in deterministic lock step mode
  108089. */
  108090. isDeterministicLockStep(): boolean;
  108091. /**
  108092. * Gets the max steps when engine is running in deterministic lock step
  108093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108094. * @returns the max steps
  108095. */
  108096. getLockstepMaxSteps(): number;
  108097. /**
  108098. * Returns the time in ms between steps when using deterministic lock step.
  108099. * @returns time step in (ms)
  108100. */
  108101. getTimeStep(): number;
  108102. /**
  108103. * Force the mipmap generation for the given render target texture
  108104. * @param texture defines the render target texture to use
  108105. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108106. */
  108107. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108108. /** States */
  108109. /**
  108110. * Set various states to the webGL context
  108111. * @param culling defines backface culling state
  108112. * @param zOffset defines the value to apply to zOffset (0 by default)
  108113. * @param force defines if states must be applied even if cache is up to date
  108114. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108115. */
  108116. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108117. /**
  108118. * Set the z offset to apply to current rendering
  108119. * @param value defines the offset to apply
  108120. */
  108121. setZOffset(value: number): void;
  108122. /**
  108123. * Gets the current value of the zOffset
  108124. * @returns the current zOffset state
  108125. */
  108126. getZOffset(): number;
  108127. /**
  108128. * Enable or disable depth buffering
  108129. * @param enable defines the state to set
  108130. */
  108131. setDepthBuffer(enable: boolean): void;
  108132. /**
  108133. * Gets a boolean indicating if depth writing is enabled
  108134. * @returns the current depth writing state
  108135. */
  108136. getDepthWrite(): boolean;
  108137. /**
  108138. * Enable or disable depth writing
  108139. * @param enable defines the state to set
  108140. */
  108141. setDepthWrite(enable: boolean): void;
  108142. /**
  108143. * Gets a boolean indicating if stencil buffer is enabled
  108144. * @returns the current stencil buffer state
  108145. */
  108146. getStencilBuffer(): boolean;
  108147. /**
  108148. * Enable or disable the stencil buffer
  108149. * @param enable defines if the stencil buffer must be enabled or disabled
  108150. */
  108151. setStencilBuffer(enable: boolean): void;
  108152. /**
  108153. * Gets the current stencil mask
  108154. * @returns a number defining the new stencil mask to use
  108155. */
  108156. getStencilMask(): number;
  108157. /**
  108158. * Sets the current stencil mask
  108159. * @param mask defines the new stencil mask to use
  108160. */
  108161. setStencilMask(mask: number): void;
  108162. /**
  108163. * Gets the current stencil function
  108164. * @returns a number defining the stencil function to use
  108165. */
  108166. getStencilFunction(): number;
  108167. /**
  108168. * Gets the current stencil reference value
  108169. * @returns a number defining the stencil reference value to use
  108170. */
  108171. getStencilFunctionReference(): number;
  108172. /**
  108173. * Gets the current stencil mask
  108174. * @returns a number defining the stencil mask to use
  108175. */
  108176. getStencilFunctionMask(): number;
  108177. /**
  108178. * Sets the current stencil function
  108179. * @param stencilFunc defines the new stencil function to use
  108180. */
  108181. setStencilFunction(stencilFunc: number): void;
  108182. /**
  108183. * Sets the current stencil reference
  108184. * @param reference defines the new stencil reference to use
  108185. */
  108186. setStencilFunctionReference(reference: number): void;
  108187. /**
  108188. * Sets the current stencil mask
  108189. * @param mask defines the new stencil mask to use
  108190. */
  108191. setStencilFunctionMask(mask: number): void;
  108192. /**
  108193. * Gets the current stencil operation when stencil fails
  108194. * @returns a number defining stencil operation to use when stencil fails
  108195. */
  108196. getStencilOperationFail(): number;
  108197. /**
  108198. * Gets the current stencil operation when depth fails
  108199. * @returns a number defining stencil operation to use when depth fails
  108200. */
  108201. getStencilOperationDepthFail(): number;
  108202. /**
  108203. * Gets the current stencil operation when stencil passes
  108204. * @returns a number defining stencil operation to use when stencil passes
  108205. */
  108206. getStencilOperationPass(): number;
  108207. /**
  108208. * Sets the stencil operation to use when stencil fails
  108209. * @param operation defines the stencil operation to use when stencil fails
  108210. */
  108211. setStencilOperationFail(operation: number): void;
  108212. /**
  108213. * Sets the stencil operation to use when depth fails
  108214. * @param operation defines the stencil operation to use when depth fails
  108215. */
  108216. setStencilOperationDepthFail(operation: number): void;
  108217. /**
  108218. * Sets the stencil operation to use when stencil passes
  108219. * @param operation defines the stencil operation to use when stencil passes
  108220. */
  108221. setStencilOperationPass(operation: number): void;
  108222. /**
  108223. * Sets a boolean indicating if the dithering state is enabled or disabled
  108224. * @param value defines the dithering state
  108225. */
  108226. setDitheringState(value: boolean): void;
  108227. /**
  108228. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108229. * @param value defines the rasterizer state
  108230. */
  108231. setRasterizerState(value: boolean): void;
  108232. /**
  108233. * Gets the current depth function
  108234. * @returns a number defining the depth function
  108235. */
  108236. getDepthFunction(): Nullable<number>;
  108237. /**
  108238. * Sets the current depth function
  108239. * @param depthFunc defines the function to use
  108240. */
  108241. setDepthFunction(depthFunc: number): void;
  108242. /**
  108243. * Sets the current depth function to GREATER
  108244. */
  108245. setDepthFunctionToGreater(): void;
  108246. /**
  108247. * Sets the current depth function to GEQUAL
  108248. */
  108249. setDepthFunctionToGreaterOrEqual(): void;
  108250. /**
  108251. * Sets the current depth function to LESS
  108252. */
  108253. setDepthFunctionToLess(): void;
  108254. /**
  108255. * Sets the current depth function to LEQUAL
  108256. */
  108257. setDepthFunctionToLessOrEqual(): void;
  108258. private _cachedStencilBuffer;
  108259. private _cachedStencilFunction;
  108260. private _cachedStencilMask;
  108261. private _cachedStencilOperationPass;
  108262. private _cachedStencilOperationFail;
  108263. private _cachedStencilOperationDepthFail;
  108264. private _cachedStencilReference;
  108265. /**
  108266. * Caches the the state of the stencil buffer
  108267. */
  108268. cacheStencilState(): void;
  108269. /**
  108270. * Restores the state of the stencil buffer
  108271. */
  108272. restoreStencilState(): void;
  108273. /**
  108274. * Directly set the WebGL Viewport
  108275. * @param x defines the x coordinate of the viewport (in screen space)
  108276. * @param y defines the y coordinate of the viewport (in screen space)
  108277. * @param width defines the width of the viewport (in screen space)
  108278. * @param height defines the height of the viewport (in screen space)
  108279. * @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
  108280. */
  108281. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108282. /**
  108283. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108284. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108285. * @param y defines the y-coordinate of the corner of the clear rectangle
  108286. * @param width defines the width of the clear rectangle
  108287. * @param height defines the height of the clear rectangle
  108288. * @param clearColor defines the clear color
  108289. */
  108290. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108291. /**
  108292. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108293. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108294. * @param y defines the y-coordinate of the corner of the clear rectangle
  108295. * @param width defines the width of the clear rectangle
  108296. * @param height defines the height of the clear rectangle
  108297. */
  108298. enableScissor(x: number, y: number, width: number, height: number): void;
  108299. /**
  108300. * Disable previously set scissor test rectangle
  108301. */
  108302. disableScissor(): void;
  108303. protected _reportDrawCall(): void;
  108304. /**
  108305. * Initializes a webVR display and starts listening to display change events
  108306. * The onVRDisplayChangedObservable will be notified upon these changes
  108307. * @returns The onVRDisplayChangedObservable
  108308. */
  108309. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108310. /** @hidden */
  108311. _prepareVRComponent(): void;
  108312. /** @hidden */
  108313. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108314. /** @hidden */
  108315. _submitVRFrame(): void;
  108316. /**
  108317. * Call this function to leave webVR mode
  108318. * Will do nothing if webVR is not supported or if there is no webVR device
  108319. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108320. */
  108321. disableVR(): void;
  108322. /**
  108323. * Gets a boolean indicating that the system is in VR mode and is presenting
  108324. * @returns true if VR mode is engaged
  108325. */
  108326. isVRPresenting(): boolean;
  108327. /** @hidden */
  108328. _requestVRFrame(): void;
  108329. /** @hidden */
  108330. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108331. /**
  108332. * Gets the source code of the vertex shader associated with a specific webGL program
  108333. * @param program defines the program to use
  108334. * @returns a string containing the source code of the vertex shader associated with the program
  108335. */
  108336. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108337. /**
  108338. * Gets the source code of the fragment shader associated with a specific webGL program
  108339. * @param program defines the program to use
  108340. * @returns a string containing the source code of the fragment shader associated with the program
  108341. */
  108342. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108343. /**
  108344. * Sets a depth stencil texture from a render target to the according uniform.
  108345. * @param channel The texture channel
  108346. * @param uniform The uniform to set
  108347. * @param texture The render target texture containing the depth stencil texture to apply
  108348. */
  108349. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108350. /**
  108351. * Sets a texture to the webGL context from a postprocess
  108352. * @param channel defines the channel to use
  108353. * @param postProcess defines the source postprocess
  108354. */
  108355. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108356. /**
  108357. * Binds the output of the passed in post process to the texture channel specified
  108358. * @param channel The channel the texture should be bound to
  108359. * @param postProcess The post process which's output should be bound
  108360. */
  108361. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108362. /** @hidden */
  108363. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108364. protected _rebuildBuffers(): void;
  108365. /** @hidden */
  108366. _renderFrame(): void;
  108367. _renderLoop(): void;
  108368. /** @hidden */
  108369. _renderViews(): boolean;
  108370. /**
  108371. * Toggle full screen mode
  108372. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108373. */
  108374. switchFullscreen(requestPointerLock: boolean): void;
  108375. /**
  108376. * Enters full screen mode
  108377. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108378. */
  108379. enterFullscreen(requestPointerLock: boolean): void;
  108380. /**
  108381. * Exits full screen mode
  108382. */
  108383. exitFullscreen(): void;
  108384. /**
  108385. * Enters Pointerlock mode
  108386. */
  108387. enterPointerlock(): void;
  108388. /**
  108389. * Exits Pointerlock mode
  108390. */
  108391. exitPointerlock(): void;
  108392. /**
  108393. * Begin a new frame
  108394. */
  108395. beginFrame(): void;
  108396. /**
  108397. * Enf the current frame
  108398. */
  108399. endFrame(): void;
  108400. resize(): void;
  108401. /**
  108402. * Force a specific size of the canvas
  108403. * @param width defines the new canvas' width
  108404. * @param height defines the new canvas' height
  108405. */
  108406. setSize(width: number, height: number): void;
  108407. /**
  108408. * Updates a dynamic vertex buffer.
  108409. * @param vertexBuffer the vertex buffer to update
  108410. * @param data the data used to update the vertex buffer
  108411. * @param byteOffset the byte offset of the data
  108412. * @param byteLength the byte length of the data
  108413. */
  108414. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108415. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108416. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108417. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108418. _releaseTexture(texture: InternalTexture): void;
  108419. /**
  108420. * @hidden
  108421. * Rescales a texture
  108422. * @param source input texutre
  108423. * @param destination destination texture
  108424. * @param scene scene to use to render the resize
  108425. * @param internalFormat format to use when resizing
  108426. * @param onComplete callback to be called when resize has completed
  108427. */
  108428. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108429. /**
  108430. * Gets the current framerate
  108431. * @returns a number representing the framerate
  108432. */
  108433. getFps(): number;
  108434. /**
  108435. * Gets the time spent between current and previous frame
  108436. * @returns a number representing the delta time in ms
  108437. */
  108438. getDeltaTime(): number;
  108439. private _measureFps;
  108440. /** @hidden */
  108441. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108442. /**
  108443. * Update a dynamic index buffer
  108444. * @param indexBuffer defines the target index buffer
  108445. * @param indices defines the data to update
  108446. * @param offset defines the offset in the target index buffer where update should start
  108447. */
  108448. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108449. /**
  108450. * Updates the sample count of a render target texture
  108451. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108452. * @param texture defines the texture to update
  108453. * @param samples defines the sample count to set
  108454. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108455. */
  108456. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108457. /**
  108458. * Updates a depth texture Comparison Mode and Function.
  108459. * If the comparison Function is equal to 0, the mode will be set to none.
  108460. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108461. * @param texture The texture to set the comparison function for
  108462. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108463. */
  108464. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108465. /**
  108466. * Creates a webGL buffer to use with instanciation
  108467. * @param capacity defines the size of the buffer
  108468. * @returns the webGL buffer
  108469. */
  108470. createInstancesBuffer(capacity: number): DataBuffer;
  108471. /**
  108472. * Delete a webGL buffer used with instanciation
  108473. * @param buffer defines the webGL buffer to delete
  108474. */
  108475. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108476. private _clientWaitAsync;
  108477. /** @hidden */
  108478. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108479. /** @hidden */
  108480. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108481. dispose(): void;
  108482. private _disableTouchAction;
  108483. /**
  108484. * Display the loading screen
  108485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108486. */
  108487. displayLoadingUI(): void;
  108488. /**
  108489. * Hide the loading screen
  108490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108491. */
  108492. hideLoadingUI(): void;
  108493. /**
  108494. * Gets the current loading screen object
  108495. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108496. */
  108497. get loadingScreen(): ILoadingScreen;
  108498. /**
  108499. * Sets the current loading screen object
  108500. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108501. */
  108502. set loadingScreen(loadingScreen: ILoadingScreen);
  108503. /**
  108504. * Sets the current loading screen text
  108505. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108506. */
  108507. set loadingUIText(text: string);
  108508. /**
  108509. * Sets the current loading screen background color
  108510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108511. */
  108512. set loadingUIBackgroundColor(color: string);
  108513. /** Pointerlock and fullscreen */
  108514. /**
  108515. * Ask the browser to promote the current element to pointerlock mode
  108516. * @param element defines the DOM element to promote
  108517. */
  108518. static _RequestPointerlock(element: HTMLElement): void;
  108519. /**
  108520. * Asks the browser to exit pointerlock mode
  108521. */
  108522. static _ExitPointerlock(): void;
  108523. /**
  108524. * Ask the browser to promote the current element to fullscreen rendering mode
  108525. * @param element defines the DOM element to promote
  108526. */
  108527. static _RequestFullscreen(element: HTMLElement): void;
  108528. /**
  108529. * Asks the browser to exit fullscreen mode
  108530. */
  108531. static _ExitFullscreen(): void;
  108532. }
  108533. }
  108534. declare module BABYLON {
  108535. /**
  108536. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108537. * during the life time of the application.
  108538. */
  108539. export class EngineStore {
  108540. /** Gets the list of created engines */
  108541. static Instances: Engine[];
  108542. /** @hidden */
  108543. static _LastCreatedScene: Nullable<Scene>;
  108544. /**
  108545. * Gets the latest created engine
  108546. */
  108547. static get LastCreatedEngine(): Nullable<Engine>;
  108548. /**
  108549. * Gets the latest created scene
  108550. */
  108551. static get LastCreatedScene(): Nullable<Scene>;
  108552. /**
  108553. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108554. * @ignorenaming
  108555. */
  108556. static UseFallbackTexture: boolean;
  108557. /**
  108558. * Texture content used if a texture cannot loaded
  108559. * @ignorenaming
  108560. */
  108561. static FallbackTexture: string;
  108562. }
  108563. }
  108564. declare module BABYLON {
  108565. /**
  108566. * Helper class that provides a small promise polyfill
  108567. */
  108568. export class PromisePolyfill {
  108569. /**
  108570. * Static function used to check if the polyfill is required
  108571. * If this is the case then the function will inject the polyfill to window.Promise
  108572. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108573. */
  108574. static Apply(force?: boolean): void;
  108575. }
  108576. }
  108577. declare module BABYLON {
  108578. /**
  108579. * Interface for screenshot methods with describe argument called `size` as object with options
  108580. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108581. */
  108582. export interface IScreenshotSize {
  108583. /**
  108584. * number in pixels for canvas height
  108585. */
  108586. height?: number;
  108587. /**
  108588. * multiplier allowing render at a higher or lower resolution
  108589. * If value is defined then height and width will be ignored and taken from camera
  108590. */
  108591. precision?: number;
  108592. /**
  108593. * number in pixels for canvas width
  108594. */
  108595. width?: number;
  108596. }
  108597. }
  108598. declare module BABYLON {
  108599. interface IColor4Like {
  108600. r: float;
  108601. g: float;
  108602. b: float;
  108603. a: float;
  108604. }
  108605. /**
  108606. * Class containing a set of static utilities functions
  108607. */
  108608. export class Tools {
  108609. /**
  108610. * Gets or sets the base URL to use to load assets
  108611. */
  108612. static get BaseUrl(): string;
  108613. static set BaseUrl(value: string);
  108614. /**
  108615. * Enable/Disable Custom HTTP Request Headers globally.
  108616. * default = false
  108617. * @see CustomRequestHeaders
  108618. */
  108619. static UseCustomRequestHeaders: boolean;
  108620. /**
  108621. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108622. * i.e. when loading files, where the server/service expects an Authorization header
  108623. */
  108624. static CustomRequestHeaders: {
  108625. [key: string]: string;
  108626. };
  108627. /**
  108628. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108629. */
  108630. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108631. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108632. /**
  108633. * Default behaviour for cors in the application.
  108634. * It can be a string if the expected behavior is identical in the entire app.
  108635. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108636. */
  108637. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108638. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108639. /**
  108640. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108641. * @ignorenaming
  108642. */
  108643. static get UseFallbackTexture(): boolean;
  108644. static set UseFallbackTexture(value: boolean);
  108645. /**
  108646. * Use this object to register external classes like custom textures or material
  108647. * to allow the laoders to instantiate them
  108648. */
  108649. static get RegisteredExternalClasses(): {
  108650. [key: string]: Object;
  108651. };
  108652. static set RegisteredExternalClasses(classes: {
  108653. [key: string]: Object;
  108654. });
  108655. /**
  108656. * Texture content used if a texture cannot loaded
  108657. * @ignorenaming
  108658. */
  108659. static get fallbackTexture(): string;
  108660. static set fallbackTexture(value: string);
  108661. /**
  108662. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108663. * @param u defines the coordinate on X axis
  108664. * @param v defines the coordinate on Y axis
  108665. * @param width defines the width of the source data
  108666. * @param height defines the height of the source data
  108667. * @param pixels defines the source byte array
  108668. * @param color defines the output color
  108669. */
  108670. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108671. /**
  108672. * Interpolates between a and b via alpha
  108673. * @param a The lower value (returned when alpha = 0)
  108674. * @param b The upper value (returned when alpha = 1)
  108675. * @param alpha The interpolation-factor
  108676. * @return The mixed value
  108677. */
  108678. static Mix(a: number, b: number, alpha: number): number;
  108679. /**
  108680. * Tries to instantiate a new object from a given class name
  108681. * @param className defines the class name to instantiate
  108682. * @returns the new object or null if the system was not able to do the instantiation
  108683. */
  108684. static Instantiate(className: string): any;
  108685. /**
  108686. * Provides a slice function that will work even on IE
  108687. * @param data defines the array to slice
  108688. * @param start defines the start of the data (optional)
  108689. * @param end defines the end of the data (optional)
  108690. * @returns the new sliced array
  108691. */
  108692. static Slice<T>(data: T, start?: number, end?: number): T;
  108693. /**
  108694. * Polyfill for setImmediate
  108695. * @param action defines the action to execute after the current execution block
  108696. */
  108697. static SetImmediate(action: () => void): void;
  108698. /**
  108699. * Function indicating if a number is an exponent of 2
  108700. * @param value defines the value to test
  108701. * @returns true if the value is an exponent of 2
  108702. */
  108703. static IsExponentOfTwo(value: number): boolean;
  108704. private static _tmpFloatArray;
  108705. /**
  108706. * Returns the nearest 32-bit single precision float representation of a Number
  108707. * @param value A Number. If the parameter is of a different type, it will get converted
  108708. * to a number or to NaN if it cannot be converted
  108709. * @returns number
  108710. */
  108711. static FloatRound(value: number): number;
  108712. /**
  108713. * Extracts the filename from a path
  108714. * @param path defines the path to use
  108715. * @returns the filename
  108716. */
  108717. static GetFilename(path: string): string;
  108718. /**
  108719. * Extracts the "folder" part of a path (everything before the filename).
  108720. * @param uri The URI to extract the info from
  108721. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108722. * @returns The "folder" part of the path
  108723. */
  108724. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108725. /**
  108726. * Extracts text content from a DOM element hierarchy
  108727. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108728. */
  108729. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108730. /**
  108731. * Convert an angle in radians to degrees
  108732. * @param angle defines the angle to convert
  108733. * @returns the angle in degrees
  108734. */
  108735. static ToDegrees(angle: number): number;
  108736. /**
  108737. * Convert an angle in degrees to radians
  108738. * @param angle defines the angle to convert
  108739. * @returns the angle in radians
  108740. */
  108741. static ToRadians(angle: number): number;
  108742. /**
  108743. * Returns an array if obj is not an array
  108744. * @param obj defines the object to evaluate as an array
  108745. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108746. * @returns either obj directly if obj is an array or a new array containing obj
  108747. */
  108748. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108749. /**
  108750. * Gets the pointer prefix to use
  108751. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108752. */
  108753. static GetPointerPrefix(): string;
  108754. /**
  108755. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108756. * @param url define the url we are trying
  108757. * @param element define the dom element where to configure the cors policy
  108758. */
  108759. static SetCorsBehavior(url: string | string[], element: {
  108760. crossOrigin: string | null;
  108761. }): void;
  108762. /**
  108763. * Removes unwanted characters from an url
  108764. * @param url defines the url to clean
  108765. * @returns the cleaned url
  108766. */
  108767. static CleanUrl(url: string): string;
  108768. /**
  108769. * Gets or sets a function used to pre-process url before using them to load assets
  108770. */
  108771. static get PreprocessUrl(): (url: string) => string;
  108772. static set PreprocessUrl(processor: (url: string) => string);
  108773. /**
  108774. * Loads an image as an HTMLImageElement.
  108775. * @param input url string, ArrayBuffer, or Blob to load
  108776. * @param onLoad callback called when the image successfully loads
  108777. * @param onError callback called when the image fails to load
  108778. * @param offlineProvider offline provider for caching
  108779. * @param mimeType optional mime type
  108780. * @returns the HTMLImageElement of the loaded image
  108781. */
  108782. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108783. /**
  108784. * Loads a file from a url
  108785. * @param url url string, ArrayBuffer, or Blob to load
  108786. * @param onSuccess callback called when the file successfully loads
  108787. * @param onProgress callback called while file is loading (if the server supports this mode)
  108788. * @param offlineProvider defines the offline provider for caching
  108789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108790. * @param onError callback called when the file fails to load
  108791. * @returns a file request object
  108792. */
  108793. 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;
  108794. /**
  108795. * Loads a file from a url
  108796. * @param url the file url to load
  108797. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108798. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108799. */
  108800. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108801. /**
  108802. * Load a script (identified by an url). When the url returns, the
  108803. * content of this file is added into a new script element, attached to the DOM (body element)
  108804. * @param scriptUrl defines the url of the script to laod
  108805. * @param onSuccess defines the callback called when the script is loaded
  108806. * @param onError defines the callback to call if an error occurs
  108807. * @param scriptId defines the id of the script element
  108808. */
  108809. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108810. /**
  108811. * Load an asynchronous script (identified by an url). When the url returns, the
  108812. * content of this file is added into a new script element, attached to the DOM (body element)
  108813. * @param scriptUrl defines the url of the script to laod
  108814. * @param scriptId defines the id of the script element
  108815. * @returns a promise request object
  108816. */
  108817. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108818. /**
  108819. * Loads a file from a blob
  108820. * @param fileToLoad defines the blob to use
  108821. * @param callback defines the callback to call when data is loaded
  108822. * @param progressCallback defines the callback to call during loading process
  108823. * @returns a file request object
  108824. */
  108825. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108826. /**
  108827. * Reads a file from a File object
  108828. * @param file defines the file to load
  108829. * @param onSuccess defines the callback to call when data is loaded
  108830. * @param onProgress defines the callback to call during loading process
  108831. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108832. * @param onError defines the callback to call when an error occurs
  108833. * @returns a file request object
  108834. */
  108835. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108836. /**
  108837. * Creates a data url from a given string content
  108838. * @param content defines the content to convert
  108839. * @returns the new data url link
  108840. */
  108841. static FileAsURL(content: string): string;
  108842. /**
  108843. * Format the given number to a specific decimal format
  108844. * @param value defines the number to format
  108845. * @param decimals defines the number of decimals to use
  108846. * @returns the formatted string
  108847. */
  108848. static Format(value: number, decimals?: number): string;
  108849. /**
  108850. * Tries to copy an object by duplicating every property
  108851. * @param source defines the source object
  108852. * @param destination defines the target object
  108853. * @param doNotCopyList defines a list of properties to avoid
  108854. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108855. */
  108856. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108857. /**
  108858. * Gets a boolean indicating if the given object has no own property
  108859. * @param obj defines the object to test
  108860. * @returns true if object has no own property
  108861. */
  108862. static IsEmpty(obj: any): boolean;
  108863. /**
  108864. * Function used to register events at window level
  108865. * @param windowElement defines the Window object to use
  108866. * @param events defines the events to register
  108867. */
  108868. static RegisterTopRootEvents(windowElement: Window, events: {
  108869. name: string;
  108870. handler: Nullable<(e: FocusEvent) => any>;
  108871. }[]): void;
  108872. /**
  108873. * Function used to unregister events from window level
  108874. * @param windowElement defines the Window object to use
  108875. * @param events defines the events to unregister
  108876. */
  108877. static UnregisterTopRootEvents(windowElement: Window, events: {
  108878. name: string;
  108879. handler: Nullable<(e: FocusEvent) => any>;
  108880. }[]): void;
  108881. /**
  108882. * @ignore
  108883. */
  108884. static _ScreenshotCanvas: HTMLCanvasElement;
  108885. /**
  108886. * Dumps the current bound framebuffer
  108887. * @param width defines the rendering width
  108888. * @param height defines the rendering height
  108889. * @param engine defines the hosting engine
  108890. * @param successCallback defines the callback triggered once the data are available
  108891. * @param mimeType defines the mime type of the result
  108892. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108893. */
  108894. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108895. /**
  108896. * Converts the canvas data to blob.
  108897. * This acts as a polyfill for browsers not supporting the to blob function.
  108898. * @param canvas Defines the canvas to extract the data from
  108899. * @param successCallback Defines the callback triggered once the data are available
  108900. * @param mimeType Defines the mime type of the result
  108901. */
  108902. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108903. /**
  108904. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108905. * @param successCallback defines the callback triggered once the data are available
  108906. * @param mimeType defines the mime type of the result
  108907. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108908. */
  108909. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108910. /**
  108911. * Downloads a blob in the browser
  108912. * @param blob defines the blob to download
  108913. * @param fileName defines the name of the downloaded file
  108914. */
  108915. static Download(blob: Blob, fileName: string): void;
  108916. /**
  108917. * Captures a screenshot of the current rendering
  108918. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108919. * @param engine defines the rendering engine
  108920. * @param camera defines the source camera
  108921. * @param size This parameter can be set to a single number or to an object with the
  108922. * following (optional) properties: precision, width, height. If a single number is passed,
  108923. * it will be used for both width and height. If an object is passed, the screenshot size
  108924. * will be derived from the parameters. The precision property is a multiplier allowing
  108925. * rendering at a higher or lower resolution
  108926. * @param successCallback defines the callback receives a single parameter which contains the
  108927. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108928. * src parameter of an <img> to display it
  108929. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108930. * Check your browser for supported MIME types
  108931. */
  108932. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108933. /**
  108934. * Captures a screenshot of the current rendering
  108935. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108936. * @param engine defines the rendering engine
  108937. * @param camera defines the source camera
  108938. * @param size This parameter can be set to a single number or to an object with the
  108939. * following (optional) properties: precision, width, height. If a single number is passed,
  108940. * it will be used for both width and height. If an object is passed, the screenshot size
  108941. * will be derived from the parameters. The precision property is a multiplier allowing
  108942. * rendering at a higher or lower resolution
  108943. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108944. * Check your browser for supported MIME types
  108945. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108946. * to the src parameter of an <img> to display it
  108947. */
  108948. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108949. /**
  108950. * Generates an image screenshot from the specified camera.
  108951. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108952. * @param engine The engine to use for rendering
  108953. * @param camera The camera to use for rendering
  108954. * @param size This parameter can be set to a single number or to an object with the
  108955. * following (optional) properties: precision, width, height. If a single number is passed,
  108956. * it will be used for both width and height. If an object is passed, the screenshot size
  108957. * will be derived from the parameters. The precision property is a multiplier allowing
  108958. * rendering at a higher or lower resolution
  108959. * @param successCallback The callback receives a single parameter which contains the
  108960. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108961. * src parameter of an <img> to display it
  108962. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108963. * Check your browser for supported MIME types
  108964. * @param samples Texture samples (default: 1)
  108965. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108966. * @param fileName A name for for the downloaded file.
  108967. */
  108968. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108969. /**
  108970. * Generates an image screenshot from the specified camera.
  108971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108972. * @param engine The engine to use for rendering
  108973. * @param camera The camera to use for rendering
  108974. * @param size This parameter can be set to a single number or to an object with the
  108975. * following (optional) properties: precision, width, height. If a single number is passed,
  108976. * it will be used for both width and height. If an object is passed, the screenshot size
  108977. * will be derived from the parameters. The precision property is a multiplier allowing
  108978. * rendering at a higher or lower resolution
  108979. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108980. * Check your browser for supported MIME types
  108981. * @param samples Texture samples (default: 1)
  108982. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108983. * @param fileName A name for for the downloaded file.
  108984. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108985. * to the src parameter of an <img> to display it
  108986. */
  108987. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108988. /**
  108989. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108990. * Be aware Math.random() could cause collisions, but:
  108991. * "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"
  108992. * @returns a pseudo random id
  108993. */
  108994. static RandomId(): string;
  108995. /**
  108996. * Test if the given uri is a base64 string
  108997. * @param uri The uri to test
  108998. * @return True if the uri is a base64 string or false otherwise
  108999. */
  109000. static IsBase64(uri: string): boolean;
  109001. /**
  109002. * Decode the given base64 uri.
  109003. * @param uri The uri to decode
  109004. * @return The decoded base64 data.
  109005. */
  109006. static DecodeBase64(uri: string): ArrayBuffer;
  109007. /**
  109008. * Gets the absolute url.
  109009. * @param url the input url
  109010. * @return the absolute url
  109011. */
  109012. static GetAbsoluteUrl(url: string): string;
  109013. /**
  109014. * No log
  109015. */
  109016. static readonly NoneLogLevel: number;
  109017. /**
  109018. * Only message logs
  109019. */
  109020. static readonly MessageLogLevel: number;
  109021. /**
  109022. * Only warning logs
  109023. */
  109024. static readonly WarningLogLevel: number;
  109025. /**
  109026. * Only error logs
  109027. */
  109028. static readonly ErrorLogLevel: number;
  109029. /**
  109030. * All logs
  109031. */
  109032. static readonly AllLogLevel: number;
  109033. /**
  109034. * Gets a value indicating the number of loading errors
  109035. * @ignorenaming
  109036. */
  109037. static get errorsCount(): number;
  109038. /**
  109039. * Callback called when a new log is added
  109040. */
  109041. static OnNewCacheEntry: (entry: string) => void;
  109042. /**
  109043. * Log a message to the console
  109044. * @param message defines the message to log
  109045. */
  109046. static Log(message: string): void;
  109047. /**
  109048. * Write a warning message to the console
  109049. * @param message defines the message to log
  109050. */
  109051. static Warn(message: string): void;
  109052. /**
  109053. * Write an error message to the console
  109054. * @param message defines the message to log
  109055. */
  109056. static Error(message: string): void;
  109057. /**
  109058. * Gets current log cache (list of logs)
  109059. */
  109060. static get LogCache(): string;
  109061. /**
  109062. * Clears the log cache
  109063. */
  109064. static ClearLogCache(): void;
  109065. /**
  109066. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109067. */
  109068. static set LogLevels(level: number);
  109069. /**
  109070. * Checks if the window object exists
  109071. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109072. */
  109073. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109074. /**
  109075. * No performance log
  109076. */
  109077. static readonly PerformanceNoneLogLevel: number;
  109078. /**
  109079. * Use user marks to log performance
  109080. */
  109081. static readonly PerformanceUserMarkLogLevel: number;
  109082. /**
  109083. * Log performance to the console
  109084. */
  109085. static readonly PerformanceConsoleLogLevel: number;
  109086. private static _performance;
  109087. /**
  109088. * Sets the current performance log level
  109089. */
  109090. static set PerformanceLogLevel(level: number);
  109091. private static _StartPerformanceCounterDisabled;
  109092. private static _EndPerformanceCounterDisabled;
  109093. private static _StartUserMark;
  109094. private static _EndUserMark;
  109095. private static _StartPerformanceConsole;
  109096. private static _EndPerformanceConsole;
  109097. /**
  109098. * Starts a performance counter
  109099. */
  109100. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109101. /**
  109102. * Ends a specific performance coutner
  109103. */
  109104. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109105. /**
  109106. * Gets either window.performance.now() if supported or Date.now() else
  109107. */
  109108. static get Now(): number;
  109109. /**
  109110. * This method will return the name of the class used to create the instance of the given object.
  109111. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109112. * @param object the object to get the class name from
  109113. * @param isType defines if the object is actually a type
  109114. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109115. */
  109116. static GetClassName(object: any, isType?: boolean): string;
  109117. /**
  109118. * Gets the first element of an array satisfying a given predicate
  109119. * @param array defines the array to browse
  109120. * @param predicate defines the predicate to use
  109121. * @returns null if not found or the element
  109122. */
  109123. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109124. /**
  109125. * This method will return the name of the full name of the class, including its owning module (if any).
  109126. * 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).
  109127. * @param object the object to get the class name from
  109128. * @param isType defines if the object is actually a type
  109129. * @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.
  109130. * @ignorenaming
  109131. */
  109132. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109133. /**
  109134. * Returns a promise that resolves after the given amount of time.
  109135. * @param delay Number of milliseconds to delay
  109136. * @returns Promise that resolves after the given amount of time
  109137. */
  109138. static DelayAsync(delay: number): Promise<void>;
  109139. /**
  109140. * Utility function to detect if the current user agent is Safari
  109141. * @returns whether or not the current user agent is safari
  109142. */
  109143. static IsSafari(): boolean;
  109144. }
  109145. /**
  109146. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109147. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109148. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109149. * @param name The name of the class, case should be preserved
  109150. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109151. */
  109152. export function className(name: string, module?: string): (target: Object) => void;
  109153. /**
  109154. * An implementation of a loop for asynchronous functions.
  109155. */
  109156. export class AsyncLoop {
  109157. /**
  109158. * Defines the number of iterations for the loop
  109159. */
  109160. iterations: number;
  109161. /**
  109162. * Defines the current index of the loop.
  109163. */
  109164. index: number;
  109165. private _done;
  109166. private _fn;
  109167. private _successCallback;
  109168. /**
  109169. * Constructor.
  109170. * @param iterations the number of iterations.
  109171. * @param func the function to run each iteration
  109172. * @param successCallback the callback that will be called upon succesful execution
  109173. * @param offset starting offset.
  109174. */
  109175. constructor(
  109176. /**
  109177. * Defines the number of iterations for the loop
  109178. */
  109179. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109180. /**
  109181. * Execute the next iteration. Must be called after the last iteration was finished.
  109182. */
  109183. executeNext(): void;
  109184. /**
  109185. * Break the loop and run the success callback.
  109186. */
  109187. breakLoop(): void;
  109188. /**
  109189. * Create and run an async loop.
  109190. * @param iterations the number of iterations.
  109191. * @param fn the function to run each iteration
  109192. * @param successCallback the callback that will be called upon succesful execution
  109193. * @param offset starting offset.
  109194. * @returns the created async loop object
  109195. */
  109196. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109197. /**
  109198. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109199. * @param iterations total number of iterations
  109200. * @param syncedIterations number of synchronous iterations in each async iteration.
  109201. * @param fn the function to call each iteration.
  109202. * @param callback a success call back that will be called when iterating stops.
  109203. * @param breakFunction a break condition (optional)
  109204. * @param timeout timeout settings for the setTimeout function. default - 0.
  109205. * @returns the created async loop object
  109206. */
  109207. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109208. }
  109209. }
  109210. declare module BABYLON {
  109211. /**
  109212. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109213. * The underlying implementation relies on an associative array to ensure the best performances.
  109214. * The value can be anything including 'null' but except 'undefined'
  109215. */
  109216. export class StringDictionary<T> {
  109217. /**
  109218. * This will clear this dictionary and copy the content from the 'source' one.
  109219. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109220. * @param source the dictionary to take the content from and copy to this dictionary
  109221. */
  109222. copyFrom(source: StringDictionary<T>): void;
  109223. /**
  109224. * Get a value based from its key
  109225. * @param key the given key to get the matching value from
  109226. * @return the value if found, otherwise undefined is returned
  109227. */
  109228. get(key: string): T | undefined;
  109229. /**
  109230. * Get a value from its key or add it if it doesn't exist.
  109231. * This method will ensure you that a given key/data will be present in the dictionary.
  109232. * @param key the given key to get the matching value from
  109233. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109234. * The factory will only be invoked if there's no data for the given key.
  109235. * @return the value corresponding to the key.
  109236. */
  109237. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109238. /**
  109239. * Get a value from its key if present in the dictionary otherwise add it
  109240. * @param key the key to get the value from
  109241. * @param val if there's no such key/value pair in the dictionary add it with this value
  109242. * @return the value corresponding to the key
  109243. */
  109244. getOrAdd(key: string, val: T): T;
  109245. /**
  109246. * Check if there's a given key in the dictionary
  109247. * @param key the key to check for
  109248. * @return true if the key is present, false otherwise
  109249. */
  109250. contains(key: string): boolean;
  109251. /**
  109252. * Add a new key and its corresponding value
  109253. * @param key the key to add
  109254. * @param value the value corresponding to the key
  109255. * @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
  109256. */
  109257. add(key: string, value: T): boolean;
  109258. /**
  109259. * Update a specific value associated to a key
  109260. * @param key defines the key to use
  109261. * @param value defines the value to store
  109262. * @returns true if the value was updated (or false if the key was not found)
  109263. */
  109264. set(key: string, value: T): boolean;
  109265. /**
  109266. * Get the element of the given key and remove it from the dictionary
  109267. * @param key defines the key to search
  109268. * @returns the value associated with the key or null if not found
  109269. */
  109270. getAndRemove(key: string): Nullable<T>;
  109271. /**
  109272. * Remove a key/value from the dictionary.
  109273. * @param key the key to remove
  109274. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109275. */
  109276. remove(key: string): boolean;
  109277. /**
  109278. * Clear the whole content of the dictionary
  109279. */
  109280. clear(): void;
  109281. /**
  109282. * Gets the current count
  109283. */
  109284. get count(): number;
  109285. /**
  109286. * Execute a callback on each key/val of the dictionary.
  109287. * Note that you can remove any element in this dictionary in the callback implementation
  109288. * @param callback the callback to execute on a given key/value pair
  109289. */
  109290. forEach(callback: (key: string, val: T) => void): void;
  109291. /**
  109292. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109293. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109294. * Note that you can remove any element in this dictionary in the callback implementation
  109295. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109296. * @returns the first item
  109297. */
  109298. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109299. private _count;
  109300. private _data;
  109301. }
  109302. }
  109303. declare module BABYLON {
  109304. /** @hidden */
  109305. export interface ICollisionCoordinator {
  109306. createCollider(): Collider;
  109307. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109308. init(scene: Scene): void;
  109309. }
  109310. /** @hidden */
  109311. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109312. private _scene;
  109313. private _scaledPosition;
  109314. private _scaledVelocity;
  109315. private _finalPosition;
  109316. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109317. createCollider(): Collider;
  109318. init(scene: Scene): void;
  109319. private _collideWithWorld;
  109320. }
  109321. }
  109322. declare module BABYLON {
  109323. /**
  109324. * Class used to manage all inputs for the scene.
  109325. */
  109326. export class InputManager {
  109327. /** The distance in pixel that you have to move to prevent some events */
  109328. static DragMovementThreshold: number;
  109329. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109330. static LongPressDelay: number;
  109331. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109332. static DoubleClickDelay: number;
  109333. /** If you need to check double click without raising a single click at first click, enable this flag */
  109334. static ExclusiveDoubleClickMode: boolean;
  109335. private _wheelEventName;
  109336. private _onPointerMove;
  109337. private _onPointerDown;
  109338. private _onPointerUp;
  109339. private _initClickEvent;
  109340. private _initActionManager;
  109341. private _delayedSimpleClick;
  109342. private _delayedSimpleClickTimeout;
  109343. private _previousDelayedSimpleClickTimeout;
  109344. private _meshPickProceed;
  109345. private _previousButtonPressed;
  109346. private _currentPickResult;
  109347. private _previousPickResult;
  109348. private _totalPointersPressed;
  109349. private _doubleClickOccured;
  109350. private _pointerOverMesh;
  109351. private _pickedDownMesh;
  109352. private _pickedUpMesh;
  109353. private _pointerX;
  109354. private _pointerY;
  109355. private _unTranslatedPointerX;
  109356. private _unTranslatedPointerY;
  109357. private _startingPointerPosition;
  109358. private _previousStartingPointerPosition;
  109359. private _startingPointerTime;
  109360. private _previousStartingPointerTime;
  109361. private _pointerCaptures;
  109362. private _onKeyDown;
  109363. private _onKeyUp;
  109364. private _onCanvasFocusObserver;
  109365. private _onCanvasBlurObserver;
  109366. private _scene;
  109367. /**
  109368. * Creates a new InputManager
  109369. * @param scene defines the hosting scene
  109370. */
  109371. constructor(scene: Scene);
  109372. /**
  109373. * Gets the mesh that is currently under the pointer
  109374. */
  109375. get meshUnderPointer(): Nullable<AbstractMesh>;
  109376. /**
  109377. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109378. */
  109379. get unTranslatedPointer(): Vector2;
  109380. /**
  109381. * Gets or sets the current on-screen X position of the pointer
  109382. */
  109383. get pointerX(): number;
  109384. set pointerX(value: number);
  109385. /**
  109386. * Gets or sets the current on-screen Y position of the pointer
  109387. */
  109388. get pointerY(): number;
  109389. set pointerY(value: number);
  109390. private _updatePointerPosition;
  109391. private _processPointerMove;
  109392. private _setRayOnPointerInfo;
  109393. private _checkPrePointerObservable;
  109394. /**
  109395. * Use this method to simulate a pointer move on a mesh
  109396. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109397. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109398. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109399. */
  109400. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109401. /**
  109402. * Use this method to simulate a pointer down on a mesh
  109403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109406. */
  109407. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109408. private _processPointerDown;
  109409. /** @hidden */
  109410. _isPointerSwiping(): boolean;
  109411. /**
  109412. * Use this method to simulate a pointer up on a mesh
  109413. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109414. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109415. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109416. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109417. */
  109418. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109419. private _processPointerUp;
  109420. /**
  109421. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109422. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109423. * @returns true if the pointer was captured
  109424. */
  109425. isPointerCaptured(pointerId?: number): boolean;
  109426. /**
  109427. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109428. * @param attachUp defines if you want to attach events to pointerup
  109429. * @param attachDown defines if you want to attach events to pointerdown
  109430. * @param attachMove defines if you want to attach events to pointermove
  109431. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109432. */
  109433. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109434. /**
  109435. * Detaches all event handlers
  109436. */
  109437. detachControl(): void;
  109438. /**
  109439. * Force the value of meshUnderPointer
  109440. * @param mesh defines the mesh to use
  109441. */
  109442. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109443. /**
  109444. * Gets the mesh under the pointer
  109445. * @returns a Mesh or null if no mesh is under the pointer
  109446. */
  109447. getPointerOverMesh(): Nullable<AbstractMesh>;
  109448. }
  109449. }
  109450. declare module BABYLON {
  109451. /**
  109452. * Helper class used to generate session unique ID
  109453. */
  109454. export class UniqueIdGenerator {
  109455. private static _UniqueIdCounter;
  109456. /**
  109457. * Gets an unique (relatively to the current scene) Id
  109458. */
  109459. static get UniqueId(): number;
  109460. }
  109461. }
  109462. declare module BABYLON {
  109463. /**
  109464. * This class defines the direct association between an animation and a target
  109465. */
  109466. export class TargetedAnimation {
  109467. /**
  109468. * Animation to perform
  109469. */
  109470. animation: Animation;
  109471. /**
  109472. * Target to animate
  109473. */
  109474. target: any;
  109475. /**
  109476. * Serialize the object
  109477. * @returns the JSON object representing the current entity
  109478. */
  109479. serialize(): any;
  109480. }
  109481. /**
  109482. * Use this class to create coordinated animations on multiple targets
  109483. */
  109484. export class AnimationGroup implements IDisposable {
  109485. /** The name of the animation group */
  109486. name: string;
  109487. private _scene;
  109488. private _targetedAnimations;
  109489. private _animatables;
  109490. private _from;
  109491. private _to;
  109492. private _isStarted;
  109493. private _isPaused;
  109494. private _speedRatio;
  109495. private _loopAnimation;
  109496. private _isAdditive;
  109497. /**
  109498. * Gets or sets the unique id of the node
  109499. */
  109500. uniqueId: number;
  109501. /**
  109502. * This observable will notify when one animation have ended
  109503. */
  109504. onAnimationEndObservable: Observable<TargetedAnimation>;
  109505. /**
  109506. * Observer raised when one animation loops
  109507. */
  109508. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109509. /**
  109510. * Observer raised when all animations have looped
  109511. */
  109512. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109513. /**
  109514. * This observable will notify when all animations have ended.
  109515. */
  109516. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109517. /**
  109518. * This observable will notify when all animations have paused.
  109519. */
  109520. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109521. /**
  109522. * This observable will notify when all animations are playing.
  109523. */
  109524. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109525. /**
  109526. * Gets the first frame
  109527. */
  109528. get from(): number;
  109529. /**
  109530. * Gets the last frame
  109531. */
  109532. get to(): number;
  109533. /**
  109534. * Define if the animations are started
  109535. */
  109536. get isStarted(): boolean;
  109537. /**
  109538. * Gets a value indicating that the current group is playing
  109539. */
  109540. get isPlaying(): boolean;
  109541. /**
  109542. * Gets or sets the speed ratio to use for all animations
  109543. */
  109544. get speedRatio(): number;
  109545. /**
  109546. * Gets or sets the speed ratio to use for all animations
  109547. */
  109548. set speedRatio(value: number);
  109549. /**
  109550. * Gets or sets if all animations should loop or not
  109551. */
  109552. get loopAnimation(): boolean;
  109553. set loopAnimation(value: boolean);
  109554. /**
  109555. * Gets or sets if all animations should be evaluated additively
  109556. */
  109557. get isAdditive(): boolean;
  109558. set isAdditive(value: boolean);
  109559. /**
  109560. * Gets the targeted animations for this animation group
  109561. */
  109562. get targetedAnimations(): Array<TargetedAnimation>;
  109563. /**
  109564. * returning the list of animatables controlled by this animation group.
  109565. */
  109566. get animatables(): Array<Animatable>;
  109567. /**
  109568. * Instantiates a new Animation Group.
  109569. * This helps managing several animations at once.
  109570. * @see http://doc.babylonjs.com/how_to/group
  109571. * @param name Defines the name of the group
  109572. * @param scene Defines the scene the group belongs to
  109573. */
  109574. constructor(
  109575. /** The name of the animation group */
  109576. name: string, scene?: Nullable<Scene>);
  109577. /**
  109578. * Add an animation (with its target) in the group
  109579. * @param animation defines the animation we want to add
  109580. * @param target defines the target of the animation
  109581. * @returns the TargetedAnimation object
  109582. */
  109583. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109584. /**
  109585. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109586. * It can add constant keys at begin or end
  109587. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109588. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109589. * @returns the animation group
  109590. */
  109591. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109592. private _animationLoopCount;
  109593. private _animationLoopFlags;
  109594. private _processLoop;
  109595. /**
  109596. * Start all animations on given targets
  109597. * @param loop defines if animations must loop
  109598. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109599. * @param from defines the from key (optional)
  109600. * @param to defines the to key (optional)
  109601. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109602. * @returns the current animation group
  109603. */
  109604. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109605. /**
  109606. * Pause all animations
  109607. * @returns the animation group
  109608. */
  109609. pause(): AnimationGroup;
  109610. /**
  109611. * Play all animations to initial state
  109612. * This function will start() the animations if they were not started or will restart() them if they were paused
  109613. * @param loop defines if animations must loop
  109614. * @returns the animation group
  109615. */
  109616. play(loop?: boolean): AnimationGroup;
  109617. /**
  109618. * Reset all animations to initial state
  109619. * @returns the animation group
  109620. */
  109621. reset(): AnimationGroup;
  109622. /**
  109623. * Restart animations from key 0
  109624. * @returns the animation group
  109625. */
  109626. restart(): AnimationGroup;
  109627. /**
  109628. * Stop all animations
  109629. * @returns the animation group
  109630. */
  109631. stop(): AnimationGroup;
  109632. /**
  109633. * Set animation weight for all animatables
  109634. * @param weight defines the weight to use
  109635. * @return the animationGroup
  109636. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109637. */
  109638. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109639. /**
  109640. * Synchronize and normalize all animatables with a source animatable
  109641. * @param root defines the root animatable to synchronize with
  109642. * @return the animationGroup
  109643. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109644. */
  109645. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109646. /**
  109647. * Goes to a specific frame in this animation group
  109648. * @param frame the frame number to go to
  109649. * @return the animationGroup
  109650. */
  109651. goToFrame(frame: number): AnimationGroup;
  109652. /**
  109653. * Dispose all associated resources
  109654. */
  109655. dispose(): void;
  109656. private _checkAnimationGroupEnded;
  109657. /**
  109658. * Clone the current animation group and returns a copy
  109659. * @param newName defines the name of the new group
  109660. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109661. * @returns the new aniamtion group
  109662. */
  109663. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109664. /**
  109665. * Serializes the animationGroup to an object
  109666. * @returns Serialized object
  109667. */
  109668. serialize(): any;
  109669. /**
  109670. * Returns a new AnimationGroup object parsed from the source provided.
  109671. * @param parsedAnimationGroup defines the source
  109672. * @param scene defines the scene that will receive the animationGroup
  109673. * @returns a new AnimationGroup
  109674. */
  109675. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109676. /**
  109677. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109678. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109679. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109680. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109681. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109682. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109683. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109684. */
  109685. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109686. /**
  109687. * Returns the string "AnimationGroup"
  109688. * @returns "AnimationGroup"
  109689. */
  109690. getClassName(): string;
  109691. /**
  109692. * Creates a detailled string about the object
  109693. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109694. * @returns a string representing the object
  109695. */
  109696. toString(fullDetails?: boolean): string;
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /**
  109701. * Define an interface for all classes that will hold resources
  109702. */
  109703. export interface IDisposable {
  109704. /**
  109705. * Releases all held resources
  109706. */
  109707. dispose(): void;
  109708. }
  109709. /** Interface defining initialization parameters for Scene class */
  109710. export interface SceneOptions {
  109711. /**
  109712. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109713. * It will improve performance when the number of geometries becomes important.
  109714. */
  109715. useGeometryUniqueIdsMap?: boolean;
  109716. /**
  109717. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109718. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109719. */
  109720. useMaterialMeshMap?: boolean;
  109721. /**
  109722. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109723. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109724. */
  109725. useClonedMeshMap?: boolean;
  109726. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109727. virtual?: boolean;
  109728. }
  109729. /**
  109730. * Represents a scene to be rendered by the engine.
  109731. * @see http://doc.babylonjs.com/features/scene
  109732. */
  109733. export class Scene extends AbstractScene implements IAnimatable {
  109734. /** The fog is deactivated */
  109735. static readonly FOGMODE_NONE: number;
  109736. /** The fog density is following an exponential function */
  109737. static readonly FOGMODE_EXP: number;
  109738. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109739. static readonly FOGMODE_EXP2: number;
  109740. /** The fog density is following a linear function. */
  109741. static readonly FOGMODE_LINEAR: number;
  109742. /**
  109743. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109745. */
  109746. static MinDeltaTime: number;
  109747. /**
  109748. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109750. */
  109751. static MaxDeltaTime: number;
  109752. /**
  109753. * Factory used to create the default material.
  109754. * @param name The name of the material to create
  109755. * @param scene The scene to create the material for
  109756. * @returns The default material
  109757. */
  109758. static DefaultMaterialFactory(scene: Scene): Material;
  109759. /**
  109760. * Factory used to create the a collision coordinator.
  109761. * @returns The collision coordinator
  109762. */
  109763. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109764. /** @hidden */
  109765. _inputManager: InputManager;
  109766. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109767. cameraToUseForPointers: Nullable<Camera>;
  109768. /** @hidden */
  109769. readonly _isScene: boolean;
  109770. /** @hidden */
  109771. _blockEntityCollection: boolean;
  109772. /**
  109773. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109774. */
  109775. autoClear: boolean;
  109776. /**
  109777. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109778. */
  109779. autoClearDepthAndStencil: boolean;
  109780. /**
  109781. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109782. */
  109783. clearColor: Color4;
  109784. /**
  109785. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109786. */
  109787. ambientColor: Color3;
  109788. /**
  109789. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109790. * It should only be one of the following (if not the default embedded one):
  109791. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109792. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109793. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109794. * The material properties need to be setup according to the type of texture in use.
  109795. */
  109796. environmentBRDFTexture: BaseTexture;
  109797. /** @hidden */
  109798. protected _environmentTexture: Nullable<BaseTexture>;
  109799. /**
  109800. * Texture used in all pbr material as the reflection texture.
  109801. * As in the majority of the scene they are the same (exception for multi room and so on),
  109802. * this is easier to reference from here than from all the materials.
  109803. */
  109804. get environmentTexture(): Nullable<BaseTexture>;
  109805. /**
  109806. * Texture used in all pbr material as the reflection texture.
  109807. * As in the majority of the scene they are the same (exception for multi room and so on),
  109808. * this is easier to set here than in all the materials.
  109809. */
  109810. set environmentTexture(value: Nullable<BaseTexture>);
  109811. /** @hidden */
  109812. protected _environmentIntensity: number;
  109813. /**
  109814. * Intensity of the environment in all pbr material.
  109815. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109816. * As in the majority of the scene they are the same (exception for multi room and so on),
  109817. * this is easier to reference from here than from all the materials.
  109818. */
  109819. get environmentIntensity(): number;
  109820. /**
  109821. * Intensity of the environment in all pbr material.
  109822. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109823. * As in the majority of the scene they are the same (exception for multi room and so on),
  109824. * this is easier to set here than in all the materials.
  109825. */
  109826. set environmentIntensity(value: number);
  109827. /** @hidden */
  109828. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109829. /**
  109830. * Default image processing configuration used either in the rendering
  109831. * Forward main pass or through the imageProcessingPostProcess if present.
  109832. * As in the majority of the scene they are the same (exception for multi camera),
  109833. * this is easier to reference from here than from all the materials and post process.
  109834. *
  109835. * No setter as we it is a shared configuration, you can set the values instead.
  109836. */
  109837. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109838. private _forceWireframe;
  109839. /**
  109840. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109841. */
  109842. set forceWireframe(value: boolean);
  109843. get forceWireframe(): boolean;
  109844. private _skipFrustumClipping;
  109845. /**
  109846. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109847. */
  109848. set skipFrustumClipping(value: boolean);
  109849. get skipFrustumClipping(): boolean;
  109850. private _forcePointsCloud;
  109851. /**
  109852. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109853. */
  109854. set forcePointsCloud(value: boolean);
  109855. get forcePointsCloud(): boolean;
  109856. /**
  109857. * Gets or sets the active clipplane 1
  109858. */
  109859. clipPlane: Nullable<Plane>;
  109860. /**
  109861. * Gets or sets the active clipplane 2
  109862. */
  109863. clipPlane2: Nullable<Plane>;
  109864. /**
  109865. * Gets or sets the active clipplane 3
  109866. */
  109867. clipPlane3: Nullable<Plane>;
  109868. /**
  109869. * Gets or sets the active clipplane 4
  109870. */
  109871. clipPlane4: Nullable<Plane>;
  109872. /**
  109873. * Gets or sets the active clipplane 5
  109874. */
  109875. clipPlane5: Nullable<Plane>;
  109876. /**
  109877. * Gets or sets the active clipplane 6
  109878. */
  109879. clipPlane6: Nullable<Plane>;
  109880. /**
  109881. * Gets or sets a boolean indicating if animations are enabled
  109882. */
  109883. animationsEnabled: boolean;
  109884. private _animationPropertiesOverride;
  109885. /**
  109886. * Gets or sets the animation properties override
  109887. */
  109888. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109889. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109890. /**
  109891. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109892. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109893. */
  109894. useConstantAnimationDeltaTime: boolean;
  109895. /**
  109896. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109897. * Please note that it requires to run a ray cast through the scene on every frame
  109898. */
  109899. constantlyUpdateMeshUnderPointer: boolean;
  109900. /**
  109901. * Defines the HTML cursor to use when hovering over interactive elements
  109902. */
  109903. hoverCursor: string;
  109904. /**
  109905. * Defines the HTML default cursor to use (empty by default)
  109906. */
  109907. defaultCursor: string;
  109908. /**
  109909. * Defines whether cursors are handled by the scene.
  109910. */
  109911. doNotHandleCursors: boolean;
  109912. /**
  109913. * This is used to call preventDefault() on pointer down
  109914. * in order to block unwanted artifacts like system double clicks
  109915. */
  109916. preventDefaultOnPointerDown: boolean;
  109917. /**
  109918. * This is used to call preventDefault() on pointer up
  109919. * in order to block unwanted artifacts like system double clicks
  109920. */
  109921. preventDefaultOnPointerUp: boolean;
  109922. /**
  109923. * Gets or sets user defined metadata
  109924. */
  109925. metadata: any;
  109926. /**
  109927. * For internal use only. Please do not use.
  109928. */
  109929. reservedDataStore: any;
  109930. /**
  109931. * Gets the name of the plugin used to load this scene (null by default)
  109932. */
  109933. loadingPluginName: string;
  109934. /**
  109935. * Use this array to add regular expressions used to disable offline support for specific urls
  109936. */
  109937. disableOfflineSupportExceptionRules: RegExp[];
  109938. /**
  109939. * An event triggered when the scene is disposed.
  109940. */
  109941. onDisposeObservable: Observable<Scene>;
  109942. private _onDisposeObserver;
  109943. /** Sets a function to be executed when this scene is disposed. */
  109944. set onDispose(callback: () => void);
  109945. /**
  109946. * An event triggered before rendering the scene (right after animations and physics)
  109947. */
  109948. onBeforeRenderObservable: Observable<Scene>;
  109949. private _onBeforeRenderObserver;
  109950. /** Sets a function to be executed before rendering this scene */
  109951. set beforeRender(callback: Nullable<() => void>);
  109952. /**
  109953. * An event triggered after rendering the scene
  109954. */
  109955. onAfterRenderObservable: Observable<Scene>;
  109956. /**
  109957. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109958. */
  109959. onAfterRenderCameraObservable: Observable<Camera>;
  109960. private _onAfterRenderObserver;
  109961. /** Sets a function to be executed after rendering this scene */
  109962. set afterRender(callback: Nullable<() => void>);
  109963. /**
  109964. * An event triggered before animating the scene
  109965. */
  109966. onBeforeAnimationsObservable: Observable<Scene>;
  109967. /**
  109968. * An event triggered after animations processing
  109969. */
  109970. onAfterAnimationsObservable: Observable<Scene>;
  109971. /**
  109972. * An event triggered before draw calls are ready to be sent
  109973. */
  109974. onBeforeDrawPhaseObservable: Observable<Scene>;
  109975. /**
  109976. * An event triggered after draw calls have been sent
  109977. */
  109978. onAfterDrawPhaseObservable: Observable<Scene>;
  109979. /**
  109980. * An event triggered when the scene is ready
  109981. */
  109982. onReadyObservable: Observable<Scene>;
  109983. /**
  109984. * An event triggered before rendering a camera
  109985. */
  109986. onBeforeCameraRenderObservable: Observable<Camera>;
  109987. private _onBeforeCameraRenderObserver;
  109988. /** Sets a function to be executed before rendering a camera*/
  109989. set beforeCameraRender(callback: () => void);
  109990. /**
  109991. * An event triggered after rendering a camera
  109992. */
  109993. onAfterCameraRenderObservable: Observable<Camera>;
  109994. private _onAfterCameraRenderObserver;
  109995. /** Sets a function to be executed after rendering a camera*/
  109996. set afterCameraRender(callback: () => void);
  109997. /**
  109998. * An event triggered when active meshes evaluation is about to start
  109999. */
  110000. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  110001. /**
  110002. * An event triggered when active meshes evaluation is done
  110003. */
  110004. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  110005. /**
  110006. * An event triggered when particles rendering is about to start
  110007. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110008. */
  110009. onBeforeParticlesRenderingObservable: Observable<Scene>;
  110010. /**
  110011. * An event triggered when particles rendering is done
  110012. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110013. */
  110014. onAfterParticlesRenderingObservable: Observable<Scene>;
  110015. /**
  110016. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  110017. */
  110018. onDataLoadedObservable: Observable<Scene>;
  110019. /**
  110020. * An event triggered when a camera is created
  110021. */
  110022. onNewCameraAddedObservable: Observable<Camera>;
  110023. /**
  110024. * An event triggered when a camera is removed
  110025. */
  110026. onCameraRemovedObservable: Observable<Camera>;
  110027. /**
  110028. * An event triggered when a light is created
  110029. */
  110030. onNewLightAddedObservable: Observable<Light>;
  110031. /**
  110032. * An event triggered when a light is removed
  110033. */
  110034. onLightRemovedObservable: Observable<Light>;
  110035. /**
  110036. * An event triggered when a geometry is created
  110037. */
  110038. onNewGeometryAddedObservable: Observable<Geometry>;
  110039. /**
  110040. * An event triggered when a geometry is removed
  110041. */
  110042. onGeometryRemovedObservable: Observable<Geometry>;
  110043. /**
  110044. * An event triggered when a transform node is created
  110045. */
  110046. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110047. /**
  110048. * An event triggered when a transform node is removed
  110049. */
  110050. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110051. /**
  110052. * An event triggered when a mesh is created
  110053. */
  110054. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110055. /**
  110056. * An event triggered when a mesh is removed
  110057. */
  110058. onMeshRemovedObservable: Observable<AbstractMesh>;
  110059. /**
  110060. * An event triggered when a skeleton is created
  110061. */
  110062. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110063. /**
  110064. * An event triggered when a skeleton is removed
  110065. */
  110066. onSkeletonRemovedObservable: Observable<Skeleton>;
  110067. /**
  110068. * An event triggered when a material is created
  110069. */
  110070. onNewMaterialAddedObservable: Observable<Material>;
  110071. /**
  110072. * An event triggered when a material is removed
  110073. */
  110074. onMaterialRemovedObservable: Observable<Material>;
  110075. /**
  110076. * An event triggered when a texture is created
  110077. */
  110078. onNewTextureAddedObservable: Observable<BaseTexture>;
  110079. /**
  110080. * An event triggered when a texture is removed
  110081. */
  110082. onTextureRemovedObservable: Observable<BaseTexture>;
  110083. /**
  110084. * An event triggered when render targets are about to be rendered
  110085. * Can happen multiple times per frame.
  110086. */
  110087. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110088. /**
  110089. * An event triggered when render targets were rendered.
  110090. * Can happen multiple times per frame.
  110091. */
  110092. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110093. /**
  110094. * An event triggered before calculating deterministic simulation step
  110095. */
  110096. onBeforeStepObservable: Observable<Scene>;
  110097. /**
  110098. * An event triggered after calculating deterministic simulation step
  110099. */
  110100. onAfterStepObservable: Observable<Scene>;
  110101. /**
  110102. * An event triggered when the activeCamera property is updated
  110103. */
  110104. onActiveCameraChanged: Observable<Scene>;
  110105. /**
  110106. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110108. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  110109. */
  110110. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110111. /**
  110112. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110113. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110114. * 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)
  110115. */
  110116. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110117. /**
  110118. * This Observable will when a mesh has been imported into the scene.
  110119. */
  110120. onMeshImportedObservable: Observable<AbstractMesh>;
  110121. /**
  110122. * This Observable will when an animation file has been imported into the scene.
  110123. */
  110124. onAnimationFileImportedObservable: Observable<Scene>;
  110125. /**
  110126. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110127. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110128. */
  110129. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110130. /** @hidden */
  110131. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110132. /**
  110133. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110134. */
  110135. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110136. /**
  110137. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110138. */
  110139. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110140. /**
  110141. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110142. */
  110143. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110144. /** Callback called when a pointer move is detected */
  110145. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110146. /** Callback called when a pointer down is detected */
  110147. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110148. /** Callback called when a pointer up is detected */
  110149. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110150. /** Callback called when a pointer pick is detected */
  110151. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110152. /**
  110153. * 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).
  110154. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110155. */
  110156. onPrePointerObservable: Observable<PointerInfoPre>;
  110157. /**
  110158. * Observable event triggered each time an input event is received from the rendering canvas
  110159. */
  110160. onPointerObservable: Observable<PointerInfo>;
  110161. /**
  110162. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110163. */
  110164. get unTranslatedPointer(): Vector2;
  110165. /**
  110166. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110167. */
  110168. static get DragMovementThreshold(): number;
  110169. static set DragMovementThreshold(value: number);
  110170. /**
  110171. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110172. */
  110173. static get LongPressDelay(): number;
  110174. static set LongPressDelay(value: number);
  110175. /**
  110176. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110177. */
  110178. static get DoubleClickDelay(): number;
  110179. static set DoubleClickDelay(value: number);
  110180. /** If you need to check double click without raising a single click at first click, enable this flag */
  110181. static get ExclusiveDoubleClickMode(): boolean;
  110182. static set ExclusiveDoubleClickMode(value: boolean);
  110183. /** @hidden */
  110184. _mirroredCameraPosition: Nullable<Vector3>;
  110185. /**
  110186. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110187. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110188. */
  110189. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110190. /**
  110191. * Observable event triggered each time an keyboard event is received from the hosting window
  110192. */
  110193. onKeyboardObservable: Observable<KeyboardInfo>;
  110194. private _useRightHandedSystem;
  110195. /**
  110196. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110197. */
  110198. set useRightHandedSystem(value: boolean);
  110199. get useRightHandedSystem(): boolean;
  110200. private _timeAccumulator;
  110201. private _currentStepId;
  110202. private _currentInternalStep;
  110203. /**
  110204. * Sets the step Id used by deterministic lock step
  110205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110206. * @param newStepId defines the step Id
  110207. */
  110208. setStepId(newStepId: number): void;
  110209. /**
  110210. * Gets the step Id used by deterministic lock step
  110211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110212. * @returns the step Id
  110213. */
  110214. getStepId(): number;
  110215. /**
  110216. * Gets the internal step used by deterministic lock step
  110217. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110218. * @returns the internal step
  110219. */
  110220. getInternalStep(): number;
  110221. private _fogEnabled;
  110222. /**
  110223. * Gets or sets a boolean indicating if fog is enabled on this scene
  110224. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110225. * (Default is true)
  110226. */
  110227. set fogEnabled(value: boolean);
  110228. get fogEnabled(): boolean;
  110229. private _fogMode;
  110230. /**
  110231. * Gets or sets the fog mode to use
  110232. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110233. * | mode | value |
  110234. * | --- | --- |
  110235. * | FOGMODE_NONE | 0 |
  110236. * | FOGMODE_EXP | 1 |
  110237. * | FOGMODE_EXP2 | 2 |
  110238. * | FOGMODE_LINEAR | 3 |
  110239. */
  110240. set fogMode(value: number);
  110241. get fogMode(): number;
  110242. /**
  110243. * Gets or sets the fog color to use
  110244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110245. * (Default is Color3(0.2, 0.2, 0.3))
  110246. */
  110247. fogColor: Color3;
  110248. /**
  110249. * Gets or sets the fog density to use
  110250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110251. * (Default is 0.1)
  110252. */
  110253. fogDensity: number;
  110254. /**
  110255. * Gets or sets the fog start distance to use
  110256. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110257. * (Default is 0)
  110258. */
  110259. fogStart: number;
  110260. /**
  110261. * Gets or sets the fog end distance to use
  110262. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110263. * (Default is 1000)
  110264. */
  110265. fogEnd: number;
  110266. private _shadowsEnabled;
  110267. /**
  110268. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110269. */
  110270. set shadowsEnabled(value: boolean);
  110271. get shadowsEnabled(): boolean;
  110272. private _lightsEnabled;
  110273. /**
  110274. * Gets or sets a boolean indicating if lights are enabled on this scene
  110275. */
  110276. set lightsEnabled(value: boolean);
  110277. get lightsEnabled(): boolean;
  110278. /** All of the active cameras added to this scene. */
  110279. activeCameras: Camera[];
  110280. /** @hidden */
  110281. _activeCamera: Nullable<Camera>;
  110282. /** Gets or sets the current active camera */
  110283. get activeCamera(): Nullable<Camera>;
  110284. set activeCamera(value: Nullable<Camera>);
  110285. private _defaultMaterial;
  110286. /** The default material used on meshes when no material is affected */
  110287. get defaultMaterial(): Material;
  110288. /** The default material used on meshes when no material is affected */
  110289. set defaultMaterial(value: Material);
  110290. private _texturesEnabled;
  110291. /**
  110292. * Gets or sets a boolean indicating if textures are enabled on this scene
  110293. */
  110294. set texturesEnabled(value: boolean);
  110295. get texturesEnabled(): boolean;
  110296. /**
  110297. * Gets or sets a boolean indicating if particles are enabled on this scene
  110298. */
  110299. particlesEnabled: boolean;
  110300. /**
  110301. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110302. */
  110303. spritesEnabled: boolean;
  110304. private _skeletonsEnabled;
  110305. /**
  110306. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110307. */
  110308. set skeletonsEnabled(value: boolean);
  110309. get skeletonsEnabled(): boolean;
  110310. /**
  110311. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110312. */
  110313. lensFlaresEnabled: boolean;
  110314. /**
  110315. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110317. */
  110318. collisionsEnabled: boolean;
  110319. private _collisionCoordinator;
  110320. /** @hidden */
  110321. get collisionCoordinator(): ICollisionCoordinator;
  110322. /**
  110323. * Defines the gravity applied to this scene (used only for collisions)
  110324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110325. */
  110326. gravity: Vector3;
  110327. /**
  110328. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110329. */
  110330. postProcessesEnabled: boolean;
  110331. /**
  110332. * The list of postprocesses added to the scene
  110333. */
  110334. postProcesses: PostProcess[];
  110335. /**
  110336. * Gets the current postprocess manager
  110337. */
  110338. postProcessManager: PostProcessManager;
  110339. /**
  110340. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110341. */
  110342. renderTargetsEnabled: boolean;
  110343. /**
  110344. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110345. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110346. */
  110347. dumpNextRenderTargets: boolean;
  110348. /**
  110349. * The list of user defined render targets added to the scene
  110350. */
  110351. customRenderTargets: RenderTargetTexture[];
  110352. /**
  110353. * Defines if texture loading must be delayed
  110354. * If true, textures will only be loaded when they need to be rendered
  110355. */
  110356. useDelayedTextureLoading: boolean;
  110357. /**
  110358. * Gets the list of meshes imported to the scene through SceneLoader
  110359. */
  110360. importedMeshesFiles: String[];
  110361. /**
  110362. * Gets or sets a boolean indicating if probes are enabled on this scene
  110363. */
  110364. probesEnabled: boolean;
  110365. /**
  110366. * Gets or sets the current offline provider to use to store scene data
  110367. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110368. */
  110369. offlineProvider: IOfflineProvider;
  110370. /**
  110371. * Gets or sets the action manager associated with the scene
  110372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110373. */
  110374. actionManager: AbstractActionManager;
  110375. private _meshesForIntersections;
  110376. /**
  110377. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110378. */
  110379. proceduralTexturesEnabled: boolean;
  110380. private _engine;
  110381. private _totalVertices;
  110382. /** @hidden */
  110383. _activeIndices: PerfCounter;
  110384. /** @hidden */
  110385. _activeParticles: PerfCounter;
  110386. /** @hidden */
  110387. _activeBones: PerfCounter;
  110388. private _animationRatio;
  110389. /** @hidden */
  110390. _animationTimeLast: number;
  110391. /** @hidden */
  110392. _animationTime: number;
  110393. /**
  110394. * Gets or sets a general scale for animation speed
  110395. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110396. */
  110397. animationTimeScale: number;
  110398. /** @hidden */
  110399. _cachedMaterial: Nullable<Material>;
  110400. /** @hidden */
  110401. _cachedEffect: Nullable<Effect>;
  110402. /** @hidden */
  110403. _cachedVisibility: Nullable<number>;
  110404. private _renderId;
  110405. private _frameId;
  110406. private _executeWhenReadyTimeoutId;
  110407. private _intermediateRendering;
  110408. private _viewUpdateFlag;
  110409. private _projectionUpdateFlag;
  110410. /** @hidden */
  110411. _toBeDisposed: Nullable<IDisposable>[];
  110412. private _activeRequests;
  110413. /** @hidden */
  110414. _pendingData: any[];
  110415. private _isDisposed;
  110416. /**
  110417. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110418. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110419. */
  110420. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110421. private _activeMeshes;
  110422. private _processedMaterials;
  110423. private _renderTargets;
  110424. /** @hidden */
  110425. _activeParticleSystems: SmartArray<IParticleSystem>;
  110426. private _activeSkeletons;
  110427. private _softwareSkinnedMeshes;
  110428. private _renderingManager;
  110429. /** @hidden */
  110430. _activeAnimatables: Animatable[];
  110431. private _transformMatrix;
  110432. private _sceneUbo;
  110433. /** @hidden */
  110434. _viewMatrix: Matrix;
  110435. private _projectionMatrix;
  110436. /** @hidden */
  110437. _forcedViewPosition: Nullable<Vector3>;
  110438. /** @hidden */
  110439. _frustumPlanes: Plane[];
  110440. /**
  110441. * Gets the list of frustum planes (built from the active camera)
  110442. */
  110443. get frustumPlanes(): Plane[];
  110444. /**
  110445. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110446. * This is useful if there are more lights that the maximum simulteanous authorized
  110447. */
  110448. requireLightSorting: boolean;
  110449. /** @hidden */
  110450. readonly useMaterialMeshMap: boolean;
  110451. /** @hidden */
  110452. readonly useClonedMeshMap: boolean;
  110453. private _externalData;
  110454. private _uid;
  110455. /**
  110456. * @hidden
  110457. * Backing store of defined scene components.
  110458. */
  110459. _components: ISceneComponent[];
  110460. /**
  110461. * @hidden
  110462. * Backing store of defined scene components.
  110463. */
  110464. _serializableComponents: ISceneSerializableComponent[];
  110465. /**
  110466. * List of components to register on the next registration step.
  110467. */
  110468. private _transientComponents;
  110469. /**
  110470. * Registers the transient components if needed.
  110471. */
  110472. private _registerTransientComponents;
  110473. /**
  110474. * @hidden
  110475. * Add a component to the scene.
  110476. * Note that the ccomponent could be registered on th next frame if this is called after
  110477. * the register component stage.
  110478. * @param component Defines the component to add to the scene
  110479. */
  110480. _addComponent(component: ISceneComponent): void;
  110481. /**
  110482. * @hidden
  110483. * Gets a component from the scene.
  110484. * @param name defines the name of the component to retrieve
  110485. * @returns the component or null if not present
  110486. */
  110487. _getComponent(name: string): Nullable<ISceneComponent>;
  110488. /**
  110489. * @hidden
  110490. * Defines the actions happening before camera updates.
  110491. */
  110492. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110493. /**
  110494. * @hidden
  110495. * Defines the actions happening before clear the canvas.
  110496. */
  110497. _beforeClearStage: Stage<SimpleStageAction>;
  110498. /**
  110499. * @hidden
  110500. * Defines the actions when collecting render targets for the frame.
  110501. */
  110502. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110503. /**
  110504. * @hidden
  110505. * Defines the actions happening for one camera in the frame.
  110506. */
  110507. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110508. /**
  110509. * @hidden
  110510. * Defines the actions happening during the per mesh ready checks.
  110511. */
  110512. _isReadyForMeshStage: Stage<MeshStageAction>;
  110513. /**
  110514. * @hidden
  110515. * Defines the actions happening before evaluate active mesh checks.
  110516. */
  110517. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110518. /**
  110519. * @hidden
  110520. * Defines the actions happening during the evaluate sub mesh checks.
  110521. */
  110522. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110523. /**
  110524. * @hidden
  110525. * Defines the actions happening during the active mesh stage.
  110526. */
  110527. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110528. /**
  110529. * @hidden
  110530. * Defines the actions happening during the per camera render target step.
  110531. */
  110532. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110533. /**
  110534. * @hidden
  110535. * Defines the actions happening just before the active camera is drawing.
  110536. */
  110537. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110538. /**
  110539. * @hidden
  110540. * Defines the actions happening just before a render target is drawing.
  110541. */
  110542. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110543. /**
  110544. * @hidden
  110545. * Defines the actions happening just before a rendering group is drawing.
  110546. */
  110547. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110548. /**
  110549. * @hidden
  110550. * Defines the actions happening just before a mesh is drawing.
  110551. */
  110552. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110553. /**
  110554. * @hidden
  110555. * Defines the actions happening just after a mesh has been drawn.
  110556. */
  110557. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110558. /**
  110559. * @hidden
  110560. * Defines the actions happening just after a rendering group has been drawn.
  110561. */
  110562. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110563. /**
  110564. * @hidden
  110565. * Defines the actions happening just after the active camera has been drawn.
  110566. */
  110567. _afterCameraDrawStage: Stage<CameraStageAction>;
  110568. /**
  110569. * @hidden
  110570. * Defines the actions happening just after a render target has been drawn.
  110571. */
  110572. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110573. /**
  110574. * @hidden
  110575. * Defines the actions happening just after rendering all cameras and computing intersections.
  110576. */
  110577. _afterRenderStage: Stage<SimpleStageAction>;
  110578. /**
  110579. * @hidden
  110580. * Defines the actions happening when a pointer move event happens.
  110581. */
  110582. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110583. /**
  110584. * @hidden
  110585. * Defines the actions happening when a pointer down event happens.
  110586. */
  110587. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110588. /**
  110589. * @hidden
  110590. * Defines the actions happening when a pointer up event happens.
  110591. */
  110592. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110593. /**
  110594. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110595. */
  110596. private geometriesByUniqueId;
  110597. /**
  110598. * Creates a new Scene
  110599. * @param engine defines the engine to use to render this scene
  110600. * @param options defines the scene options
  110601. */
  110602. constructor(engine: Engine, options?: SceneOptions);
  110603. /**
  110604. * Gets a string idenfifying the name of the class
  110605. * @returns "Scene" string
  110606. */
  110607. getClassName(): string;
  110608. private _defaultMeshCandidates;
  110609. /**
  110610. * @hidden
  110611. */
  110612. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110613. private _defaultSubMeshCandidates;
  110614. /**
  110615. * @hidden
  110616. */
  110617. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110618. /**
  110619. * Sets the default candidate providers for the scene.
  110620. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110621. * and getCollidingSubMeshCandidates to their default function
  110622. */
  110623. setDefaultCandidateProviders(): void;
  110624. /**
  110625. * Gets the mesh that is currently under the pointer
  110626. */
  110627. get meshUnderPointer(): Nullable<AbstractMesh>;
  110628. /**
  110629. * Gets or sets the current on-screen X position of the pointer
  110630. */
  110631. get pointerX(): number;
  110632. set pointerX(value: number);
  110633. /**
  110634. * Gets or sets the current on-screen Y position of the pointer
  110635. */
  110636. get pointerY(): number;
  110637. set pointerY(value: number);
  110638. /**
  110639. * Gets the cached material (ie. the latest rendered one)
  110640. * @returns the cached material
  110641. */
  110642. getCachedMaterial(): Nullable<Material>;
  110643. /**
  110644. * Gets the cached effect (ie. the latest rendered one)
  110645. * @returns the cached effect
  110646. */
  110647. getCachedEffect(): Nullable<Effect>;
  110648. /**
  110649. * Gets the cached visibility state (ie. the latest rendered one)
  110650. * @returns the cached visibility state
  110651. */
  110652. getCachedVisibility(): Nullable<number>;
  110653. /**
  110654. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110655. * @param material defines the current material
  110656. * @param effect defines the current effect
  110657. * @param visibility defines the current visibility state
  110658. * @returns true if one parameter is not cached
  110659. */
  110660. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110661. /**
  110662. * Gets the engine associated with the scene
  110663. * @returns an Engine
  110664. */
  110665. getEngine(): Engine;
  110666. /**
  110667. * Gets the total number of vertices rendered per frame
  110668. * @returns the total number of vertices rendered per frame
  110669. */
  110670. getTotalVertices(): number;
  110671. /**
  110672. * Gets the performance counter for total vertices
  110673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110674. */
  110675. get totalVerticesPerfCounter(): PerfCounter;
  110676. /**
  110677. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110678. * @returns the total number of active indices rendered per frame
  110679. */
  110680. getActiveIndices(): number;
  110681. /**
  110682. * Gets the performance counter for active indices
  110683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110684. */
  110685. get totalActiveIndicesPerfCounter(): PerfCounter;
  110686. /**
  110687. * Gets the total number of active particles rendered per frame
  110688. * @returns the total number of active particles rendered per frame
  110689. */
  110690. getActiveParticles(): number;
  110691. /**
  110692. * Gets the performance counter for active particles
  110693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110694. */
  110695. get activeParticlesPerfCounter(): PerfCounter;
  110696. /**
  110697. * Gets the total number of active bones rendered per frame
  110698. * @returns the total number of active bones rendered per frame
  110699. */
  110700. getActiveBones(): number;
  110701. /**
  110702. * Gets the performance counter for active bones
  110703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110704. */
  110705. get activeBonesPerfCounter(): PerfCounter;
  110706. /**
  110707. * Gets the array of active meshes
  110708. * @returns an array of AbstractMesh
  110709. */
  110710. getActiveMeshes(): SmartArray<AbstractMesh>;
  110711. /**
  110712. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110713. * @returns a number
  110714. */
  110715. getAnimationRatio(): number;
  110716. /**
  110717. * Gets an unique Id for the current render phase
  110718. * @returns a number
  110719. */
  110720. getRenderId(): number;
  110721. /**
  110722. * Gets an unique Id for the current frame
  110723. * @returns a number
  110724. */
  110725. getFrameId(): number;
  110726. /** Call this function if you want to manually increment the render Id*/
  110727. incrementRenderId(): void;
  110728. private _createUbo;
  110729. /**
  110730. * Use this method to simulate a pointer move on a mesh
  110731. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110732. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110733. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110734. * @returns the current scene
  110735. */
  110736. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110737. /**
  110738. * Use this method to simulate a pointer down on a mesh
  110739. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110740. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110741. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110742. * @returns the current scene
  110743. */
  110744. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110745. /**
  110746. * Use this method to simulate a pointer up on a mesh
  110747. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110748. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110749. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110750. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110751. * @returns the current scene
  110752. */
  110753. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110754. /**
  110755. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110756. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110757. * @returns true if the pointer was captured
  110758. */
  110759. isPointerCaptured(pointerId?: number): boolean;
  110760. /**
  110761. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110762. * @param attachUp defines if you want to attach events to pointerup
  110763. * @param attachDown defines if you want to attach events to pointerdown
  110764. * @param attachMove defines if you want to attach events to pointermove
  110765. */
  110766. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110767. /** Detaches all event handlers*/
  110768. detachControl(): void;
  110769. /**
  110770. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110771. * Delay loaded resources are not taking in account
  110772. * @return true if all required resources are ready
  110773. */
  110774. isReady(): boolean;
  110775. /** Resets all cached information relative to material (including effect and visibility) */
  110776. resetCachedMaterial(): void;
  110777. /**
  110778. * Registers a function to be called before every frame render
  110779. * @param func defines the function to register
  110780. */
  110781. registerBeforeRender(func: () => void): void;
  110782. /**
  110783. * Unregisters a function called before every frame render
  110784. * @param func defines the function to unregister
  110785. */
  110786. unregisterBeforeRender(func: () => void): void;
  110787. /**
  110788. * Registers a function to be called after every frame render
  110789. * @param func defines the function to register
  110790. */
  110791. registerAfterRender(func: () => void): void;
  110792. /**
  110793. * Unregisters a function called after every frame render
  110794. * @param func defines the function to unregister
  110795. */
  110796. unregisterAfterRender(func: () => void): void;
  110797. private _executeOnceBeforeRender;
  110798. /**
  110799. * The provided function will run before render once and will be disposed afterwards.
  110800. * A timeout delay can be provided so that the function will be executed in N ms.
  110801. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110802. * @param func The function to be executed.
  110803. * @param timeout optional delay in ms
  110804. */
  110805. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110806. /** @hidden */
  110807. _addPendingData(data: any): void;
  110808. /** @hidden */
  110809. _removePendingData(data: any): void;
  110810. /**
  110811. * Returns the number of items waiting to be loaded
  110812. * @returns the number of items waiting to be loaded
  110813. */
  110814. getWaitingItemsCount(): number;
  110815. /**
  110816. * Returns a boolean indicating if the scene is still loading data
  110817. */
  110818. get isLoading(): boolean;
  110819. /**
  110820. * Registers a function to be executed when the scene is ready
  110821. * @param {Function} func - the function to be executed
  110822. */
  110823. executeWhenReady(func: () => void): void;
  110824. /**
  110825. * Returns a promise that resolves when the scene is ready
  110826. * @returns A promise that resolves when the scene is ready
  110827. */
  110828. whenReadyAsync(): Promise<void>;
  110829. /** @hidden */
  110830. _checkIsReady(): void;
  110831. /**
  110832. * Gets all animatable attached to the scene
  110833. */
  110834. get animatables(): Animatable[];
  110835. /**
  110836. * Resets the last animation time frame.
  110837. * Useful to override when animations start running when loading a scene for the first time.
  110838. */
  110839. resetLastAnimationTimeFrame(): void;
  110840. /**
  110841. * Gets the current view matrix
  110842. * @returns a Matrix
  110843. */
  110844. getViewMatrix(): Matrix;
  110845. /**
  110846. * Gets the current projection matrix
  110847. * @returns a Matrix
  110848. */
  110849. getProjectionMatrix(): Matrix;
  110850. /**
  110851. * Gets the current transform matrix
  110852. * @returns a Matrix made of View * Projection
  110853. */
  110854. getTransformMatrix(): Matrix;
  110855. /**
  110856. * Sets the current transform matrix
  110857. * @param viewL defines the View matrix to use
  110858. * @param projectionL defines the Projection matrix to use
  110859. * @param viewR defines the right View matrix to use (if provided)
  110860. * @param projectionR defines the right Projection matrix to use (if provided)
  110861. */
  110862. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110863. /**
  110864. * Gets the uniform buffer used to store scene data
  110865. * @returns a UniformBuffer
  110866. */
  110867. getSceneUniformBuffer(): UniformBuffer;
  110868. /**
  110869. * Gets an unique (relatively to the current scene) Id
  110870. * @returns an unique number for the scene
  110871. */
  110872. getUniqueId(): number;
  110873. /**
  110874. * Add a mesh to the list of scene's meshes
  110875. * @param newMesh defines the mesh to add
  110876. * @param recursive if all child meshes should also be added to the scene
  110877. */
  110878. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110879. /**
  110880. * Remove a mesh for the list of scene's meshes
  110881. * @param toRemove defines the mesh to remove
  110882. * @param recursive if all child meshes should also be removed from the scene
  110883. * @returns the index where the mesh was in the mesh list
  110884. */
  110885. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110886. /**
  110887. * Add a transform node to the list of scene's transform nodes
  110888. * @param newTransformNode defines the transform node to add
  110889. */
  110890. addTransformNode(newTransformNode: TransformNode): void;
  110891. /**
  110892. * Remove a transform node for the list of scene's transform nodes
  110893. * @param toRemove defines the transform node to remove
  110894. * @returns the index where the transform node was in the transform node list
  110895. */
  110896. removeTransformNode(toRemove: TransformNode): number;
  110897. /**
  110898. * Remove a skeleton for the list of scene's skeletons
  110899. * @param toRemove defines the skeleton to remove
  110900. * @returns the index where the skeleton was in the skeleton list
  110901. */
  110902. removeSkeleton(toRemove: Skeleton): number;
  110903. /**
  110904. * Remove a morph target for the list of scene's morph targets
  110905. * @param toRemove defines the morph target to remove
  110906. * @returns the index where the morph target was in the morph target list
  110907. */
  110908. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110909. /**
  110910. * Remove a light for the list of scene's lights
  110911. * @param toRemove defines the light to remove
  110912. * @returns the index where the light was in the light list
  110913. */
  110914. removeLight(toRemove: Light): number;
  110915. /**
  110916. * Remove a camera for the list of scene's cameras
  110917. * @param toRemove defines the camera to remove
  110918. * @returns the index where the camera was in the camera list
  110919. */
  110920. removeCamera(toRemove: Camera): number;
  110921. /**
  110922. * Remove a particle system for the list of scene's particle systems
  110923. * @param toRemove defines the particle system to remove
  110924. * @returns the index where the particle system was in the particle system list
  110925. */
  110926. removeParticleSystem(toRemove: IParticleSystem): number;
  110927. /**
  110928. * Remove a animation for the list of scene's animations
  110929. * @param toRemove defines the animation to remove
  110930. * @returns the index where the animation was in the animation list
  110931. */
  110932. removeAnimation(toRemove: Animation): number;
  110933. /**
  110934. * Will stop the animation of the given target
  110935. * @param target - the target
  110936. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110937. * @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)
  110938. */
  110939. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110940. /**
  110941. * Removes the given animation group from this scene.
  110942. * @param toRemove The animation group to remove
  110943. * @returns The index of the removed animation group
  110944. */
  110945. removeAnimationGroup(toRemove: AnimationGroup): number;
  110946. /**
  110947. * Removes the given multi-material from this scene.
  110948. * @param toRemove The multi-material to remove
  110949. * @returns The index of the removed multi-material
  110950. */
  110951. removeMultiMaterial(toRemove: MultiMaterial): number;
  110952. /**
  110953. * Removes the given material from this scene.
  110954. * @param toRemove The material to remove
  110955. * @returns The index of the removed material
  110956. */
  110957. removeMaterial(toRemove: Material): number;
  110958. /**
  110959. * Removes the given action manager from this scene.
  110960. * @param toRemove The action manager to remove
  110961. * @returns The index of the removed action manager
  110962. */
  110963. removeActionManager(toRemove: AbstractActionManager): number;
  110964. /**
  110965. * Removes the given texture from this scene.
  110966. * @param toRemove The texture to remove
  110967. * @returns The index of the removed texture
  110968. */
  110969. removeTexture(toRemove: BaseTexture): number;
  110970. /**
  110971. * Adds the given light to this scene
  110972. * @param newLight The light to add
  110973. */
  110974. addLight(newLight: Light): void;
  110975. /**
  110976. * Sorts the list list based on light priorities
  110977. */
  110978. sortLightsByPriority(): void;
  110979. /**
  110980. * Adds the given camera to this scene
  110981. * @param newCamera The camera to add
  110982. */
  110983. addCamera(newCamera: Camera): void;
  110984. /**
  110985. * Adds the given skeleton to this scene
  110986. * @param newSkeleton The skeleton to add
  110987. */
  110988. addSkeleton(newSkeleton: Skeleton): void;
  110989. /**
  110990. * Adds the given particle system to this scene
  110991. * @param newParticleSystem The particle system to add
  110992. */
  110993. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110994. /**
  110995. * Adds the given animation to this scene
  110996. * @param newAnimation The animation to add
  110997. */
  110998. addAnimation(newAnimation: Animation): void;
  110999. /**
  111000. * Adds the given animation group to this scene.
  111001. * @param newAnimationGroup The animation group to add
  111002. */
  111003. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  111004. /**
  111005. * Adds the given multi-material to this scene
  111006. * @param newMultiMaterial The multi-material to add
  111007. */
  111008. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  111009. /**
  111010. * Adds the given material to this scene
  111011. * @param newMaterial The material to add
  111012. */
  111013. addMaterial(newMaterial: Material): void;
  111014. /**
  111015. * Adds the given morph target to this scene
  111016. * @param newMorphTargetManager The morph target to add
  111017. */
  111018. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  111019. /**
  111020. * Adds the given geometry to this scene
  111021. * @param newGeometry The geometry to add
  111022. */
  111023. addGeometry(newGeometry: Geometry): void;
  111024. /**
  111025. * Adds the given action manager to this scene
  111026. * @param newActionManager The action manager to add
  111027. */
  111028. addActionManager(newActionManager: AbstractActionManager): void;
  111029. /**
  111030. * Adds the given texture to this scene.
  111031. * @param newTexture The texture to add
  111032. */
  111033. addTexture(newTexture: BaseTexture): void;
  111034. /**
  111035. * Switch active camera
  111036. * @param newCamera defines the new active camera
  111037. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111038. */
  111039. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111040. /**
  111041. * sets the active camera of the scene using its ID
  111042. * @param id defines the camera's ID
  111043. * @return the new active camera or null if none found.
  111044. */
  111045. setActiveCameraByID(id: string): Nullable<Camera>;
  111046. /**
  111047. * sets the active camera of the scene using its name
  111048. * @param name defines the camera's name
  111049. * @returns the new active camera or null if none found.
  111050. */
  111051. setActiveCameraByName(name: string): Nullable<Camera>;
  111052. /**
  111053. * get an animation group using its name
  111054. * @param name defines the material's name
  111055. * @return the animation group or null if none found.
  111056. */
  111057. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111058. /**
  111059. * Get a material using its unique id
  111060. * @param uniqueId defines the material's unique id
  111061. * @return the material or null if none found.
  111062. */
  111063. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111064. /**
  111065. * get a material using its id
  111066. * @param id defines the material's ID
  111067. * @return the material or null if none found.
  111068. */
  111069. getMaterialByID(id: string): Nullable<Material>;
  111070. /**
  111071. * Gets a the last added material using a given id
  111072. * @param id defines the material's ID
  111073. * @return the last material with the given id or null if none found.
  111074. */
  111075. getLastMaterialByID(id: string): Nullable<Material>;
  111076. /**
  111077. * Gets a material using its name
  111078. * @param name defines the material's name
  111079. * @return the material or null if none found.
  111080. */
  111081. getMaterialByName(name: string): Nullable<Material>;
  111082. /**
  111083. * Get a texture using its unique id
  111084. * @param uniqueId defines the texture's unique id
  111085. * @return the texture or null if none found.
  111086. */
  111087. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111088. /**
  111089. * Gets a camera using its id
  111090. * @param id defines the id to look for
  111091. * @returns the camera or null if not found
  111092. */
  111093. getCameraByID(id: string): Nullable<Camera>;
  111094. /**
  111095. * Gets a camera using its unique id
  111096. * @param uniqueId defines the unique id to look for
  111097. * @returns the camera or null if not found
  111098. */
  111099. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111100. /**
  111101. * Gets a camera using its name
  111102. * @param name defines the camera's name
  111103. * @return the camera or null if none found.
  111104. */
  111105. getCameraByName(name: string): Nullable<Camera>;
  111106. /**
  111107. * Gets a bone using its id
  111108. * @param id defines the bone's id
  111109. * @return the bone or null if not found
  111110. */
  111111. getBoneByID(id: string): Nullable<Bone>;
  111112. /**
  111113. * Gets a bone using its id
  111114. * @param name defines the bone's name
  111115. * @return the bone or null if not found
  111116. */
  111117. getBoneByName(name: string): Nullable<Bone>;
  111118. /**
  111119. * Gets a light node using its name
  111120. * @param name defines the the light's name
  111121. * @return the light or null if none found.
  111122. */
  111123. getLightByName(name: string): Nullable<Light>;
  111124. /**
  111125. * Gets a light node using its id
  111126. * @param id defines the light's id
  111127. * @return the light or null if none found.
  111128. */
  111129. getLightByID(id: string): Nullable<Light>;
  111130. /**
  111131. * Gets a light node using its scene-generated unique ID
  111132. * @param uniqueId defines the light's unique id
  111133. * @return the light or null if none found.
  111134. */
  111135. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111136. /**
  111137. * Gets a particle system by id
  111138. * @param id defines the particle system id
  111139. * @return the corresponding system or null if none found
  111140. */
  111141. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111142. /**
  111143. * Gets a geometry using its ID
  111144. * @param id defines the geometry's id
  111145. * @return the geometry or null if none found.
  111146. */
  111147. getGeometryByID(id: string): Nullable<Geometry>;
  111148. private _getGeometryByUniqueID;
  111149. /**
  111150. * Add a new geometry to this scene
  111151. * @param geometry defines the geometry to be added to the scene.
  111152. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111153. * @return a boolean defining if the geometry was added or not
  111154. */
  111155. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111156. /**
  111157. * Removes an existing geometry
  111158. * @param geometry defines the geometry to be removed from the scene
  111159. * @return a boolean defining if the geometry was removed or not
  111160. */
  111161. removeGeometry(geometry: Geometry): boolean;
  111162. /**
  111163. * Gets the list of geometries attached to the scene
  111164. * @returns an array of Geometry
  111165. */
  111166. getGeometries(): Geometry[];
  111167. /**
  111168. * Gets the first added mesh found of a given ID
  111169. * @param id defines the id to search for
  111170. * @return the mesh found or null if not found at all
  111171. */
  111172. getMeshByID(id: string): Nullable<AbstractMesh>;
  111173. /**
  111174. * Gets a list of meshes using their id
  111175. * @param id defines the id to search for
  111176. * @returns a list of meshes
  111177. */
  111178. getMeshesByID(id: string): Array<AbstractMesh>;
  111179. /**
  111180. * Gets the first added transform node found of a given ID
  111181. * @param id defines the id to search for
  111182. * @return the found transform node or null if not found at all.
  111183. */
  111184. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111185. /**
  111186. * Gets a transform node with its auto-generated unique id
  111187. * @param uniqueId efines the unique id to search for
  111188. * @return the found transform node or null if not found at all.
  111189. */
  111190. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111191. /**
  111192. * Gets a list of transform nodes using their id
  111193. * @param id defines the id to search for
  111194. * @returns a list of transform nodes
  111195. */
  111196. getTransformNodesByID(id: string): Array<TransformNode>;
  111197. /**
  111198. * Gets a mesh with its auto-generated unique id
  111199. * @param uniqueId defines the unique id to search for
  111200. * @return the found mesh or null if not found at all.
  111201. */
  111202. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111203. /**
  111204. * Gets a the last added mesh using a given id
  111205. * @param id defines the id to search for
  111206. * @return the found mesh or null if not found at all.
  111207. */
  111208. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111209. /**
  111210. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111211. * @param id defines the id to search for
  111212. * @return the found node or null if not found at all
  111213. */
  111214. getLastEntryByID(id: string): Nullable<Node>;
  111215. /**
  111216. * Gets a node (Mesh, Camera, Light) using a given id
  111217. * @param id defines the id to search for
  111218. * @return the found node or null if not found at all
  111219. */
  111220. getNodeByID(id: string): Nullable<Node>;
  111221. /**
  111222. * Gets a node (Mesh, Camera, Light) using a given name
  111223. * @param name defines the name to search for
  111224. * @return the found node or null if not found at all.
  111225. */
  111226. getNodeByName(name: string): Nullable<Node>;
  111227. /**
  111228. * Gets a mesh using a given name
  111229. * @param name defines the name to search for
  111230. * @return the found mesh or null if not found at all.
  111231. */
  111232. getMeshByName(name: string): Nullable<AbstractMesh>;
  111233. /**
  111234. * Gets a transform node using a given name
  111235. * @param name defines the name to search for
  111236. * @return the found transform node or null if not found at all.
  111237. */
  111238. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111239. /**
  111240. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111241. * @param id defines the id to search for
  111242. * @return the found skeleton or null if not found at all.
  111243. */
  111244. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111245. /**
  111246. * Gets a skeleton using a given auto generated unique id
  111247. * @param uniqueId defines the unique id to search for
  111248. * @return the found skeleton or null if not found at all.
  111249. */
  111250. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111251. /**
  111252. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111253. * @param id defines the id to search for
  111254. * @return the found skeleton or null if not found at all.
  111255. */
  111256. getSkeletonById(id: string): Nullable<Skeleton>;
  111257. /**
  111258. * Gets a skeleton using a given name
  111259. * @param name defines the name to search for
  111260. * @return the found skeleton or null if not found at all.
  111261. */
  111262. getSkeletonByName(name: string): Nullable<Skeleton>;
  111263. /**
  111264. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111265. * @param id defines the id to search for
  111266. * @return the found morph target manager or null if not found at all.
  111267. */
  111268. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111269. /**
  111270. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111271. * @param id defines the id to search for
  111272. * @return the found morph target or null if not found at all.
  111273. */
  111274. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111275. /**
  111276. * Gets a boolean indicating if the given mesh is active
  111277. * @param mesh defines the mesh to look for
  111278. * @returns true if the mesh is in the active list
  111279. */
  111280. isActiveMesh(mesh: AbstractMesh): boolean;
  111281. /**
  111282. * Return a unique id as a string which can serve as an identifier for the scene
  111283. */
  111284. get uid(): string;
  111285. /**
  111286. * Add an externaly attached data from its key.
  111287. * This method call will fail and return false, if such key already exists.
  111288. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111289. * @param key the unique key that identifies the data
  111290. * @param data the data object to associate to the key for this Engine instance
  111291. * @return true if no such key were already present and the data was added successfully, false otherwise
  111292. */
  111293. addExternalData<T>(key: string, data: T): boolean;
  111294. /**
  111295. * Get an externaly attached data from its key
  111296. * @param key the unique key that identifies the data
  111297. * @return the associated data, if present (can be null), or undefined if not present
  111298. */
  111299. getExternalData<T>(key: string): Nullable<T>;
  111300. /**
  111301. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111302. * @param key the unique key that identifies the data
  111303. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111304. * @return the associated data, can be null if the factory returned null.
  111305. */
  111306. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111307. /**
  111308. * Remove an externaly attached data from the Engine instance
  111309. * @param key the unique key that identifies the data
  111310. * @return true if the data was successfully removed, false if it doesn't exist
  111311. */
  111312. removeExternalData(key: string): boolean;
  111313. private _evaluateSubMesh;
  111314. /**
  111315. * Clear the processed materials smart array preventing retention point in material dispose.
  111316. */
  111317. freeProcessedMaterials(): void;
  111318. private _preventFreeActiveMeshesAndRenderingGroups;
  111319. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111320. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111321. * when disposing several meshes in a row or a hierarchy of meshes.
  111322. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111323. */
  111324. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111325. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111326. /**
  111327. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111328. */
  111329. freeActiveMeshes(): void;
  111330. /**
  111331. * Clear the info related to rendering groups preventing retention points during dispose.
  111332. */
  111333. freeRenderingGroups(): void;
  111334. /** @hidden */
  111335. _isInIntermediateRendering(): boolean;
  111336. /**
  111337. * Lambda returning the list of potentially active meshes.
  111338. */
  111339. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111340. /**
  111341. * Lambda returning the list of potentially active sub meshes.
  111342. */
  111343. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111344. /**
  111345. * Lambda returning the list of potentially intersecting sub meshes.
  111346. */
  111347. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111348. /**
  111349. * Lambda returning the list of potentially colliding sub meshes.
  111350. */
  111351. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111352. private _activeMeshesFrozen;
  111353. private _skipEvaluateActiveMeshesCompletely;
  111354. /**
  111355. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111356. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111357. * @returns the current scene
  111358. */
  111359. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111360. /**
  111361. * Use this function to restart evaluating active meshes on every frame
  111362. * @returns the current scene
  111363. */
  111364. unfreezeActiveMeshes(): Scene;
  111365. private _evaluateActiveMeshes;
  111366. private _activeMesh;
  111367. /**
  111368. * Update the transform matrix to update from the current active camera
  111369. * @param force defines a boolean used to force the update even if cache is up to date
  111370. */
  111371. updateTransformMatrix(force?: boolean): void;
  111372. private _bindFrameBuffer;
  111373. /** @hidden */
  111374. _allowPostProcessClearColor: boolean;
  111375. /** @hidden */
  111376. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111377. private _processSubCameras;
  111378. private _checkIntersections;
  111379. /** @hidden */
  111380. _advancePhysicsEngineStep(step: number): void;
  111381. /**
  111382. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111383. */
  111384. getDeterministicFrameTime: () => number;
  111385. /** @hidden */
  111386. _animate(): void;
  111387. /** Execute all animations (for a frame) */
  111388. animate(): void;
  111389. /**
  111390. * Render the scene
  111391. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111392. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111393. */
  111394. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111395. /**
  111396. * Freeze all materials
  111397. * A frozen material will not be updatable but should be faster to render
  111398. */
  111399. freezeMaterials(): void;
  111400. /**
  111401. * Unfreeze all materials
  111402. * A frozen material will not be updatable but should be faster to render
  111403. */
  111404. unfreezeMaterials(): void;
  111405. /**
  111406. * Releases all held ressources
  111407. */
  111408. dispose(): void;
  111409. /**
  111410. * Gets if the scene is already disposed
  111411. */
  111412. get isDisposed(): boolean;
  111413. /**
  111414. * Call this function to reduce memory footprint of the scene.
  111415. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111416. */
  111417. clearCachedVertexData(): void;
  111418. /**
  111419. * This function will remove the local cached buffer data from texture.
  111420. * It will save memory but will prevent the texture from being rebuilt
  111421. */
  111422. cleanCachedTextureBuffer(): void;
  111423. /**
  111424. * Get the world extend vectors with an optional filter
  111425. *
  111426. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111427. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111428. */
  111429. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111430. min: Vector3;
  111431. max: Vector3;
  111432. };
  111433. /**
  111434. * Creates a ray that can be used to pick in the scene
  111435. * @param x defines the x coordinate of the origin (on-screen)
  111436. * @param y defines the y coordinate of the origin (on-screen)
  111437. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111438. * @param camera defines the camera to use for the picking
  111439. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111440. * @returns a Ray
  111441. */
  111442. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111443. /**
  111444. * Creates a ray that can be used to pick in the scene
  111445. * @param x defines the x coordinate of the origin (on-screen)
  111446. * @param y defines the y coordinate of the origin (on-screen)
  111447. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111448. * @param result defines the ray where to store the picking ray
  111449. * @param camera defines the camera to use for the picking
  111450. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111451. * @returns the current scene
  111452. */
  111453. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111454. /**
  111455. * Creates a ray that can be used to pick in the scene
  111456. * @param x defines the x coordinate of the origin (on-screen)
  111457. * @param y defines the y coordinate of the origin (on-screen)
  111458. * @param camera defines the camera to use for the picking
  111459. * @returns a Ray
  111460. */
  111461. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111462. /**
  111463. * Creates a ray that can be used to pick in the scene
  111464. * @param x defines the x coordinate of the origin (on-screen)
  111465. * @param y defines the y coordinate of the origin (on-screen)
  111466. * @param result defines the ray where to store the picking ray
  111467. * @param camera defines the camera to use for the picking
  111468. * @returns the current scene
  111469. */
  111470. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111471. /** Launch a ray to try to pick a mesh in the scene
  111472. * @param x position on screen
  111473. * @param y position on screen
  111474. * @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
  111475. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111476. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111477. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111478. * @returns a PickingInfo
  111479. */
  111480. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111481. /** Use the given ray to pick a mesh in the scene
  111482. * @param ray The ray to use to pick meshes
  111483. * @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
  111484. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111485. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111486. * @returns a PickingInfo
  111487. */
  111488. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111489. /**
  111490. * Launch a ray to try to pick a mesh in the scene
  111491. * @param x X position on screen
  111492. * @param y Y position on screen
  111493. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  111494. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111496. * @returns an array of PickingInfo
  111497. */
  111498. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111499. /**
  111500. * Launch a ray to try to pick a mesh in the scene
  111501. * @param ray Ray to use
  111502. * @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
  111503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111504. * @returns an array of PickingInfo
  111505. */
  111506. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111507. /**
  111508. * Force the value of meshUnderPointer
  111509. * @param mesh defines the mesh to use
  111510. */
  111511. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111512. /**
  111513. * Gets the mesh under the pointer
  111514. * @returns a Mesh or null if no mesh is under the pointer
  111515. */
  111516. getPointerOverMesh(): Nullable<AbstractMesh>;
  111517. /** @hidden */
  111518. _rebuildGeometries(): void;
  111519. /** @hidden */
  111520. _rebuildTextures(): void;
  111521. private _getByTags;
  111522. /**
  111523. * Get a list of meshes by tags
  111524. * @param tagsQuery defines the tags query to use
  111525. * @param forEach defines a predicate used to filter results
  111526. * @returns an array of Mesh
  111527. */
  111528. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111529. /**
  111530. * Get a list of cameras by tags
  111531. * @param tagsQuery defines the tags query to use
  111532. * @param forEach defines a predicate used to filter results
  111533. * @returns an array of Camera
  111534. */
  111535. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111536. /**
  111537. * Get a list of lights by tags
  111538. * @param tagsQuery defines the tags query to use
  111539. * @param forEach defines a predicate used to filter results
  111540. * @returns an array of Light
  111541. */
  111542. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111543. /**
  111544. * Get a list of materials by tags
  111545. * @param tagsQuery defines the tags query to use
  111546. * @param forEach defines a predicate used to filter results
  111547. * @returns an array of Material
  111548. */
  111549. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111550. /**
  111551. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111552. * This allowed control for front to back rendering or reversly depending of the special needs.
  111553. *
  111554. * @param renderingGroupId The rendering group id corresponding to its index
  111555. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111556. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111557. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111558. */
  111559. 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;
  111560. /**
  111561. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111562. *
  111563. * @param renderingGroupId The rendering group id corresponding to its index
  111564. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111565. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111566. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111567. */
  111568. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111569. /**
  111570. * Gets the current auto clear configuration for one rendering group of the rendering
  111571. * manager.
  111572. * @param index the rendering group index to get the information for
  111573. * @returns The auto clear setup for the requested rendering group
  111574. */
  111575. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111576. private _blockMaterialDirtyMechanism;
  111577. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111578. get blockMaterialDirtyMechanism(): boolean;
  111579. set blockMaterialDirtyMechanism(value: boolean);
  111580. /**
  111581. * Will flag all materials as dirty to trigger new shader compilation
  111582. * @param flag defines the flag used to specify which material part must be marked as dirty
  111583. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111584. */
  111585. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111586. /** @hidden */
  111587. _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;
  111588. /** @hidden */
  111589. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111590. /** @hidden */
  111591. _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;
  111592. /** @hidden */
  111593. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111594. /** @hidden */
  111595. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111596. /** @hidden */
  111597. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111598. }
  111599. }
  111600. declare module BABYLON {
  111601. /**
  111602. * Set of assets to keep when moving a scene into an asset container.
  111603. */
  111604. export class KeepAssets extends AbstractScene {
  111605. }
  111606. /**
  111607. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111608. */
  111609. export class InstantiatedEntries {
  111610. /**
  111611. * List of new root nodes (eg. nodes with no parent)
  111612. */
  111613. rootNodes: TransformNode[];
  111614. /**
  111615. * List of new skeletons
  111616. */
  111617. skeletons: Skeleton[];
  111618. /**
  111619. * List of new animation groups
  111620. */
  111621. animationGroups: AnimationGroup[];
  111622. }
  111623. /**
  111624. * Container with a set of assets that can be added or removed from a scene.
  111625. */
  111626. export class AssetContainer extends AbstractScene {
  111627. private _wasAddedToScene;
  111628. /**
  111629. * The scene the AssetContainer belongs to.
  111630. */
  111631. scene: Scene;
  111632. /**
  111633. * Instantiates an AssetContainer.
  111634. * @param scene The scene the AssetContainer belongs to.
  111635. */
  111636. constructor(scene: Scene);
  111637. /**
  111638. * Instantiate or clone all meshes and add the new ones to the scene.
  111639. * Skeletons and animation groups will all be cloned
  111640. * @param nameFunction defines an optional function used to get new names for clones
  111641. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111642. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111643. */
  111644. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111645. /**
  111646. * Adds all the assets from the container to the scene.
  111647. */
  111648. addAllToScene(): void;
  111649. /**
  111650. * Removes all the assets in the container from the scene
  111651. */
  111652. removeAllFromScene(): void;
  111653. /**
  111654. * Disposes all the assets in the container
  111655. */
  111656. dispose(): void;
  111657. private _moveAssets;
  111658. /**
  111659. * Removes all the assets contained in the scene and adds them to the container.
  111660. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111661. */
  111662. moveAllFromScene(keepAssets?: KeepAssets): void;
  111663. /**
  111664. * 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.
  111665. * @returns the root mesh
  111666. */
  111667. createRootMesh(): Mesh;
  111668. /**
  111669. * Merge animations from this asset container into a scene
  111670. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111671. * @param animatables set of animatables to retarget to a node from the scene
  111672. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111673. */
  111674. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111675. }
  111676. }
  111677. declare module BABYLON {
  111678. /**
  111679. * Defines how the parser contract is defined.
  111680. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111681. */
  111682. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111683. /**
  111684. * Defines how the individual parser contract is defined.
  111685. * These parser can parse an individual asset
  111686. */
  111687. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111688. /**
  111689. * Base class of the scene acting as a container for the different elements composing a scene.
  111690. * This class is dynamically extended by the different components of the scene increasing
  111691. * flexibility and reducing coupling
  111692. */
  111693. export abstract class AbstractScene {
  111694. /**
  111695. * Stores the list of available parsers in the application.
  111696. */
  111697. private static _BabylonFileParsers;
  111698. /**
  111699. * Stores the list of available individual parsers in the application.
  111700. */
  111701. private static _IndividualBabylonFileParsers;
  111702. /**
  111703. * Adds a parser in the list of available ones
  111704. * @param name Defines the name of the parser
  111705. * @param parser Defines the parser to add
  111706. */
  111707. static AddParser(name: string, parser: BabylonFileParser): void;
  111708. /**
  111709. * Gets a general parser from the list of avaialble ones
  111710. * @param name Defines the name of the parser
  111711. * @returns the requested parser or null
  111712. */
  111713. static GetParser(name: string): Nullable<BabylonFileParser>;
  111714. /**
  111715. * Adds n individual parser in the list of available ones
  111716. * @param name Defines the name of the parser
  111717. * @param parser Defines the parser to add
  111718. */
  111719. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111720. /**
  111721. * Gets an individual parser from the list of avaialble ones
  111722. * @param name Defines the name of the parser
  111723. * @returns the requested parser or null
  111724. */
  111725. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111726. /**
  111727. * Parser json data and populate both a scene and its associated container object
  111728. * @param jsonData Defines the data to parse
  111729. * @param scene Defines the scene to parse the data for
  111730. * @param container Defines the container attached to the parsing sequence
  111731. * @param rootUrl Defines the root url of the data
  111732. */
  111733. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111734. /**
  111735. * Gets the list of root nodes (ie. nodes with no parent)
  111736. */
  111737. rootNodes: Node[];
  111738. /** All of the cameras added to this scene
  111739. * @see http://doc.babylonjs.com/babylon101/cameras
  111740. */
  111741. cameras: Camera[];
  111742. /**
  111743. * All of the lights added to this scene
  111744. * @see http://doc.babylonjs.com/babylon101/lights
  111745. */
  111746. lights: Light[];
  111747. /**
  111748. * All of the (abstract) meshes added to this scene
  111749. */
  111750. meshes: AbstractMesh[];
  111751. /**
  111752. * The list of skeletons added to the scene
  111753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111754. */
  111755. skeletons: Skeleton[];
  111756. /**
  111757. * All of the particle systems added to this scene
  111758. * @see http://doc.babylonjs.com/babylon101/particles
  111759. */
  111760. particleSystems: IParticleSystem[];
  111761. /**
  111762. * Gets a list of Animations associated with the scene
  111763. */
  111764. animations: Animation[];
  111765. /**
  111766. * All of the animation groups added to this scene
  111767. * @see http://doc.babylonjs.com/how_to/group
  111768. */
  111769. animationGroups: AnimationGroup[];
  111770. /**
  111771. * All of the multi-materials added to this scene
  111772. * @see http://doc.babylonjs.com/how_to/multi_materials
  111773. */
  111774. multiMaterials: MultiMaterial[];
  111775. /**
  111776. * All of the materials added to this scene
  111777. * In the context of a Scene, it is not supposed to be modified manually.
  111778. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  111779. * Note also that the order of the Material within the array is not significant and might change.
  111780. * @see http://doc.babylonjs.com/babylon101/materials
  111781. */
  111782. materials: Material[];
  111783. /**
  111784. * The list of morph target managers added to the scene
  111785. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111786. */
  111787. morphTargetManagers: MorphTargetManager[];
  111788. /**
  111789. * The list of geometries used in the scene.
  111790. */
  111791. geometries: Geometry[];
  111792. /**
  111793. * All of the tranform nodes added to this scene
  111794. * In the context of a Scene, it is not supposed to be modified manually.
  111795. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  111796. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111797. * @see http://doc.babylonjs.com/how_to/transformnode
  111798. */
  111799. transformNodes: TransformNode[];
  111800. /**
  111801. * ActionManagers available on the scene.
  111802. */
  111803. actionManagers: AbstractActionManager[];
  111804. /**
  111805. * Textures to keep.
  111806. */
  111807. textures: BaseTexture[];
  111808. /**
  111809. * Environment texture for the scene
  111810. */
  111811. environmentTexture: Nullable<BaseTexture>;
  111812. /**
  111813. * @returns all meshes, lights, cameras, transformNodes and bones
  111814. */
  111815. getNodes(): Array<Node>;
  111816. }
  111817. }
  111818. declare module BABYLON {
  111819. /**
  111820. * Interface used to define options for Sound class
  111821. */
  111822. export interface ISoundOptions {
  111823. /**
  111824. * Does the sound autoplay once loaded.
  111825. */
  111826. autoplay?: boolean;
  111827. /**
  111828. * Does the sound loop after it finishes playing once.
  111829. */
  111830. loop?: boolean;
  111831. /**
  111832. * Sound's volume
  111833. */
  111834. volume?: number;
  111835. /**
  111836. * Is it a spatial sound?
  111837. */
  111838. spatialSound?: boolean;
  111839. /**
  111840. * Maximum distance to hear that sound
  111841. */
  111842. maxDistance?: number;
  111843. /**
  111844. * Uses user defined attenuation function
  111845. */
  111846. useCustomAttenuation?: boolean;
  111847. /**
  111848. * Define the roll off factor of spatial sounds.
  111849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111850. */
  111851. rolloffFactor?: number;
  111852. /**
  111853. * Define the reference distance the sound should be heard perfectly.
  111854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111855. */
  111856. refDistance?: number;
  111857. /**
  111858. * Define the distance attenuation model the sound will follow.
  111859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111860. */
  111861. distanceModel?: string;
  111862. /**
  111863. * Defines the playback speed (1 by default)
  111864. */
  111865. playbackRate?: number;
  111866. /**
  111867. * Defines if the sound is from a streaming source
  111868. */
  111869. streaming?: boolean;
  111870. /**
  111871. * Defines an optional length (in seconds) inside the sound file
  111872. */
  111873. length?: number;
  111874. /**
  111875. * Defines an optional offset (in seconds) inside the sound file
  111876. */
  111877. offset?: number;
  111878. /**
  111879. * If true, URLs will not be required to state the audio file codec to use.
  111880. */
  111881. skipCodecCheck?: boolean;
  111882. }
  111883. /**
  111884. * Defines a sound that can be played in the application.
  111885. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111887. */
  111888. export class Sound {
  111889. /**
  111890. * The name of the sound in the scene.
  111891. */
  111892. name: string;
  111893. /**
  111894. * Does the sound autoplay once loaded.
  111895. */
  111896. autoplay: boolean;
  111897. /**
  111898. * Does the sound loop after it finishes playing once.
  111899. */
  111900. loop: boolean;
  111901. /**
  111902. * Does the sound use a custom attenuation curve to simulate the falloff
  111903. * happening when the source gets further away from the camera.
  111904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111905. */
  111906. useCustomAttenuation: boolean;
  111907. /**
  111908. * The sound track id this sound belongs to.
  111909. */
  111910. soundTrackId: number;
  111911. /**
  111912. * Is this sound currently played.
  111913. */
  111914. isPlaying: boolean;
  111915. /**
  111916. * Is this sound currently paused.
  111917. */
  111918. isPaused: boolean;
  111919. /**
  111920. * Does this sound enables spatial sound.
  111921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111922. */
  111923. spatialSound: boolean;
  111924. /**
  111925. * Define the reference distance the sound should be heard perfectly.
  111926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111927. */
  111928. refDistance: number;
  111929. /**
  111930. * Define the roll off factor of spatial sounds.
  111931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111932. */
  111933. rolloffFactor: number;
  111934. /**
  111935. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111937. */
  111938. maxDistance: number;
  111939. /**
  111940. * Define the distance attenuation model the sound will follow.
  111941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111942. */
  111943. distanceModel: string;
  111944. /**
  111945. * @hidden
  111946. * Back Compat
  111947. **/
  111948. onended: () => any;
  111949. /**
  111950. * Observable event when the current playing sound finishes.
  111951. */
  111952. onEndedObservable: Observable<Sound>;
  111953. private _panningModel;
  111954. private _playbackRate;
  111955. private _streaming;
  111956. private _startTime;
  111957. private _startOffset;
  111958. private _position;
  111959. /** @hidden */
  111960. _positionInEmitterSpace: boolean;
  111961. private _localDirection;
  111962. private _volume;
  111963. private _isReadyToPlay;
  111964. private _isDirectional;
  111965. private _readyToPlayCallback;
  111966. private _audioBuffer;
  111967. private _soundSource;
  111968. private _streamingSource;
  111969. private _soundPanner;
  111970. private _soundGain;
  111971. private _inputAudioNode;
  111972. private _outputAudioNode;
  111973. private _coneInnerAngle;
  111974. private _coneOuterAngle;
  111975. private _coneOuterGain;
  111976. private _scene;
  111977. private _connectedTransformNode;
  111978. private _customAttenuationFunction;
  111979. private _registerFunc;
  111980. private _isOutputConnected;
  111981. private _htmlAudioElement;
  111982. private _urlType;
  111983. private _length?;
  111984. private _offset?;
  111985. /** @hidden */
  111986. static _SceneComponentInitialization: (scene: Scene) => void;
  111987. /**
  111988. * Create a sound and attach it to a scene
  111989. * @param name Name of your sound
  111990. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111991. * @param scene defines the scene the sound belongs to
  111992. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111993. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111994. */
  111995. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111996. /**
  111997. * Release the sound and its associated resources
  111998. */
  111999. dispose(): void;
  112000. /**
  112001. * Gets if the sounds is ready to be played or not.
  112002. * @returns true if ready, otherwise false
  112003. */
  112004. isReady(): boolean;
  112005. private _soundLoaded;
  112006. /**
  112007. * Sets the data of the sound from an audiobuffer
  112008. * @param audioBuffer The audioBuffer containing the data
  112009. */
  112010. setAudioBuffer(audioBuffer: AudioBuffer): void;
  112011. /**
  112012. * Updates the current sounds options such as maxdistance, loop...
  112013. * @param options A JSON object containing values named as the object properties
  112014. */
  112015. updateOptions(options: ISoundOptions): void;
  112016. private _createSpatialParameters;
  112017. private _updateSpatialParameters;
  112018. /**
  112019. * Switch the panning model to HRTF:
  112020. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112022. */
  112023. switchPanningModelToHRTF(): void;
  112024. /**
  112025. * Switch the panning model to Equal Power:
  112026. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112028. */
  112029. switchPanningModelToEqualPower(): void;
  112030. private _switchPanningModel;
  112031. /**
  112032. * Connect this sound to a sound track audio node like gain...
  112033. * @param soundTrackAudioNode the sound track audio node to connect to
  112034. */
  112035. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112036. /**
  112037. * Transform this sound into a directional source
  112038. * @param coneInnerAngle Size of the inner cone in degree
  112039. * @param coneOuterAngle Size of the outer cone in degree
  112040. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112041. */
  112042. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112043. /**
  112044. * Gets or sets the inner angle for the directional cone.
  112045. */
  112046. get directionalConeInnerAngle(): number;
  112047. /**
  112048. * Gets or sets the inner angle for the directional cone.
  112049. */
  112050. set directionalConeInnerAngle(value: number);
  112051. /**
  112052. * Gets or sets the outer angle for the directional cone.
  112053. */
  112054. get directionalConeOuterAngle(): number;
  112055. /**
  112056. * Gets or sets the outer angle for the directional cone.
  112057. */
  112058. set directionalConeOuterAngle(value: number);
  112059. /**
  112060. * Sets the position of the emitter if spatial sound is enabled
  112061. * @param newPosition Defines the new posisiton
  112062. */
  112063. setPosition(newPosition: Vector3): void;
  112064. /**
  112065. * Sets the local direction of the emitter if spatial sound is enabled
  112066. * @param newLocalDirection Defines the new local direction
  112067. */
  112068. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112069. private _updateDirection;
  112070. /** @hidden */
  112071. updateDistanceFromListener(): void;
  112072. /**
  112073. * Sets a new custom attenuation function for the sound.
  112074. * @param callback Defines the function used for the attenuation
  112075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112076. */
  112077. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112078. /**
  112079. * Play the sound
  112080. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112081. * @param offset (optional) Start the sound at a specific time in seconds
  112082. * @param length (optional) Sound duration (in seconds)
  112083. */
  112084. play(time?: number, offset?: number, length?: number): void;
  112085. private _onended;
  112086. /**
  112087. * Stop the sound
  112088. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112089. */
  112090. stop(time?: number): void;
  112091. /**
  112092. * Put the sound in pause
  112093. */
  112094. pause(): void;
  112095. /**
  112096. * Sets a dedicated volume for this sounds
  112097. * @param newVolume Define the new volume of the sound
  112098. * @param time Define time for gradual change to new volume
  112099. */
  112100. setVolume(newVolume: number, time?: number): void;
  112101. /**
  112102. * Set the sound play back rate
  112103. * @param newPlaybackRate Define the playback rate the sound should be played at
  112104. */
  112105. setPlaybackRate(newPlaybackRate: number): void;
  112106. /**
  112107. * Gets the volume of the sound.
  112108. * @returns the volume of the sound
  112109. */
  112110. getVolume(): number;
  112111. /**
  112112. * Attach the sound to a dedicated mesh
  112113. * @param transformNode The transform node to connect the sound with
  112114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112115. */
  112116. attachToMesh(transformNode: TransformNode): void;
  112117. /**
  112118. * Detach the sound from the previously attached mesh
  112119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112120. */
  112121. detachFromMesh(): void;
  112122. private _onRegisterAfterWorldMatrixUpdate;
  112123. /**
  112124. * Clone the current sound in the scene.
  112125. * @returns the new sound clone
  112126. */
  112127. clone(): Nullable<Sound>;
  112128. /**
  112129. * Gets the current underlying audio buffer containing the data
  112130. * @returns the audio buffer
  112131. */
  112132. getAudioBuffer(): Nullable<AudioBuffer>;
  112133. /**
  112134. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112135. * @returns the source node
  112136. */
  112137. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112138. /**
  112139. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112140. * @returns the gain node
  112141. */
  112142. getSoundGain(): Nullable<GainNode>;
  112143. /**
  112144. * Serializes the Sound in a JSON representation
  112145. * @returns the JSON representation of the sound
  112146. */
  112147. serialize(): any;
  112148. /**
  112149. * Parse a JSON representation of a sound to innstantiate in a given scene
  112150. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112151. * @param scene Define the scene the new parsed sound should be created in
  112152. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112153. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112154. * @returns the newly parsed sound
  112155. */
  112156. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112157. }
  112158. }
  112159. declare module BABYLON {
  112160. /**
  112161. * This defines an action helpful to play a defined sound on a triggered action.
  112162. */
  112163. export class PlaySoundAction extends Action {
  112164. private _sound;
  112165. /**
  112166. * Instantiate the action
  112167. * @param triggerOptions defines the trigger options
  112168. * @param sound defines the sound to play
  112169. * @param condition defines the trigger related conditions
  112170. */
  112171. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112172. /** @hidden */
  112173. _prepare(): void;
  112174. /**
  112175. * Execute the action and play the sound.
  112176. */
  112177. execute(): void;
  112178. /**
  112179. * Serializes the actions and its related information.
  112180. * @param parent defines the object to serialize in
  112181. * @returns the serialized object
  112182. */
  112183. serialize(parent: any): any;
  112184. }
  112185. /**
  112186. * This defines an action helpful to stop a defined sound on a triggered action.
  112187. */
  112188. export class StopSoundAction extends Action {
  112189. private _sound;
  112190. /**
  112191. * Instantiate the action
  112192. * @param triggerOptions defines the trigger options
  112193. * @param sound defines the sound to stop
  112194. * @param condition defines the trigger related conditions
  112195. */
  112196. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112197. /** @hidden */
  112198. _prepare(): void;
  112199. /**
  112200. * Execute the action and stop the sound.
  112201. */
  112202. execute(): void;
  112203. /**
  112204. * Serializes the actions and its related information.
  112205. * @param parent defines the object to serialize in
  112206. * @returns the serialized object
  112207. */
  112208. serialize(parent: any): any;
  112209. }
  112210. }
  112211. declare module BABYLON {
  112212. /**
  112213. * This defines an action responsible to change the value of a property
  112214. * by interpolating between its current value and the newly set one once triggered.
  112215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112216. */
  112217. export class InterpolateValueAction extends Action {
  112218. /**
  112219. * Defines the path of the property where the value should be interpolated
  112220. */
  112221. propertyPath: string;
  112222. /**
  112223. * Defines the target value at the end of the interpolation.
  112224. */
  112225. value: any;
  112226. /**
  112227. * Defines the time it will take for the property to interpolate to the value.
  112228. */
  112229. duration: number;
  112230. /**
  112231. * Defines if the other scene animations should be stopped when the action has been triggered
  112232. */
  112233. stopOtherAnimations?: boolean;
  112234. /**
  112235. * Defines a callback raised once the interpolation animation has been done.
  112236. */
  112237. onInterpolationDone?: () => void;
  112238. /**
  112239. * Observable triggered once the interpolation animation has been done.
  112240. */
  112241. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112242. private _target;
  112243. private _effectiveTarget;
  112244. private _property;
  112245. /**
  112246. * Instantiate the action
  112247. * @param triggerOptions defines the trigger options
  112248. * @param target defines the object containing the value to interpolate
  112249. * @param propertyPath defines the path to the property in the target object
  112250. * @param value defines the target value at the end of the interpolation
  112251. * @param duration deines the time it will take for the property to interpolate to the value.
  112252. * @param condition defines the trigger related conditions
  112253. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112254. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112255. */
  112256. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112257. /** @hidden */
  112258. _prepare(): void;
  112259. /**
  112260. * Execute the action starts the value interpolation.
  112261. */
  112262. execute(): void;
  112263. /**
  112264. * Serializes the actions and its related information.
  112265. * @param parent defines the object to serialize in
  112266. * @returns the serialized object
  112267. */
  112268. serialize(parent: any): any;
  112269. }
  112270. }
  112271. declare module BABYLON {
  112272. /**
  112273. * Options allowed during the creation of a sound track.
  112274. */
  112275. export interface ISoundTrackOptions {
  112276. /**
  112277. * The volume the sound track should take during creation
  112278. */
  112279. volume?: number;
  112280. /**
  112281. * Define if the sound track is the main sound track of the scene
  112282. */
  112283. mainTrack?: boolean;
  112284. }
  112285. /**
  112286. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112287. * It will be also used in a future release to apply effects on a specific track.
  112288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112289. */
  112290. export class SoundTrack {
  112291. /**
  112292. * The unique identifier of the sound track in the scene.
  112293. */
  112294. id: number;
  112295. /**
  112296. * The list of sounds included in the sound track.
  112297. */
  112298. soundCollection: Array<Sound>;
  112299. private _outputAudioNode;
  112300. private _scene;
  112301. private _connectedAnalyser;
  112302. private _options;
  112303. private _isInitialized;
  112304. /**
  112305. * Creates a new sound track.
  112306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112307. * @param scene Define the scene the sound track belongs to
  112308. * @param options
  112309. */
  112310. constructor(scene: Scene, options?: ISoundTrackOptions);
  112311. private _initializeSoundTrackAudioGraph;
  112312. /**
  112313. * Release the sound track and its associated resources
  112314. */
  112315. dispose(): void;
  112316. /**
  112317. * Adds a sound to this sound track
  112318. * @param sound define the cound to add
  112319. * @ignoreNaming
  112320. */
  112321. AddSound(sound: Sound): void;
  112322. /**
  112323. * Removes a sound to this sound track
  112324. * @param sound define the cound to remove
  112325. * @ignoreNaming
  112326. */
  112327. RemoveSound(sound: Sound): void;
  112328. /**
  112329. * Set a global volume for the full sound track.
  112330. * @param newVolume Define the new volume of the sound track
  112331. */
  112332. setVolume(newVolume: number): void;
  112333. /**
  112334. * Switch the panning model to HRTF:
  112335. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112337. */
  112338. switchPanningModelToHRTF(): void;
  112339. /**
  112340. * Switch the panning model to Equal Power:
  112341. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112343. */
  112344. switchPanningModelToEqualPower(): void;
  112345. /**
  112346. * Connect the sound track to an audio analyser allowing some amazing
  112347. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112349. * @param analyser The analyser to connect to the engine
  112350. */
  112351. connectToAnalyser(analyser: Analyser): void;
  112352. }
  112353. }
  112354. declare module BABYLON {
  112355. interface AbstractScene {
  112356. /**
  112357. * The list of sounds used in the scene.
  112358. */
  112359. sounds: Nullable<Array<Sound>>;
  112360. }
  112361. interface Scene {
  112362. /**
  112363. * @hidden
  112364. * Backing field
  112365. */
  112366. _mainSoundTrack: SoundTrack;
  112367. /**
  112368. * The main sound track played by the scene.
  112369. * It cotains your primary collection of sounds.
  112370. */
  112371. mainSoundTrack: SoundTrack;
  112372. /**
  112373. * The list of sound tracks added to the scene
  112374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112375. */
  112376. soundTracks: Nullable<Array<SoundTrack>>;
  112377. /**
  112378. * Gets a sound using a given name
  112379. * @param name defines the name to search for
  112380. * @return the found sound or null if not found at all.
  112381. */
  112382. getSoundByName(name: string): Nullable<Sound>;
  112383. /**
  112384. * Gets or sets if audio support is enabled
  112385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112386. */
  112387. audioEnabled: boolean;
  112388. /**
  112389. * Gets or sets if audio will be output to headphones
  112390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112391. */
  112392. headphone: boolean;
  112393. /**
  112394. * Gets or sets custom audio listener position provider
  112395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112396. */
  112397. audioListenerPositionProvider: Nullable<() => Vector3>;
  112398. /**
  112399. * Gets or sets a refresh rate when using 3D audio positioning
  112400. */
  112401. audioPositioningRefreshRate: number;
  112402. }
  112403. /**
  112404. * Defines the sound scene component responsible to manage any sounds
  112405. * in a given scene.
  112406. */
  112407. export class AudioSceneComponent implements ISceneSerializableComponent {
  112408. /**
  112409. * The component name helpfull to identify the component in the list of scene components.
  112410. */
  112411. readonly name: string;
  112412. /**
  112413. * The scene the component belongs to.
  112414. */
  112415. scene: Scene;
  112416. private _audioEnabled;
  112417. /**
  112418. * Gets whether audio is enabled or not.
  112419. * Please use related enable/disable method to switch state.
  112420. */
  112421. get audioEnabled(): boolean;
  112422. private _headphone;
  112423. /**
  112424. * Gets whether audio is outputing to headphone or not.
  112425. * Please use the according Switch methods to change output.
  112426. */
  112427. get headphone(): boolean;
  112428. /**
  112429. * Gets or sets a refresh rate when using 3D audio positioning
  112430. */
  112431. audioPositioningRefreshRate: number;
  112432. private _audioListenerPositionProvider;
  112433. /**
  112434. * Gets the current audio listener position provider
  112435. */
  112436. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112437. /**
  112438. * Sets a custom listener position for all sounds in the scene
  112439. * By default, this is the position of the first active camera
  112440. */
  112441. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112442. /**
  112443. * Creates a new instance of the component for the given scene
  112444. * @param scene Defines the scene to register the component in
  112445. */
  112446. constructor(scene: Scene);
  112447. /**
  112448. * Registers the component in a given scene
  112449. */
  112450. register(): void;
  112451. /**
  112452. * Rebuilds the elements related to this component in case of
  112453. * context lost for instance.
  112454. */
  112455. rebuild(): void;
  112456. /**
  112457. * Serializes the component data to the specified json object
  112458. * @param serializationObject The object to serialize to
  112459. */
  112460. serialize(serializationObject: any): void;
  112461. /**
  112462. * Adds all the elements from the container to the scene
  112463. * @param container the container holding the elements
  112464. */
  112465. addFromContainer(container: AbstractScene): void;
  112466. /**
  112467. * Removes all the elements in the container from the scene
  112468. * @param container contains the elements to remove
  112469. * @param dispose if the removed element should be disposed (default: false)
  112470. */
  112471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112472. /**
  112473. * Disposes the component and the associated ressources.
  112474. */
  112475. dispose(): void;
  112476. /**
  112477. * Disables audio in the associated scene.
  112478. */
  112479. disableAudio(): void;
  112480. /**
  112481. * Enables audio in the associated scene.
  112482. */
  112483. enableAudio(): void;
  112484. /**
  112485. * Switch audio to headphone output.
  112486. */
  112487. switchAudioModeForHeadphones(): void;
  112488. /**
  112489. * Switch audio to normal speakers.
  112490. */
  112491. switchAudioModeForNormalSpeakers(): void;
  112492. private _cachedCameraDirection;
  112493. private _cachedCameraPosition;
  112494. private _lastCheck;
  112495. private _afterRender;
  112496. }
  112497. }
  112498. declare module BABYLON {
  112499. /**
  112500. * Wraps one or more Sound objects and selects one with random weight for playback.
  112501. */
  112502. export class WeightedSound {
  112503. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112504. loop: boolean;
  112505. private _coneInnerAngle;
  112506. private _coneOuterAngle;
  112507. private _volume;
  112508. /** A Sound is currently playing. */
  112509. isPlaying: boolean;
  112510. /** A Sound is currently paused. */
  112511. isPaused: boolean;
  112512. private _sounds;
  112513. private _weights;
  112514. private _currentIndex?;
  112515. /**
  112516. * Creates a new WeightedSound from the list of sounds given.
  112517. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112518. * @param sounds Array of Sounds that will be selected from.
  112519. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112520. */
  112521. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112522. /**
  112523. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112524. */
  112525. get directionalConeInnerAngle(): number;
  112526. /**
  112527. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112528. */
  112529. set directionalConeInnerAngle(value: number);
  112530. /**
  112531. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112532. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112533. */
  112534. get directionalConeOuterAngle(): number;
  112535. /**
  112536. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112537. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112538. */
  112539. set directionalConeOuterAngle(value: number);
  112540. /**
  112541. * Playback volume.
  112542. */
  112543. get volume(): number;
  112544. /**
  112545. * Playback volume.
  112546. */
  112547. set volume(value: number);
  112548. private _onended;
  112549. /**
  112550. * Suspend playback
  112551. */
  112552. pause(): void;
  112553. /**
  112554. * Stop playback
  112555. */
  112556. stop(): void;
  112557. /**
  112558. * Start playback.
  112559. * @param startOffset Position the clip head at a specific time in seconds.
  112560. */
  112561. play(startOffset?: number): void;
  112562. }
  112563. }
  112564. declare module BABYLON {
  112565. /**
  112566. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112567. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112568. */
  112569. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112570. /**
  112571. * Gets the name of the behavior.
  112572. */
  112573. get name(): string;
  112574. /**
  112575. * The easing function used by animations
  112576. */
  112577. static EasingFunction: BackEase;
  112578. /**
  112579. * The easing mode used by animations
  112580. */
  112581. static EasingMode: number;
  112582. /**
  112583. * The duration of the animation, in milliseconds
  112584. */
  112585. transitionDuration: number;
  112586. /**
  112587. * Length of the distance animated by the transition when lower radius is reached
  112588. */
  112589. lowerRadiusTransitionRange: number;
  112590. /**
  112591. * Length of the distance animated by the transition when upper radius is reached
  112592. */
  112593. upperRadiusTransitionRange: number;
  112594. private _autoTransitionRange;
  112595. /**
  112596. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112597. */
  112598. get autoTransitionRange(): boolean;
  112599. /**
  112600. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112601. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112602. */
  112603. set autoTransitionRange(value: boolean);
  112604. private _attachedCamera;
  112605. private _onAfterCheckInputsObserver;
  112606. private _onMeshTargetChangedObserver;
  112607. /**
  112608. * Initializes the behavior.
  112609. */
  112610. init(): void;
  112611. /**
  112612. * Attaches the behavior to its arc rotate camera.
  112613. * @param camera Defines the camera to attach the behavior to
  112614. */
  112615. attach(camera: ArcRotateCamera): void;
  112616. /**
  112617. * Detaches the behavior from its current arc rotate camera.
  112618. */
  112619. detach(): void;
  112620. private _radiusIsAnimating;
  112621. private _radiusBounceTransition;
  112622. private _animatables;
  112623. private _cachedWheelPrecision;
  112624. /**
  112625. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112626. * @param radiusLimit The limit to check against.
  112627. * @return Bool to indicate if at limit.
  112628. */
  112629. private _isRadiusAtLimit;
  112630. /**
  112631. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112632. * @param radiusDelta The delta by which to animate to. Can be negative.
  112633. */
  112634. private _applyBoundRadiusAnimation;
  112635. /**
  112636. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112637. */
  112638. protected _clearAnimationLocks(): void;
  112639. /**
  112640. * Stops and removes all animations that have been applied to the camera
  112641. */
  112642. stopAllAnimations(): void;
  112643. }
  112644. }
  112645. declare module BABYLON {
  112646. /**
  112647. * 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.
  112648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112649. */
  112650. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112651. /**
  112652. * Gets the name of the behavior.
  112653. */
  112654. get name(): string;
  112655. private _mode;
  112656. private _radiusScale;
  112657. private _positionScale;
  112658. private _defaultElevation;
  112659. private _elevationReturnTime;
  112660. private _elevationReturnWaitTime;
  112661. private _zoomStopsAnimation;
  112662. private _framingTime;
  112663. /**
  112664. * The easing function used by animations
  112665. */
  112666. static EasingFunction: ExponentialEase;
  112667. /**
  112668. * The easing mode used by animations
  112669. */
  112670. static EasingMode: number;
  112671. /**
  112672. * Sets the current mode used by the behavior
  112673. */
  112674. set mode(mode: number);
  112675. /**
  112676. * Gets current mode used by the behavior.
  112677. */
  112678. get mode(): number;
  112679. /**
  112680. * Sets the scale applied to the radius (1 by default)
  112681. */
  112682. set radiusScale(radius: number);
  112683. /**
  112684. * Gets the scale applied to the radius
  112685. */
  112686. get radiusScale(): number;
  112687. /**
  112688. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112689. */
  112690. set positionScale(scale: number);
  112691. /**
  112692. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112693. */
  112694. get positionScale(): number;
  112695. /**
  112696. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112697. * behaviour is triggered, in radians.
  112698. */
  112699. set defaultElevation(elevation: number);
  112700. /**
  112701. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112702. * behaviour is triggered, in radians.
  112703. */
  112704. get defaultElevation(): number;
  112705. /**
  112706. * Sets the time (in milliseconds) taken to return to the default beta position.
  112707. * Negative value indicates camera should not return to default.
  112708. */
  112709. set elevationReturnTime(speed: number);
  112710. /**
  112711. * Gets the time (in milliseconds) taken to return to the default beta position.
  112712. * Negative value indicates camera should not return to default.
  112713. */
  112714. get elevationReturnTime(): number;
  112715. /**
  112716. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112717. */
  112718. set elevationReturnWaitTime(time: number);
  112719. /**
  112720. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112721. */
  112722. get elevationReturnWaitTime(): number;
  112723. /**
  112724. * Sets the flag that indicates if user zooming should stop animation.
  112725. */
  112726. set zoomStopsAnimation(flag: boolean);
  112727. /**
  112728. * Gets the flag that indicates if user zooming should stop animation.
  112729. */
  112730. get zoomStopsAnimation(): boolean;
  112731. /**
  112732. * Sets the transition time when framing the mesh, in milliseconds
  112733. */
  112734. set framingTime(time: number);
  112735. /**
  112736. * Gets the transition time when framing the mesh, in milliseconds
  112737. */
  112738. get framingTime(): number;
  112739. /**
  112740. * Define if the behavior should automatically change the configured
  112741. * camera limits and sensibilities.
  112742. */
  112743. autoCorrectCameraLimitsAndSensibility: boolean;
  112744. private _onPrePointerObservableObserver;
  112745. private _onAfterCheckInputsObserver;
  112746. private _onMeshTargetChangedObserver;
  112747. private _attachedCamera;
  112748. private _isPointerDown;
  112749. private _lastInteractionTime;
  112750. /**
  112751. * Initializes the behavior.
  112752. */
  112753. init(): void;
  112754. /**
  112755. * Attaches the behavior to its arc rotate camera.
  112756. * @param camera Defines the camera to attach the behavior to
  112757. */
  112758. attach(camera: ArcRotateCamera): void;
  112759. /**
  112760. * Detaches the behavior from its current arc rotate camera.
  112761. */
  112762. detach(): void;
  112763. private _animatables;
  112764. private _betaIsAnimating;
  112765. private _betaTransition;
  112766. private _radiusTransition;
  112767. private _vectorTransition;
  112768. /**
  112769. * Targets the given mesh and updates zoom level accordingly.
  112770. * @param mesh The mesh to target.
  112771. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112772. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112773. */
  112774. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112775. /**
  112776. * Targets the given mesh with its children and updates zoom level accordingly.
  112777. * @param mesh The mesh to target.
  112778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112780. */
  112781. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112782. /**
  112783. * Targets the given meshes with their children and updates zoom level accordingly.
  112784. * @param meshes The mesh to target.
  112785. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112786. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112787. */
  112788. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112789. /**
  112790. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112791. * @param minimumWorld Determines the smaller position of the bounding box extend
  112792. * @param maximumWorld Determines the bigger position of the bounding box extend
  112793. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112794. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112795. */
  112796. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112797. /**
  112798. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112799. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112800. * frustum width.
  112801. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112802. * to fully enclose the mesh in the viewing frustum.
  112803. */
  112804. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112805. /**
  112806. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112807. * is automatically returned to its default position (expected to be above ground plane).
  112808. */
  112809. private _maintainCameraAboveGround;
  112810. /**
  112811. * Returns the frustum slope based on the canvas ratio and camera FOV
  112812. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112813. */
  112814. private _getFrustumSlope;
  112815. /**
  112816. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112817. */
  112818. private _clearAnimationLocks;
  112819. /**
  112820. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112821. */
  112822. private _applyUserInteraction;
  112823. /**
  112824. * Stops and removes all animations that have been applied to the camera
  112825. */
  112826. stopAllAnimations(): void;
  112827. /**
  112828. * Gets a value indicating if the user is moving the camera
  112829. */
  112830. get isUserIsMoving(): boolean;
  112831. /**
  112832. * The camera can move all the way towards the mesh.
  112833. */
  112834. static IgnoreBoundsSizeMode: number;
  112835. /**
  112836. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112837. */
  112838. static FitFrustumSidesMode: number;
  112839. }
  112840. }
  112841. declare module BABYLON {
  112842. /**
  112843. * Base class for Camera Pointer Inputs.
  112844. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112845. * for example usage.
  112846. */
  112847. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112848. /**
  112849. * Defines the camera the input is attached to.
  112850. */
  112851. abstract camera: Camera;
  112852. /**
  112853. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112854. */
  112855. protected _altKey: boolean;
  112856. protected _ctrlKey: boolean;
  112857. protected _metaKey: boolean;
  112858. protected _shiftKey: boolean;
  112859. /**
  112860. * Which mouse buttons were pressed at time of last mouse event.
  112861. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112862. */
  112863. protected _buttonsPressed: number;
  112864. /**
  112865. * Defines the buttons associated with the input to handle camera move.
  112866. */
  112867. buttons: number[];
  112868. /**
  112869. * Attach the input controls to a specific dom element to get the input from.
  112870. * @param element Defines the element the controls should be listened from
  112871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112872. */
  112873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112874. /**
  112875. * Detach the current controls from the specified dom element.
  112876. * @param element Defines the element to stop listening the inputs from
  112877. */
  112878. detachControl(element: Nullable<HTMLElement>): void;
  112879. /**
  112880. * Gets the class name of the current input.
  112881. * @returns the class name
  112882. */
  112883. getClassName(): string;
  112884. /**
  112885. * Get the friendly name associated with the input class.
  112886. * @returns the input friendly name
  112887. */
  112888. getSimpleName(): string;
  112889. /**
  112890. * Called on pointer POINTERDOUBLETAP event.
  112891. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112892. */
  112893. protected onDoubleTap(type: string): void;
  112894. /**
  112895. * Called on pointer POINTERMOVE event if only a single touch is active.
  112896. * Override this method to provide functionality.
  112897. */
  112898. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112899. /**
  112900. * Called on pointer POINTERMOVE event if multiple touches are active.
  112901. * Override this method to provide functionality.
  112902. */
  112903. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112904. /**
  112905. * Called on JS contextmenu event.
  112906. * Override this method to provide functionality.
  112907. */
  112908. protected onContextMenu(evt: PointerEvent): void;
  112909. /**
  112910. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112911. * press.
  112912. * Override this method to provide functionality.
  112913. */
  112914. protected onButtonDown(evt: PointerEvent): void;
  112915. /**
  112916. * Called each time a new POINTERUP event occurs. Ie, for each button
  112917. * release.
  112918. * Override this method to provide functionality.
  112919. */
  112920. protected onButtonUp(evt: PointerEvent): void;
  112921. /**
  112922. * Called when window becomes inactive.
  112923. * Override this method to provide functionality.
  112924. */
  112925. protected onLostFocus(): void;
  112926. private _pointerInput;
  112927. private _observer;
  112928. private _onLostFocus;
  112929. private pointA;
  112930. private pointB;
  112931. }
  112932. }
  112933. declare module BABYLON {
  112934. /**
  112935. * Manage the pointers inputs to control an arc rotate camera.
  112936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112937. */
  112938. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112939. /**
  112940. * Defines the camera the input is attached to.
  112941. */
  112942. camera: ArcRotateCamera;
  112943. /**
  112944. * Gets the class name of the current input.
  112945. * @returns the class name
  112946. */
  112947. getClassName(): string;
  112948. /**
  112949. * Defines the buttons associated with the input to handle camera move.
  112950. */
  112951. buttons: number[];
  112952. /**
  112953. * Defines the pointer angular sensibility along the X axis or how fast is
  112954. * the camera rotating.
  112955. */
  112956. angularSensibilityX: number;
  112957. /**
  112958. * Defines the pointer angular sensibility along the Y axis or how fast is
  112959. * the camera rotating.
  112960. */
  112961. angularSensibilityY: number;
  112962. /**
  112963. * Defines the pointer pinch precision or how fast is the camera zooming.
  112964. */
  112965. pinchPrecision: number;
  112966. /**
  112967. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112968. * from 0.
  112969. * It defines the percentage of current camera.radius to use as delta when
  112970. * pinch zoom is used.
  112971. */
  112972. pinchDeltaPercentage: number;
  112973. /**
  112974. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112975. * that any object in the plane at the camera's target point will scale
  112976. * perfectly with finger motion.
  112977. * Overrides pinchDeltaPercentage and pinchPrecision.
  112978. */
  112979. useNaturalPinchZoom: boolean;
  112980. /**
  112981. * Defines the pointer panning sensibility or how fast is the camera moving.
  112982. */
  112983. panningSensibility: number;
  112984. /**
  112985. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112986. */
  112987. multiTouchPanning: boolean;
  112988. /**
  112989. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112990. * zoom (pinch) through multitouch.
  112991. */
  112992. multiTouchPanAndZoom: boolean;
  112993. /**
  112994. * Revers pinch action direction.
  112995. */
  112996. pinchInwards: boolean;
  112997. private _isPanClick;
  112998. private _twoFingerActivityCount;
  112999. private _isPinching;
  113000. /**
  113001. * Called on pointer POINTERMOVE event if only a single touch is active.
  113002. */
  113003. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113004. /**
  113005. * Called on pointer POINTERDOUBLETAP event.
  113006. */
  113007. protected onDoubleTap(type: string): void;
  113008. /**
  113009. * Called on pointer POINTERMOVE event if multiple touches are active.
  113010. */
  113011. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113012. /**
  113013. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  113014. * press.
  113015. */
  113016. protected onButtonDown(evt: PointerEvent): void;
  113017. /**
  113018. * Called each time a new POINTERUP event occurs. Ie, for each button
  113019. * release.
  113020. */
  113021. protected onButtonUp(evt: PointerEvent): void;
  113022. /**
  113023. * Called when window becomes inactive.
  113024. */
  113025. protected onLostFocus(): void;
  113026. }
  113027. }
  113028. declare module BABYLON {
  113029. /**
  113030. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113032. */
  113033. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113034. /**
  113035. * Defines the camera the input is attached to.
  113036. */
  113037. camera: ArcRotateCamera;
  113038. /**
  113039. * Defines the list of key codes associated with the up action (increase alpha)
  113040. */
  113041. keysUp: number[];
  113042. /**
  113043. * Defines the list of key codes associated with the down action (decrease alpha)
  113044. */
  113045. keysDown: number[];
  113046. /**
  113047. * Defines the list of key codes associated with the left action (increase beta)
  113048. */
  113049. keysLeft: number[];
  113050. /**
  113051. * Defines the list of key codes associated with the right action (decrease beta)
  113052. */
  113053. keysRight: number[];
  113054. /**
  113055. * Defines the list of key codes associated with the reset action.
  113056. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113057. */
  113058. keysReset: number[];
  113059. /**
  113060. * Defines the panning sensibility of the inputs.
  113061. * (How fast is the camera panning)
  113062. */
  113063. panningSensibility: number;
  113064. /**
  113065. * Defines the zooming sensibility of the inputs.
  113066. * (How fast is the camera zooming)
  113067. */
  113068. zoomingSensibility: number;
  113069. /**
  113070. * Defines whether maintaining the alt key down switch the movement mode from
  113071. * orientation to zoom.
  113072. */
  113073. useAltToZoom: boolean;
  113074. /**
  113075. * Rotation speed of the camera
  113076. */
  113077. angularSpeed: number;
  113078. private _keys;
  113079. private _ctrlPressed;
  113080. private _altPressed;
  113081. private _onCanvasBlurObserver;
  113082. private _onKeyboardObserver;
  113083. private _engine;
  113084. private _scene;
  113085. /**
  113086. * Attach the input controls to a specific dom element to get the input from.
  113087. * @param element Defines the element the controls should be listened from
  113088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113089. */
  113090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113091. /**
  113092. * Detach the current controls from the specified dom element.
  113093. * @param element Defines the element to stop listening the inputs from
  113094. */
  113095. detachControl(element: Nullable<HTMLElement>): void;
  113096. /**
  113097. * Update the current camera state depending on the inputs that have been used this frame.
  113098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113099. */
  113100. checkInputs(): void;
  113101. /**
  113102. * Gets the class name of the current intput.
  113103. * @returns the class name
  113104. */
  113105. getClassName(): string;
  113106. /**
  113107. * Get the friendly name associated with the input class.
  113108. * @returns the input friendly name
  113109. */
  113110. getSimpleName(): string;
  113111. }
  113112. }
  113113. declare module BABYLON {
  113114. /**
  113115. * Manage the mouse wheel inputs to control an arc rotate camera.
  113116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113117. */
  113118. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113119. /**
  113120. * Defines the camera the input is attached to.
  113121. */
  113122. camera: ArcRotateCamera;
  113123. /**
  113124. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113125. */
  113126. wheelPrecision: number;
  113127. /**
  113128. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113129. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113130. */
  113131. wheelDeltaPercentage: number;
  113132. private _wheel;
  113133. private _observer;
  113134. private computeDeltaFromMouseWheelLegacyEvent;
  113135. /**
  113136. * Attach the input controls to a specific dom element to get the input from.
  113137. * @param element Defines the element the controls should be listened from
  113138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113139. */
  113140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113141. /**
  113142. * Detach the current controls from the specified dom element.
  113143. * @param element Defines the element to stop listening the inputs from
  113144. */
  113145. detachControl(element: Nullable<HTMLElement>): void;
  113146. /**
  113147. * Gets the class name of the current intput.
  113148. * @returns the class name
  113149. */
  113150. getClassName(): string;
  113151. /**
  113152. * Get the friendly name associated with the input class.
  113153. * @returns the input friendly name
  113154. */
  113155. getSimpleName(): string;
  113156. }
  113157. }
  113158. declare module BABYLON {
  113159. /**
  113160. * Default Inputs manager for the ArcRotateCamera.
  113161. * It groups all the default supported inputs for ease of use.
  113162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113163. */
  113164. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113165. /**
  113166. * Instantiates a new ArcRotateCameraInputsManager.
  113167. * @param camera Defines the camera the inputs belong to
  113168. */
  113169. constructor(camera: ArcRotateCamera);
  113170. /**
  113171. * Add mouse wheel input support to the input manager.
  113172. * @returns the current input manager
  113173. */
  113174. addMouseWheel(): ArcRotateCameraInputsManager;
  113175. /**
  113176. * Add pointers input support to the input manager.
  113177. * @returns the current input manager
  113178. */
  113179. addPointers(): ArcRotateCameraInputsManager;
  113180. /**
  113181. * Add keyboard input support to the input manager.
  113182. * @returns the current input manager
  113183. */
  113184. addKeyboard(): ArcRotateCameraInputsManager;
  113185. }
  113186. }
  113187. declare module BABYLON {
  113188. /**
  113189. * This represents an orbital type of camera.
  113190. *
  113191. * 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.
  113192. * 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.
  113193. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113194. */
  113195. export class ArcRotateCamera extends TargetCamera {
  113196. /**
  113197. * Defines the rotation angle of the camera along the longitudinal axis.
  113198. */
  113199. alpha: number;
  113200. /**
  113201. * Defines the rotation angle of the camera along the latitudinal axis.
  113202. */
  113203. beta: number;
  113204. /**
  113205. * Defines the radius of the camera from it s target point.
  113206. */
  113207. radius: number;
  113208. protected _target: Vector3;
  113209. protected _targetHost: Nullable<AbstractMesh>;
  113210. /**
  113211. * Defines the target point of the camera.
  113212. * The camera looks towards it form the radius distance.
  113213. */
  113214. get target(): Vector3;
  113215. set target(value: Vector3);
  113216. /**
  113217. * Define the current local position of the camera in the scene
  113218. */
  113219. get position(): Vector3;
  113220. set position(newPosition: Vector3);
  113221. protected _upVector: Vector3;
  113222. protected _upToYMatrix: Matrix;
  113223. protected _YToUpMatrix: Matrix;
  113224. /**
  113225. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113226. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113227. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113228. */
  113229. set upVector(vec: Vector3);
  113230. get upVector(): Vector3;
  113231. /**
  113232. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113233. */
  113234. setMatUp(): void;
  113235. /**
  113236. * Current inertia value on the longitudinal axis.
  113237. * The bigger this number the longer it will take for the camera to stop.
  113238. */
  113239. inertialAlphaOffset: number;
  113240. /**
  113241. * Current inertia value on the latitudinal axis.
  113242. * The bigger this number the longer it will take for the camera to stop.
  113243. */
  113244. inertialBetaOffset: number;
  113245. /**
  113246. * Current inertia value on the radius axis.
  113247. * The bigger this number the longer it will take for the camera to stop.
  113248. */
  113249. inertialRadiusOffset: number;
  113250. /**
  113251. * Minimum allowed angle on the longitudinal axis.
  113252. * This can help limiting how the Camera is able to move in the scene.
  113253. */
  113254. lowerAlphaLimit: Nullable<number>;
  113255. /**
  113256. * Maximum allowed angle on the longitudinal axis.
  113257. * This can help limiting how the Camera is able to move in the scene.
  113258. */
  113259. upperAlphaLimit: Nullable<number>;
  113260. /**
  113261. * Minimum allowed angle on the latitudinal axis.
  113262. * This can help limiting how the Camera is able to move in the scene.
  113263. */
  113264. lowerBetaLimit: number;
  113265. /**
  113266. * Maximum allowed angle on the latitudinal axis.
  113267. * This can help limiting how the Camera is able to move in the scene.
  113268. */
  113269. upperBetaLimit: number;
  113270. /**
  113271. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113272. * This can help limiting how the Camera is able to move in the scene.
  113273. */
  113274. lowerRadiusLimit: Nullable<number>;
  113275. /**
  113276. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113277. * This can help limiting how the Camera is able to move in the scene.
  113278. */
  113279. upperRadiusLimit: Nullable<number>;
  113280. /**
  113281. * Defines the current inertia value used during panning of the camera along the X axis.
  113282. */
  113283. inertialPanningX: number;
  113284. /**
  113285. * Defines the current inertia value used during panning of the camera along the Y axis.
  113286. */
  113287. inertialPanningY: number;
  113288. /**
  113289. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113290. * Basically if your fingers moves away from more than this distance you will be considered
  113291. * in pinch mode.
  113292. */
  113293. pinchToPanMaxDistance: number;
  113294. /**
  113295. * Defines the maximum distance the camera can pan.
  113296. * This could help keeping the cammera always in your scene.
  113297. */
  113298. panningDistanceLimit: Nullable<number>;
  113299. /**
  113300. * Defines the target of the camera before paning.
  113301. */
  113302. panningOriginTarget: Vector3;
  113303. /**
  113304. * Defines the value of the inertia used during panning.
  113305. * 0 would mean stop inertia and one would mean no decelleration at all.
  113306. */
  113307. panningInertia: number;
  113308. /**
  113309. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113310. */
  113311. get angularSensibilityX(): number;
  113312. set angularSensibilityX(value: number);
  113313. /**
  113314. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113315. */
  113316. get angularSensibilityY(): number;
  113317. set angularSensibilityY(value: number);
  113318. /**
  113319. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113320. */
  113321. get pinchPrecision(): number;
  113322. set pinchPrecision(value: number);
  113323. /**
  113324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113325. * It will be used instead of pinchDeltaPrecision if different from 0.
  113326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113327. */
  113328. get pinchDeltaPercentage(): number;
  113329. set pinchDeltaPercentage(value: number);
  113330. /**
  113331. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113332. * and pinch delta percentage.
  113333. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113334. * that any object in the plane at the camera's target point will scale
  113335. * perfectly with finger motion.
  113336. */
  113337. get useNaturalPinchZoom(): boolean;
  113338. set useNaturalPinchZoom(value: boolean);
  113339. /**
  113340. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113341. */
  113342. get panningSensibility(): number;
  113343. set panningSensibility(value: number);
  113344. /**
  113345. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113346. */
  113347. get keysUp(): number[];
  113348. set keysUp(value: number[]);
  113349. /**
  113350. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113351. */
  113352. get keysDown(): number[];
  113353. set keysDown(value: number[]);
  113354. /**
  113355. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113356. */
  113357. get keysLeft(): number[];
  113358. set keysLeft(value: number[]);
  113359. /**
  113360. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113361. */
  113362. get keysRight(): number[];
  113363. set keysRight(value: number[]);
  113364. /**
  113365. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113366. */
  113367. get wheelPrecision(): number;
  113368. set wheelPrecision(value: number);
  113369. /**
  113370. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113371. * It will be used instead of pinchDeltaPrecision if different from 0.
  113372. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113373. */
  113374. get wheelDeltaPercentage(): number;
  113375. set wheelDeltaPercentage(value: number);
  113376. /**
  113377. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113378. */
  113379. zoomOnFactor: number;
  113380. /**
  113381. * Defines a screen offset for the camera position.
  113382. */
  113383. targetScreenOffset: Vector2;
  113384. /**
  113385. * Allows the camera to be completely reversed.
  113386. * If false the camera can not arrive upside down.
  113387. */
  113388. allowUpsideDown: boolean;
  113389. /**
  113390. * Define if double tap/click is used to restore the previously saved state of the camera.
  113391. */
  113392. useInputToRestoreState: boolean;
  113393. /** @hidden */
  113394. _viewMatrix: Matrix;
  113395. /** @hidden */
  113396. _useCtrlForPanning: boolean;
  113397. /** @hidden */
  113398. _panningMouseButton: number;
  113399. /**
  113400. * Defines the input associated to the camera.
  113401. */
  113402. inputs: ArcRotateCameraInputsManager;
  113403. /** @hidden */
  113404. _reset: () => void;
  113405. /**
  113406. * Defines the allowed panning axis.
  113407. */
  113408. panningAxis: Vector3;
  113409. protected _localDirection: Vector3;
  113410. protected _transformedDirection: Vector3;
  113411. private _bouncingBehavior;
  113412. /**
  113413. * Gets the bouncing behavior of the camera if it has been enabled.
  113414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113415. */
  113416. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113417. /**
  113418. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113420. */
  113421. get useBouncingBehavior(): boolean;
  113422. set useBouncingBehavior(value: boolean);
  113423. private _framingBehavior;
  113424. /**
  113425. * Gets the framing behavior of the camera if it has been enabled.
  113426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113427. */
  113428. get framingBehavior(): Nullable<FramingBehavior>;
  113429. /**
  113430. * Defines if the framing behavior of the camera is enabled on the camera.
  113431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113432. */
  113433. get useFramingBehavior(): boolean;
  113434. set useFramingBehavior(value: boolean);
  113435. private _autoRotationBehavior;
  113436. /**
  113437. * Gets the auto rotation behavior of the camera if it has been enabled.
  113438. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113439. */
  113440. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113441. /**
  113442. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113443. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113444. */
  113445. get useAutoRotationBehavior(): boolean;
  113446. set useAutoRotationBehavior(value: boolean);
  113447. /**
  113448. * Observable triggered when the mesh target has been changed on the camera.
  113449. */
  113450. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113451. /**
  113452. * Event raised when the camera is colliding with a mesh.
  113453. */
  113454. onCollide: (collidedMesh: AbstractMesh) => void;
  113455. /**
  113456. * Defines whether the camera should check collision with the objects oh the scene.
  113457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113458. */
  113459. checkCollisions: boolean;
  113460. /**
  113461. * Defines the collision radius of the camera.
  113462. * This simulates a sphere around the camera.
  113463. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113464. */
  113465. collisionRadius: Vector3;
  113466. protected _collider: Collider;
  113467. protected _previousPosition: Vector3;
  113468. protected _collisionVelocity: Vector3;
  113469. protected _newPosition: Vector3;
  113470. protected _previousAlpha: number;
  113471. protected _previousBeta: number;
  113472. protected _previousRadius: number;
  113473. protected _collisionTriggered: boolean;
  113474. protected _targetBoundingCenter: Nullable<Vector3>;
  113475. private _computationVector;
  113476. /**
  113477. * Instantiates a new ArcRotateCamera in a given scene
  113478. * @param name Defines the name of the camera
  113479. * @param alpha Defines the camera rotation along the logitudinal axis
  113480. * @param beta Defines the camera rotation along the latitudinal axis
  113481. * @param radius Defines the camera distance from its target
  113482. * @param target Defines the camera target
  113483. * @param scene Defines the scene the camera belongs to
  113484. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113485. */
  113486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113487. /** @hidden */
  113488. _initCache(): void;
  113489. /** @hidden */
  113490. _updateCache(ignoreParentClass?: boolean): void;
  113491. protected _getTargetPosition(): Vector3;
  113492. private _storedAlpha;
  113493. private _storedBeta;
  113494. private _storedRadius;
  113495. private _storedTarget;
  113496. private _storedTargetScreenOffset;
  113497. /**
  113498. * Stores the current state of the camera (alpha, beta, radius and target)
  113499. * @returns the camera itself
  113500. */
  113501. storeState(): Camera;
  113502. /**
  113503. * @hidden
  113504. * Restored camera state. You must call storeState() first
  113505. */
  113506. _restoreStateValues(): boolean;
  113507. /** @hidden */
  113508. _isSynchronizedViewMatrix(): boolean;
  113509. /**
  113510. * Attached controls to the current camera.
  113511. * @param element Defines the element the controls should be listened from
  113512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113513. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113514. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113515. */
  113516. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113517. /**
  113518. * Detach the current controls from the camera.
  113519. * The camera will stop reacting to inputs.
  113520. * @param element Defines the element to stop listening the inputs from
  113521. */
  113522. detachControl(element: HTMLElement): void;
  113523. /** @hidden */
  113524. _checkInputs(): void;
  113525. protected _checkLimits(): void;
  113526. /**
  113527. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113528. */
  113529. rebuildAnglesAndRadius(): void;
  113530. /**
  113531. * Use a position to define the current camera related information like alpha, beta and radius
  113532. * @param position Defines the position to set the camera at
  113533. */
  113534. setPosition(position: Vector3): void;
  113535. /**
  113536. * Defines the target the camera should look at.
  113537. * This will automatically adapt alpha beta and radius to fit within the new target.
  113538. * @param target Defines the new target as a Vector or a mesh
  113539. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113540. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113541. */
  113542. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113543. /** @hidden */
  113544. _getViewMatrix(): Matrix;
  113545. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113546. /**
  113547. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113548. * @param meshes Defines the mesh to zoom on
  113549. * @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)
  113550. */
  113551. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113552. /**
  113553. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113554. * The target will be changed but the radius
  113555. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113556. * @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)
  113557. */
  113558. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113559. min: Vector3;
  113560. max: Vector3;
  113561. distance: number;
  113562. }, doNotUpdateMaxZ?: boolean): void;
  113563. /**
  113564. * @override
  113565. * Override Camera.createRigCamera
  113566. */
  113567. createRigCamera(name: string, cameraIndex: number): Camera;
  113568. /**
  113569. * @hidden
  113570. * @override
  113571. * Override Camera._updateRigCameras
  113572. */
  113573. _updateRigCameras(): void;
  113574. /**
  113575. * Destroy the camera and release the current resources hold by it.
  113576. */
  113577. dispose(): void;
  113578. /**
  113579. * Gets the current object class name.
  113580. * @return the class name
  113581. */
  113582. getClassName(): string;
  113583. }
  113584. }
  113585. declare module BABYLON {
  113586. /**
  113587. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113589. */
  113590. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113591. /**
  113592. * Gets the name of the behavior.
  113593. */
  113594. get name(): string;
  113595. private _zoomStopsAnimation;
  113596. private _idleRotationSpeed;
  113597. private _idleRotationWaitTime;
  113598. private _idleRotationSpinupTime;
  113599. /**
  113600. * Sets the flag that indicates if user zooming should stop animation.
  113601. */
  113602. set zoomStopsAnimation(flag: boolean);
  113603. /**
  113604. * Gets the flag that indicates if user zooming should stop animation.
  113605. */
  113606. get zoomStopsAnimation(): boolean;
  113607. /**
  113608. * Sets the default speed at which the camera rotates around the model.
  113609. */
  113610. set idleRotationSpeed(speed: number);
  113611. /**
  113612. * Gets the default speed at which the camera rotates around the model.
  113613. */
  113614. get idleRotationSpeed(): number;
  113615. /**
  113616. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113617. */
  113618. set idleRotationWaitTime(time: number);
  113619. /**
  113620. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113621. */
  113622. get idleRotationWaitTime(): number;
  113623. /**
  113624. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113625. */
  113626. set idleRotationSpinupTime(time: number);
  113627. /**
  113628. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113629. */
  113630. get idleRotationSpinupTime(): number;
  113631. /**
  113632. * Gets a value indicating if the camera is currently rotating because of this behavior
  113633. */
  113634. get rotationInProgress(): boolean;
  113635. private _onPrePointerObservableObserver;
  113636. private _onAfterCheckInputsObserver;
  113637. private _attachedCamera;
  113638. private _isPointerDown;
  113639. private _lastFrameTime;
  113640. private _lastInteractionTime;
  113641. private _cameraRotationSpeed;
  113642. /**
  113643. * Initializes the behavior.
  113644. */
  113645. init(): void;
  113646. /**
  113647. * Attaches the behavior to its arc rotate camera.
  113648. * @param camera Defines the camera to attach the behavior to
  113649. */
  113650. attach(camera: ArcRotateCamera): void;
  113651. /**
  113652. * Detaches the behavior from its current arc rotate camera.
  113653. */
  113654. detach(): void;
  113655. /**
  113656. * Returns true if user is scrolling.
  113657. * @return true if user is scrolling.
  113658. */
  113659. private _userIsZooming;
  113660. private _lastFrameRadius;
  113661. private _shouldAnimationStopForInteraction;
  113662. /**
  113663. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113664. */
  113665. private _applyUserInteraction;
  113666. private _userIsMoving;
  113667. }
  113668. }
  113669. declare module BABYLON {
  113670. /**
  113671. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113672. */
  113673. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113674. private ui;
  113675. /**
  113676. * The name of the behavior
  113677. */
  113678. name: string;
  113679. /**
  113680. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113681. */
  113682. distanceAwayFromFace: number;
  113683. /**
  113684. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113685. */
  113686. distanceAwayFromBottomOfFace: number;
  113687. private _faceVectors;
  113688. private _target;
  113689. private _scene;
  113690. private _onRenderObserver;
  113691. private _tmpMatrix;
  113692. private _tmpVector;
  113693. /**
  113694. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113695. * @param ui The transform node that should be attched to the mesh
  113696. */
  113697. constructor(ui: TransformNode);
  113698. /**
  113699. * Initializes the behavior
  113700. */
  113701. init(): void;
  113702. private _closestFace;
  113703. private _zeroVector;
  113704. private _lookAtTmpMatrix;
  113705. private _lookAtToRef;
  113706. /**
  113707. * Attaches the AttachToBoxBehavior to the passed in mesh
  113708. * @param target The mesh that the specified node will be attached to
  113709. */
  113710. attach(target: Mesh): void;
  113711. /**
  113712. * Detaches the behavior from the mesh
  113713. */
  113714. detach(): void;
  113715. }
  113716. }
  113717. declare module BABYLON {
  113718. /**
  113719. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113720. */
  113721. export class FadeInOutBehavior implements Behavior<Mesh> {
  113722. /**
  113723. * Time in milliseconds to delay before fading in (Default: 0)
  113724. */
  113725. delay: number;
  113726. /**
  113727. * Time in milliseconds for the mesh to fade in (Default: 300)
  113728. */
  113729. fadeInTime: number;
  113730. private _millisecondsPerFrame;
  113731. private _hovered;
  113732. private _hoverValue;
  113733. private _ownerNode;
  113734. /**
  113735. * Instatiates the FadeInOutBehavior
  113736. */
  113737. constructor();
  113738. /**
  113739. * The name of the behavior
  113740. */
  113741. get name(): string;
  113742. /**
  113743. * Initializes the behavior
  113744. */
  113745. init(): void;
  113746. /**
  113747. * Attaches the fade behavior on the passed in mesh
  113748. * @param ownerNode The mesh that will be faded in/out once attached
  113749. */
  113750. attach(ownerNode: Mesh): void;
  113751. /**
  113752. * Detaches the behavior from the mesh
  113753. */
  113754. detach(): void;
  113755. /**
  113756. * Triggers the mesh to begin fading in or out
  113757. * @param value if the object should fade in or out (true to fade in)
  113758. */
  113759. fadeIn(value: boolean): void;
  113760. private _update;
  113761. private _setAllVisibility;
  113762. }
  113763. }
  113764. declare module BABYLON {
  113765. /**
  113766. * Class containing a set of static utilities functions for managing Pivots
  113767. * @hidden
  113768. */
  113769. export class PivotTools {
  113770. private static _PivotCached;
  113771. private static _OldPivotPoint;
  113772. private static _PivotTranslation;
  113773. private static _PivotTmpVector;
  113774. /** @hidden */
  113775. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113776. /** @hidden */
  113777. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113778. }
  113779. }
  113780. declare module BABYLON {
  113781. /**
  113782. * Class containing static functions to help procedurally build meshes
  113783. */
  113784. export class PlaneBuilder {
  113785. /**
  113786. * Creates a plane mesh
  113787. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113788. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113789. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113793. * @param name defines the name of the mesh
  113794. * @param options defines the options used to create the mesh
  113795. * @param scene defines the hosting scene
  113796. * @returns the plane mesh
  113797. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113798. */
  113799. static CreatePlane(name: string, options: {
  113800. size?: number;
  113801. width?: number;
  113802. height?: number;
  113803. sideOrientation?: number;
  113804. frontUVs?: Vector4;
  113805. backUVs?: Vector4;
  113806. updatable?: boolean;
  113807. sourcePlane?: Plane;
  113808. }, scene?: Nullable<Scene>): Mesh;
  113809. }
  113810. }
  113811. declare module BABYLON {
  113812. /**
  113813. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113814. */
  113815. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113816. private static _AnyMouseID;
  113817. /**
  113818. * Abstract mesh the behavior is set on
  113819. */
  113820. attachedNode: AbstractMesh;
  113821. private _dragPlane;
  113822. private _scene;
  113823. private _pointerObserver;
  113824. private _beforeRenderObserver;
  113825. private static _planeScene;
  113826. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113827. /**
  113828. * 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)
  113829. */
  113830. maxDragAngle: number;
  113831. /**
  113832. * @hidden
  113833. */
  113834. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113835. /**
  113836. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113837. */
  113838. currentDraggingPointerID: number;
  113839. /**
  113840. * The last position where the pointer hit the drag plane in world space
  113841. */
  113842. lastDragPosition: Vector3;
  113843. /**
  113844. * If the behavior is currently in a dragging state
  113845. */
  113846. dragging: boolean;
  113847. /**
  113848. * 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)
  113849. */
  113850. dragDeltaRatio: number;
  113851. /**
  113852. * If the drag plane orientation should be updated during the dragging (Default: true)
  113853. */
  113854. updateDragPlane: boolean;
  113855. private _debugMode;
  113856. private _moving;
  113857. /**
  113858. * Fires each time the attached mesh is dragged with the pointer
  113859. * * delta between last drag position and current drag position in world space
  113860. * * dragDistance along the drag axis
  113861. * * dragPlaneNormal normal of the current drag plane used during the drag
  113862. * * dragPlanePoint in world space where the drag intersects the drag plane
  113863. */
  113864. onDragObservable: Observable<{
  113865. delta: Vector3;
  113866. dragPlanePoint: Vector3;
  113867. dragPlaneNormal: Vector3;
  113868. dragDistance: number;
  113869. pointerId: number;
  113870. }>;
  113871. /**
  113872. * Fires each time a drag begins (eg. mouse down on mesh)
  113873. */
  113874. onDragStartObservable: Observable<{
  113875. dragPlanePoint: Vector3;
  113876. pointerId: number;
  113877. }>;
  113878. /**
  113879. * Fires each time a drag ends (eg. mouse release after drag)
  113880. */
  113881. onDragEndObservable: Observable<{
  113882. dragPlanePoint: Vector3;
  113883. pointerId: number;
  113884. }>;
  113885. /**
  113886. * If the attached mesh should be moved when dragged
  113887. */
  113888. moveAttached: boolean;
  113889. /**
  113890. * If the drag behavior will react to drag events (Default: true)
  113891. */
  113892. enabled: boolean;
  113893. /**
  113894. * If pointer events should start and release the drag (Default: true)
  113895. */
  113896. startAndReleaseDragOnPointerEvents: boolean;
  113897. /**
  113898. * If camera controls should be detached during the drag
  113899. */
  113900. detachCameraControls: boolean;
  113901. /**
  113902. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113903. */
  113904. useObjectOrientationForDragging: boolean;
  113905. private _options;
  113906. /**
  113907. * Gets the options used by the behavior
  113908. */
  113909. get options(): {
  113910. dragAxis?: Vector3;
  113911. dragPlaneNormal?: Vector3;
  113912. };
  113913. /**
  113914. * Sets the options used by the behavior
  113915. */
  113916. set options(options: {
  113917. dragAxis?: Vector3;
  113918. dragPlaneNormal?: Vector3;
  113919. });
  113920. /**
  113921. * Creates a pointer drag behavior that can be attached to a mesh
  113922. * @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)
  113923. */
  113924. constructor(options?: {
  113925. dragAxis?: Vector3;
  113926. dragPlaneNormal?: Vector3;
  113927. });
  113928. /**
  113929. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113930. */
  113931. validateDrag: (targetPosition: Vector3) => boolean;
  113932. /**
  113933. * The name of the behavior
  113934. */
  113935. get name(): string;
  113936. /**
  113937. * Initializes the behavior
  113938. */
  113939. init(): void;
  113940. private _tmpVector;
  113941. private _alternatePickedPoint;
  113942. private _worldDragAxis;
  113943. private _targetPosition;
  113944. private _attachedElement;
  113945. /**
  113946. * Attaches the drag behavior the passed in mesh
  113947. * @param ownerNode The mesh that will be dragged around once attached
  113948. * @param predicate Predicate to use for pick filtering
  113949. */
  113950. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113951. /**
  113952. * Force relase the drag action by code.
  113953. */
  113954. releaseDrag(): void;
  113955. private _startDragRay;
  113956. private _lastPointerRay;
  113957. /**
  113958. * Simulates the start of a pointer drag event on the behavior
  113959. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113960. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113961. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113962. */
  113963. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113964. private _startDrag;
  113965. private _dragDelta;
  113966. private _moveDrag;
  113967. private _pickWithRayOnDragPlane;
  113968. private _pointA;
  113969. private _pointB;
  113970. private _pointC;
  113971. private _lineA;
  113972. private _lineB;
  113973. private _localAxis;
  113974. private _lookAt;
  113975. private _updateDragPlanePosition;
  113976. /**
  113977. * Detaches the behavior from the mesh
  113978. */
  113979. detach(): void;
  113980. }
  113981. }
  113982. declare module BABYLON {
  113983. /**
  113984. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113985. */
  113986. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113987. private _dragBehaviorA;
  113988. private _dragBehaviorB;
  113989. private _startDistance;
  113990. private _initialScale;
  113991. private _targetScale;
  113992. private _ownerNode;
  113993. private _sceneRenderObserver;
  113994. /**
  113995. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113996. */
  113997. constructor();
  113998. /**
  113999. * The name of the behavior
  114000. */
  114001. get name(): string;
  114002. /**
  114003. * Initializes the behavior
  114004. */
  114005. init(): void;
  114006. private _getCurrentDistance;
  114007. /**
  114008. * Attaches the scale behavior the passed in mesh
  114009. * @param ownerNode The mesh that will be scaled around once attached
  114010. */
  114011. attach(ownerNode: Mesh): void;
  114012. /**
  114013. * Detaches the behavior from the mesh
  114014. */
  114015. detach(): void;
  114016. }
  114017. }
  114018. declare module BABYLON {
  114019. /**
  114020. * 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
  114021. */
  114022. export class SixDofDragBehavior implements Behavior<Mesh> {
  114023. private static _virtualScene;
  114024. private _ownerNode;
  114025. private _sceneRenderObserver;
  114026. private _scene;
  114027. private _targetPosition;
  114028. private _virtualOriginMesh;
  114029. private _virtualDragMesh;
  114030. private _pointerObserver;
  114031. private _moving;
  114032. private _startingOrientation;
  114033. private _attachedElement;
  114034. /**
  114035. * 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)
  114036. */
  114037. private zDragFactor;
  114038. /**
  114039. * If the object should rotate to face the drag origin
  114040. */
  114041. rotateDraggedObject: boolean;
  114042. /**
  114043. * If the behavior is currently in a dragging state
  114044. */
  114045. dragging: boolean;
  114046. /**
  114047. * 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)
  114048. */
  114049. dragDeltaRatio: number;
  114050. /**
  114051. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114052. */
  114053. currentDraggingPointerID: number;
  114054. /**
  114055. * If camera controls should be detached during the drag
  114056. */
  114057. detachCameraControls: boolean;
  114058. /**
  114059. * Fires each time a drag starts
  114060. */
  114061. onDragStartObservable: Observable<{}>;
  114062. /**
  114063. * Fires each time a drag ends (eg. mouse release after drag)
  114064. */
  114065. onDragEndObservable: Observable<{}>;
  114066. /**
  114067. * 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
  114068. */
  114069. constructor();
  114070. /**
  114071. * The name of the behavior
  114072. */
  114073. get name(): string;
  114074. /**
  114075. * Initializes the behavior
  114076. */
  114077. init(): void;
  114078. /**
  114079. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114080. */
  114081. private get _pointerCamera();
  114082. /**
  114083. * Attaches the scale behavior the passed in mesh
  114084. * @param ownerNode The mesh that will be scaled around once attached
  114085. */
  114086. attach(ownerNode: Mesh): void;
  114087. /**
  114088. * Detaches the behavior from the mesh
  114089. */
  114090. detach(): void;
  114091. }
  114092. }
  114093. declare module BABYLON {
  114094. /**
  114095. * Class used to apply inverse kinematics to bones
  114096. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114097. */
  114098. export class BoneIKController {
  114099. private static _tmpVecs;
  114100. private static _tmpQuat;
  114101. private static _tmpMats;
  114102. /**
  114103. * Gets or sets the target mesh
  114104. */
  114105. targetMesh: AbstractMesh;
  114106. /** Gets or sets the mesh used as pole */
  114107. poleTargetMesh: AbstractMesh;
  114108. /**
  114109. * Gets or sets the bone used as pole
  114110. */
  114111. poleTargetBone: Nullable<Bone>;
  114112. /**
  114113. * Gets or sets the target position
  114114. */
  114115. targetPosition: Vector3;
  114116. /**
  114117. * Gets or sets the pole target position
  114118. */
  114119. poleTargetPosition: Vector3;
  114120. /**
  114121. * Gets or sets the pole target local offset
  114122. */
  114123. poleTargetLocalOffset: Vector3;
  114124. /**
  114125. * Gets or sets the pole angle
  114126. */
  114127. poleAngle: number;
  114128. /**
  114129. * Gets or sets the mesh associated with the controller
  114130. */
  114131. mesh: AbstractMesh;
  114132. /**
  114133. * 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)
  114134. */
  114135. slerpAmount: number;
  114136. private _bone1Quat;
  114137. private _bone1Mat;
  114138. private _bone2Ang;
  114139. private _bone1;
  114140. private _bone2;
  114141. private _bone1Length;
  114142. private _bone2Length;
  114143. private _maxAngle;
  114144. private _maxReach;
  114145. private _rightHandedSystem;
  114146. private _bendAxis;
  114147. private _slerping;
  114148. private _adjustRoll;
  114149. /**
  114150. * Gets or sets maximum allowed angle
  114151. */
  114152. get maxAngle(): number;
  114153. set maxAngle(value: number);
  114154. /**
  114155. * Creates a new BoneIKController
  114156. * @param mesh defines the mesh to control
  114157. * @param bone defines the bone to control
  114158. * @param options defines options to set up the controller
  114159. */
  114160. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114161. targetMesh?: AbstractMesh;
  114162. poleTargetMesh?: AbstractMesh;
  114163. poleTargetBone?: Bone;
  114164. poleTargetLocalOffset?: Vector3;
  114165. poleAngle?: number;
  114166. bendAxis?: Vector3;
  114167. maxAngle?: number;
  114168. slerpAmount?: number;
  114169. });
  114170. private _setMaxAngle;
  114171. /**
  114172. * Force the controller to update the bones
  114173. */
  114174. update(): void;
  114175. }
  114176. }
  114177. declare module BABYLON {
  114178. /**
  114179. * Class used to make a bone look toward a point in space
  114180. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114181. */
  114182. export class BoneLookController {
  114183. private static _tmpVecs;
  114184. private static _tmpQuat;
  114185. private static _tmpMats;
  114186. /**
  114187. * The target Vector3 that the bone will look at
  114188. */
  114189. target: Vector3;
  114190. /**
  114191. * The mesh that the bone is attached to
  114192. */
  114193. mesh: AbstractMesh;
  114194. /**
  114195. * The bone that will be looking to the target
  114196. */
  114197. bone: Bone;
  114198. /**
  114199. * The up axis of the coordinate system that is used when the bone is rotated
  114200. */
  114201. upAxis: Vector3;
  114202. /**
  114203. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114204. */
  114205. upAxisSpace: Space;
  114206. /**
  114207. * Used to make an adjustment to the yaw of the bone
  114208. */
  114209. adjustYaw: number;
  114210. /**
  114211. * Used to make an adjustment to the pitch of the bone
  114212. */
  114213. adjustPitch: number;
  114214. /**
  114215. * Used to make an adjustment to the roll of the bone
  114216. */
  114217. adjustRoll: number;
  114218. /**
  114219. * 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)
  114220. */
  114221. slerpAmount: number;
  114222. private _minYaw;
  114223. private _maxYaw;
  114224. private _minPitch;
  114225. private _maxPitch;
  114226. private _minYawSin;
  114227. private _minYawCos;
  114228. private _maxYawSin;
  114229. private _maxYawCos;
  114230. private _midYawConstraint;
  114231. private _minPitchTan;
  114232. private _maxPitchTan;
  114233. private _boneQuat;
  114234. private _slerping;
  114235. private _transformYawPitch;
  114236. private _transformYawPitchInv;
  114237. private _firstFrameSkipped;
  114238. private _yawRange;
  114239. private _fowardAxis;
  114240. /**
  114241. * Gets or sets the minimum yaw angle that the bone can look to
  114242. */
  114243. get minYaw(): number;
  114244. set minYaw(value: number);
  114245. /**
  114246. * Gets or sets the maximum yaw angle that the bone can look to
  114247. */
  114248. get maxYaw(): number;
  114249. set maxYaw(value: number);
  114250. /**
  114251. * Gets or sets the minimum pitch angle that the bone can look to
  114252. */
  114253. get minPitch(): number;
  114254. set minPitch(value: number);
  114255. /**
  114256. * Gets or sets the maximum pitch angle that the bone can look to
  114257. */
  114258. get maxPitch(): number;
  114259. set maxPitch(value: number);
  114260. /**
  114261. * Create a BoneLookController
  114262. * @param mesh the mesh that the bone belongs to
  114263. * @param bone the bone that will be looking to the target
  114264. * @param target the target Vector3 to look at
  114265. * @param options optional settings:
  114266. * * maxYaw: the maximum angle the bone will yaw to
  114267. * * minYaw: the minimum angle the bone will yaw to
  114268. * * maxPitch: the maximum angle the bone will pitch to
  114269. * * minPitch: the minimum angle the bone will yaw to
  114270. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114271. * * upAxis: the up axis of the coordinate system
  114272. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114273. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114274. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114275. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114276. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114277. * * adjustRoll: used to make an adjustment to the roll of the bone
  114278. **/
  114279. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114280. maxYaw?: number;
  114281. minYaw?: number;
  114282. maxPitch?: number;
  114283. minPitch?: number;
  114284. slerpAmount?: number;
  114285. upAxis?: Vector3;
  114286. upAxisSpace?: Space;
  114287. yawAxis?: Vector3;
  114288. pitchAxis?: Vector3;
  114289. adjustYaw?: number;
  114290. adjustPitch?: number;
  114291. adjustRoll?: number;
  114292. });
  114293. /**
  114294. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114295. */
  114296. update(): void;
  114297. private _getAngleDiff;
  114298. private _getAngleBetween;
  114299. private _isAngleBetween;
  114300. }
  114301. }
  114302. declare module BABYLON {
  114303. /**
  114304. * Manage the gamepad inputs to control an arc rotate camera.
  114305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114306. */
  114307. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114308. /**
  114309. * Defines the camera the input is attached to.
  114310. */
  114311. camera: ArcRotateCamera;
  114312. /**
  114313. * Defines the gamepad the input is gathering event from.
  114314. */
  114315. gamepad: Nullable<Gamepad>;
  114316. /**
  114317. * Defines the gamepad rotation sensiblity.
  114318. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114319. */
  114320. gamepadRotationSensibility: number;
  114321. /**
  114322. * Defines the gamepad move sensiblity.
  114323. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114324. */
  114325. gamepadMoveSensibility: number;
  114326. private _yAxisScale;
  114327. /**
  114328. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114329. */
  114330. get invertYAxis(): boolean;
  114331. set invertYAxis(value: boolean);
  114332. private _onGamepadConnectedObserver;
  114333. private _onGamepadDisconnectedObserver;
  114334. /**
  114335. * Attach the input controls to a specific dom element to get the input from.
  114336. * @param element Defines the element the controls should be listened from
  114337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114338. */
  114339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114340. /**
  114341. * Detach the current controls from the specified dom element.
  114342. * @param element Defines the element to stop listening the inputs from
  114343. */
  114344. detachControl(element: Nullable<HTMLElement>): void;
  114345. /**
  114346. * Update the current camera state depending on the inputs that have been used this frame.
  114347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114348. */
  114349. checkInputs(): void;
  114350. /**
  114351. * Gets the class name of the current intput.
  114352. * @returns the class name
  114353. */
  114354. getClassName(): string;
  114355. /**
  114356. * Get the friendly name associated with the input class.
  114357. * @returns the input friendly name
  114358. */
  114359. getSimpleName(): string;
  114360. }
  114361. }
  114362. declare module BABYLON {
  114363. interface ArcRotateCameraInputsManager {
  114364. /**
  114365. * Add orientation input support to the input manager.
  114366. * @returns the current input manager
  114367. */
  114368. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114369. }
  114370. /**
  114371. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114373. */
  114374. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114375. /**
  114376. * Defines the camera the input is attached to.
  114377. */
  114378. camera: ArcRotateCamera;
  114379. /**
  114380. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114381. */
  114382. alphaCorrection: number;
  114383. /**
  114384. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114385. */
  114386. gammaCorrection: number;
  114387. private _alpha;
  114388. private _gamma;
  114389. private _dirty;
  114390. private _deviceOrientationHandler;
  114391. /**
  114392. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114393. */
  114394. constructor();
  114395. /**
  114396. * Attach the input controls to a specific dom element to get the input from.
  114397. * @param element Defines the element the controls should be listened from
  114398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114399. */
  114400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114401. /** @hidden */
  114402. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114403. /**
  114404. * Update the current camera state depending on the inputs that have been used this frame.
  114405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114406. */
  114407. checkInputs(): void;
  114408. /**
  114409. * Detach the current controls from the specified dom element.
  114410. * @param element Defines the element to stop listening the inputs from
  114411. */
  114412. detachControl(element: Nullable<HTMLElement>): void;
  114413. /**
  114414. * Gets the class name of the current intput.
  114415. * @returns the class name
  114416. */
  114417. getClassName(): string;
  114418. /**
  114419. * Get the friendly name associated with the input class.
  114420. * @returns the input friendly name
  114421. */
  114422. getSimpleName(): string;
  114423. }
  114424. }
  114425. declare module BABYLON {
  114426. /**
  114427. * Listen to mouse events to control the camera.
  114428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114429. */
  114430. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114431. /**
  114432. * Defines the camera the input is attached to.
  114433. */
  114434. camera: FlyCamera;
  114435. /**
  114436. * Defines if touch is enabled. (Default is true.)
  114437. */
  114438. touchEnabled: boolean;
  114439. /**
  114440. * Defines the buttons associated with the input to handle camera rotation.
  114441. */
  114442. buttons: number[];
  114443. /**
  114444. * Assign buttons for Yaw control.
  114445. */
  114446. buttonsYaw: number[];
  114447. /**
  114448. * Assign buttons for Pitch control.
  114449. */
  114450. buttonsPitch: number[];
  114451. /**
  114452. * Assign buttons for Roll control.
  114453. */
  114454. buttonsRoll: number[];
  114455. /**
  114456. * Detect if any button is being pressed while mouse is moved.
  114457. * -1 = Mouse locked.
  114458. * 0 = Left button.
  114459. * 1 = Middle Button.
  114460. * 2 = Right Button.
  114461. */
  114462. activeButton: number;
  114463. /**
  114464. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114465. * Higher values reduce its sensitivity.
  114466. */
  114467. angularSensibility: number;
  114468. private _mousemoveCallback;
  114469. private _observer;
  114470. private _rollObserver;
  114471. private previousPosition;
  114472. private noPreventDefault;
  114473. private element;
  114474. /**
  114475. * Listen to mouse events to control the camera.
  114476. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114478. */
  114479. constructor(touchEnabled?: boolean);
  114480. /**
  114481. * Attach the mouse control to the HTML DOM element.
  114482. * @param element Defines the element that listens to the input events.
  114483. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114484. */
  114485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114486. /**
  114487. * Detach the current controls from the specified dom element.
  114488. * @param element Defines the element to stop listening the inputs from
  114489. */
  114490. detachControl(element: Nullable<HTMLElement>): void;
  114491. /**
  114492. * Gets the class name of the current input.
  114493. * @returns the class name.
  114494. */
  114495. getClassName(): string;
  114496. /**
  114497. * Get the friendly name associated with the input class.
  114498. * @returns the input's friendly name.
  114499. */
  114500. getSimpleName(): string;
  114501. private _pointerInput;
  114502. private _onMouseMove;
  114503. /**
  114504. * Rotate camera by mouse offset.
  114505. */
  114506. private rotateCamera;
  114507. }
  114508. }
  114509. declare module BABYLON {
  114510. /**
  114511. * Default Inputs manager for the FlyCamera.
  114512. * It groups all the default supported inputs for ease of use.
  114513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114514. */
  114515. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114516. /**
  114517. * Instantiates a new FlyCameraInputsManager.
  114518. * @param camera Defines the camera the inputs belong to.
  114519. */
  114520. constructor(camera: FlyCamera);
  114521. /**
  114522. * Add keyboard input support to the input manager.
  114523. * @returns the new FlyCameraKeyboardMoveInput().
  114524. */
  114525. addKeyboard(): FlyCameraInputsManager;
  114526. /**
  114527. * Add mouse input support to the input manager.
  114528. * @param touchEnabled Enable touch screen support.
  114529. * @returns the new FlyCameraMouseInput().
  114530. */
  114531. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114532. }
  114533. }
  114534. declare module BABYLON {
  114535. /**
  114536. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114537. * such as in a 3D Space Shooter or a Flight Simulator.
  114538. */
  114539. export class FlyCamera extends TargetCamera {
  114540. /**
  114541. * Define the collision ellipsoid of the camera.
  114542. * This is helpful for simulating a camera body, like a player's body.
  114543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114544. */
  114545. ellipsoid: Vector3;
  114546. /**
  114547. * Define an offset for the position of the ellipsoid around the camera.
  114548. * This can be helpful if the camera is attached away from the player's body center,
  114549. * such as at its head.
  114550. */
  114551. ellipsoidOffset: Vector3;
  114552. /**
  114553. * Enable or disable collisions of the camera with the rest of the scene objects.
  114554. */
  114555. checkCollisions: boolean;
  114556. /**
  114557. * Enable or disable gravity on the camera.
  114558. */
  114559. applyGravity: boolean;
  114560. /**
  114561. * Define the current direction the camera is moving to.
  114562. */
  114563. cameraDirection: Vector3;
  114564. /**
  114565. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114566. * This overrides and empties cameraRotation.
  114567. */
  114568. rotationQuaternion: Quaternion;
  114569. /**
  114570. * Track Roll to maintain the wanted Rolling when looking around.
  114571. */
  114572. _trackRoll: number;
  114573. /**
  114574. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114575. */
  114576. rollCorrect: number;
  114577. /**
  114578. * Mimic a banked turn, Rolling the camera when Yawing.
  114579. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114580. */
  114581. bankedTurn: boolean;
  114582. /**
  114583. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114584. */
  114585. bankedTurnLimit: number;
  114586. /**
  114587. * Value of 0 disables the banked Roll.
  114588. * Value of 1 is equal to the Yaw angle in radians.
  114589. */
  114590. bankedTurnMultiplier: number;
  114591. /**
  114592. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114593. */
  114594. inputs: FlyCameraInputsManager;
  114595. /**
  114596. * Gets the input sensibility for mouse input.
  114597. * Higher values reduce sensitivity.
  114598. */
  114599. get angularSensibility(): number;
  114600. /**
  114601. * Sets the input sensibility for a mouse input.
  114602. * Higher values reduce sensitivity.
  114603. */
  114604. set angularSensibility(value: number);
  114605. /**
  114606. * Get the keys for camera movement forward.
  114607. */
  114608. get keysForward(): number[];
  114609. /**
  114610. * Set the keys for camera movement forward.
  114611. */
  114612. set keysForward(value: number[]);
  114613. /**
  114614. * Get the keys for camera movement backward.
  114615. */
  114616. get keysBackward(): number[];
  114617. set keysBackward(value: number[]);
  114618. /**
  114619. * Get the keys for camera movement up.
  114620. */
  114621. get keysUp(): number[];
  114622. /**
  114623. * Set the keys for camera movement up.
  114624. */
  114625. set keysUp(value: number[]);
  114626. /**
  114627. * Get the keys for camera movement down.
  114628. */
  114629. get keysDown(): number[];
  114630. /**
  114631. * Set the keys for camera movement down.
  114632. */
  114633. set keysDown(value: number[]);
  114634. /**
  114635. * Get the keys for camera movement left.
  114636. */
  114637. get keysLeft(): number[];
  114638. /**
  114639. * Set the keys for camera movement left.
  114640. */
  114641. set keysLeft(value: number[]);
  114642. /**
  114643. * Set the keys for camera movement right.
  114644. */
  114645. get keysRight(): number[];
  114646. /**
  114647. * Set the keys for camera movement right.
  114648. */
  114649. set keysRight(value: number[]);
  114650. /**
  114651. * Event raised when the camera collides with a mesh in the scene.
  114652. */
  114653. onCollide: (collidedMesh: AbstractMesh) => void;
  114654. private _collider;
  114655. private _needMoveForGravity;
  114656. private _oldPosition;
  114657. private _diffPosition;
  114658. private _newPosition;
  114659. /** @hidden */
  114660. _localDirection: Vector3;
  114661. /** @hidden */
  114662. _transformedDirection: Vector3;
  114663. /**
  114664. * Instantiates a FlyCamera.
  114665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114666. * such as in a 3D Space Shooter or a Flight Simulator.
  114667. * @param name Define the name of the camera in the scene.
  114668. * @param position Define the starting position of the camera in the scene.
  114669. * @param scene Define the scene the camera belongs to.
  114670. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114671. */
  114672. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114673. /**
  114674. * Attach a control to the HTML DOM element.
  114675. * @param element Defines the element that listens to the input events.
  114676. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114677. */
  114678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114679. /**
  114680. * Detach a control from the HTML DOM element.
  114681. * The camera will stop reacting to that input.
  114682. * @param element Defines the element that listens to the input events.
  114683. */
  114684. detachControl(element: HTMLElement): void;
  114685. private _collisionMask;
  114686. /**
  114687. * Get the mask that the camera ignores in collision events.
  114688. */
  114689. get collisionMask(): number;
  114690. /**
  114691. * Set the mask that the camera ignores in collision events.
  114692. */
  114693. set collisionMask(mask: number);
  114694. /** @hidden */
  114695. _collideWithWorld(displacement: Vector3): void;
  114696. /** @hidden */
  114697. private _onCollisionPositionChange;
  114698. /** @hidden */
  114699. _checkInputs(): void;
  114700. /** @hidden */
  114701. _decideIfNeedsToMove(): boolean;
  114702. /** @hidden */
  114703. _updatePosition(): void;
  114704. /**
  114705. * Restore the Roll to its target value at the rate specified.
  114706. * @param rate - Higher means slower restoring.
  114707. * @hidden
  114708. */
  114709. restoreRoll(rate: number): void;
  114710. /**
  114711. * Destroy the camera and release the current resources held by it.
  114712. */
  114713. dispose(): void;
  114714. /**
  114715. * Get the current object class name.
  114716. * @returns the class name.
  114717. */
  114718. getClassName(): string;
  114719. }
  114720. }
  114721. declare module BABYLON {
  114722. /**
  114723. * Listen to keyboard events to control the camera.
  114724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114725. */
  114726. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114727. /**
  114728. * Defines the camera the input is attached to.
  114729. */
  114730. camera: FlyCamera;
  114731. /**
  114732. * The list of keyboard keys used to control the forward move of the camera.
  114733. */
  114734. keysForward: number[];
  114735. /**
  114736. * The list of keyboard keys used to control the backward move of the camera.
  114737. */
  114738. keysBackward: number[];
  114739. /**
  114740. * The list of keyboard keys used to control the forward move of the camera.
  114741. */
  114742. keysUp: number[];
  114743. /**
  114744. * The list of keyboard keys used to control the backward move of the camera.
  114745. */
  114746. keysDown: number[];
  114747. /**
  114748. * The list of keyboard keys used to control the right strafe move of the camera.
  114749. */
  114750. keysRight: number[];
  114751. /**
  114752. * The list of keyboard keys used to control the left strafe move of the camera.
  114753. */
  114754. keysLeft: number[];
  114755. private _keys;
  114756. private _onCanvasBlurObserver;
  114757. private _onKeyboardObserver;
  114758. private _engine;
  114759. private _scene;
  114760. /**
  114761. * Attach the input controls to a specific dom element to get the input from.
  114762. * @param element Defines the element the controls should be listened from
  114763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114764. */
  114765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114766. /**
  114767. * Detach the current controls from the specified dom element.
  114768. * @param element Defines the element to stop listening the inputs from
  114769. */
  114770. detachControl(element: Nullable<HTMLElement>): void;
  114771. /**
  114772. * Gets the class name of the current intput.
  114773. * @returns the class name
  114774. */
  114775. getClassName(): string;
  114776. /** @hidden */
  114777. _onLostFocus(e: FocusEvent): void;
  114778. /**
  114779. * Get the friendly name associated with the input class.
  114780. * @returns the input friendly name
  114781. */
  114782. getSimpleName(): string;
  114783. /**
  114784. * Update the current camera state depending on the inputs that have been used this frame.
  114785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114786. */
  114787. checkInputs(): void;
  114788. }
  114789. }
  114790. declare module BABYLON {
  114791. /**
  114792. * Manage the mouse wheel inputs to control a follow camera.
  114793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114794. */
  114795. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114796. /**
  114797. * Defines the camera the input is attached to.
  114798. */
  114799. camera: FollowCamera;
  114800. /**
  114801. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114802. */
  114803. axisControlRadius: boolean;
  114804. /**
  114805. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114806. */
  114807. axisControlHeight: boolean;
  114808. /**
  114809. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114810. */
  114811. axisControlRotation: boolean;
  114812. /**
  114813. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114814. * relation to mouseWheel events.
  114815. */
  114816. wheelPrecision: number;
  114817. /**
  114818. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114819. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114820. */
  114821. wheelDeltaPercentage: number;
  114822. private _wheel;
  114823. private _observer;
  114824. /**
  114825. * Attach the input controls to a specific dom element to get the input from.
  114826. * @param element Defines the element the controls should be listened from
  114827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114828. */
  114829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114830. /**
  114831. * Detach the current controls from the specified dom element.
  114832. * @param element Defines the element to stop listening the inputs from
  114833. */
  114834. detachControl(element: Nullable<HTMLElement>): void;
  114835. /**
  114836. * Gets the class name of the current intput.
  114837. * @returns the class name
  114838. */
  114839. getClassName(): string;
  114840. /**
  114841. * Get the friendly name associated with the input class.
  114842. * @returns the input friendly name
  114843. */
  114844. getSimpleName(): string;
  114845. }
  114846. }
  114847. declare module BABYLON {
  114848. /**
  114849. * Manage the pointers inputs to control an follow camera.
  114850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114851. */
  114852. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114853. /**
  114854. * Defines the camera the input is attached to.
  114855. */
  114856. camera: FollowCamera;
  114857. /**
  114858. * Gets the class name of the current input.
  114859. * @returns the class name
  114860. */
  114861. getClassName(): string;
  114862. /**
  114863. * Defines the pointer angular sensibility along the X axis or how fast is
  114864. * the camera rotating.
  114865. * A negative number will reverse the axis direction.
  114866. */
  114867. angularSensibilityX: number;
  114868. /**
  114869. * Defines the pointer angular sensibility along the Y axis or how fast is
  114870. * the camera rotating.
  114871. * A negative number will reverse the axis direction.
  114872. */
  114873. angularSensibilityY: number;
  114874. /**
  114875. * Defines the pointer pinch precision or how fast is the camera zooming.
  114876. * A negative number will reverse the axis direction.
  114877. */
  114878. pinchPrecision: number;
  114879. /**
  114880. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114881. * from 0.
  114882. * It defines the percentage of current camera.radius to use as delta when
  114883. * pinch zoom is used.
  114884. */
  114885. pinchDeltaPercentage: number;
  114886. /**
  114887. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114888. */
  114889. axisXControlRadius: boolean;
  114890. /**
  114891. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114892. */
  114893. axisXControlHeight: boolean;
  114894. /**
  114895. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114896. */
  114897. axisXControlRotation: boolean;
  114898. /**
  114899. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114900. */
  114901. axisYControlRadius: boolean;
  114902. /**
  114903. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114904. */
  114905. axisYControlHeight: boolean;
  114906. /**
  114907. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114908. */
  114909. axisYControlRotation: boolean;
  114910. /**
  114911. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114912. */
  114913. axisPinchControlRadius: boolean;
  114914. /**
  114915. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114916. */
  114917. axisPinchControlHeight: boolean;
  114918. /**
  114919. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114920. */
  114921. axisPinchControlRotation: boolean;
  114922. /**
  114923. * Log error messages if basic misconfiguration has occurred.
  114924. */
  114925. warningEnable: boolean;
  114926. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114928. private _warningCounter;
  114929. private _warning;
  114930. }
  114931. }
  114932. declare module BABYLON {
  114933. /**
  114934. * Default Inputs manager for the FollowCamera.
  114935. * It groups all the default supported inputs for ease of use.
  114936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114937. */
  114938. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114939. /**
  114940. * Instantiates a new FollowCameraInputsManager.
  114941. * @param camera Defines the camera the inputs belong to
  114942. */
  114943. constructor(camera: FollowCamera);
  114944. /**
  114945. * Add keyboard input support to the input manager.
  114946. * @returns the current input manager
  114947. */
  114948. addKeyboard(): FollowCameraInputsManager;
  114949. /**
  114950. * Add mouse wheel input support to the input manager.
  114951. * @returns the current input manager
  114952. */
  114953. addMouseWheel(): FollowCameraInputsManager;
  114954. /**
  114955. * Add pointers input support to the input manager.
  114956. * @returns the current input manager
  114957. */
  114958. addPointers(): FollowCameraInputsManager;
  114959. /**
  114960. * Add orientation input support to the input manager.
  114961. * @returns the current input manager
  114962. */
  114963. addVRDeviceOrientation(): FollowCameraInputsManager;
  114964. }
  114965. }
  114966. declare module BABYLON {
  114967. /**
  114968. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114969. * an arc rotate version arcFollowCamera are available.
  114970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114971. */
  114972. export class FollowCamera extends TargetCamera {
  114973. /**
  114974. * Distance the follow camera should follow an object at
  114975. */
  114976. radius: number;
  114977. /**
  114978. * Minimum allowed distance of the camera to the axis of rotation
  114979. * (The camera can not get closer).
  114980. * This can help limiting how the Camera is able to move in the scene.
  114981. */
  114982. lowerRadiusLimit: Nullable<number>;
  114983. /**
  114984. * Maximum allowed distance of the camera to the axis of rotation
  114985. * (The camera can not get further).
  114986. * This can help limiting how the Camera is able to move in the scene.
  114987. */
  114988. upperRadiusLimit: Nullable<number>;
  114989. /**
  114990. * Define a rotation offset between the camera and the object it follows
  114991. */
  114992. rotationOffset: number;
  114993. /**
  114994. * Minimum allowed angle to camera position relative to target object.
  114995. * This can help limiting how the Camera is able to move in the scene.
  114996. */
  114997. lowerRotationOffsetLimit: Nullable<number>;
  114998. /**
  114999. * Maximum allowed angle to camera position relative to target object.
  115000. * This can help limiting how the Camera is able to move in the scene.
  115001. */
  115002. upperRotationOffsetLimit: Nullable<number>;
  115003. /**
  115004. * Define a height offset between the camera and the object it follows.
  115005. * It can help following an object from the top (like a car chaing a plane)
  115006. */
  115007. heightOffset: number;
  115008. /**
  115009. * Minimum allowed height of camera position relative to target object.
  115010. * This can help limiting how the Camera is able to move in the scene.
  115011. */
  115012. lowerHeightOffsetLimit: Nullable<number>;
  115013. /**
  115014. * Maximum allowed height of camera position relative to target object.
  115015. * This can help limiting how the Camera is able to move in the scene.
  115016. */
  115017. upperHeightOffsetLimit: Nullable<number>;
  115018. /**
  115019. * Define how fast the camera can accelerate to follow it s target.
  115020. */
  115021. cameraAcceleration: number;
  115022. /**
  115023. * Define the speed limit of the camera following an object.
  115024. */
  115025. maxCameraSpeed: number;
  115026. /**
  115027. * Define the target of the camera.
  115028. */
  115029. lockedTarget: Nullable<AbstractMesh>;
  115030. /**
  115031. * Defines the input associated with the camera.
  115032. */
  115033. inputs: FollowCameraInputsManager;
  115034. /**
  115035. * Instantiates the follow camera.
  115036. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115037. * @param name Define the name of the camera in the scene
  115038. * @param position Define the position of the camera
  115039. * @param scene Define the scene the camera belong to
  115040. * @param lockedTarget Define the target of the camera
  115041. */
  115042. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115043. private _follow;
  115044. /**
  115045. * Attached controls to the current camera.
  115046. * @param element Defines the element the controls should be listened from
  115047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115048. */
  115049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115050. /**
  115051. * Detach the current controls from the camera.
  115052. * The camera will stop reacting to inputs.
  115053. * @param element Defines the element to stop listening the inputs from
  115054. */
  115055. detachControl(element: HTMLElement): void;
  115056. /** @hidden */
  115057. _checkInputs(): void;
  115058. private _checkLimits;
  115059. /**
  115060. * Gets the camera class name.
  115061. * @returns the class name
  115062. */
  115063. getClassName(): string;
  115064. }
  115065. /**
  115066. * Arc Rotate version of the follow camera.
  115067. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115068. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115069. */
  115070. export class ArcFollowCamera extends TargetCamera {
  115071. /** The longitudinal angle of the camera */
  115072. alpha: number;
  115073. /** The latitudinal angle of the camera */
  115074. beta: number;
  115075. /** The radius of the camera from its target */
  115076. radius: number;
  115077. /** Define the camera target (the messh it should follow) */
  115078. target: Nullable<AbstractMesh>;
  115079. private _cartesianCoordinates;
  115080. /**
  115081. * Instantiates a new ArcFollowCamera
  115082. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115083. * @param name Define the name of the camera
  115084. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115085. * @param beta Define the rotation angle of the camera around the elevation axis
  115086. * @param radius Define the radius of the camera from its target point
  115087. * @param target Define the target of the camera
  115088. * @param scene Define the scene the camera belongs to
  115089. */
  115090. constructor(name: string,
  115091. /** The longitudinal angle of the camera */
  115092. alpha: number,
  115093. /** The latitudinal angle of the camera */
  115094. beta: number,
  115095. /** The radius of the camera from its target */
  115096. radius: number,
  115097. /** Define the camera target (the messh it should follow) */
  115098. target: Nullable<AbstractMesh>, scene: Scene);
  115099. private _follow;
  115100. /** @hidden */
  115101. _checkInputs(): void;
  115102. /**
  115103. * Returns the class name of the object.
  115104. * It is mostly used internally for serialization purposes.
  115105. */
  115106. getClassName(): string;
  115107. }
  115108. }
  115109. declare module BABYLON {
  115110. /**
  115111. * Manage the keyboard inputs to control the movement of a follow camera.
  115112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115113. */
  115114. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115115. /**
  115116. * Defines the camera the input is attached to.
  115117. */
  115118. camera: FollowCamera;
  115119. /**
  115120. * Defines the list of key codes associated with the up action (increase heightOffset)
  115121. */
  115122. keysHeightOffsetIncr: number[];
  115123. /**
  115124. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115125. */
  115126. keysHeightOffsetDecr: number[];
  115127. /**
  115128. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115129. */
  115130. keysHeightOffsetModifierAlt: boolean;
  115131. /**
  115132. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115133. */
  115134. keysHeightOffsetModifierCtrl: boolean;
  115135. /**
  115136. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115137. */
  115138. keysHeightOffsetModifierShift: boolean;
  115139. /**
  115140. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115141. */
  115142. keysRotationOffsetIncr: number[];
  115143. /**
  115144. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115145. */
  115146. keysRotationOffsetDecr: number[];
  115147. /**
  115148. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115149. */
  115150. keysRotationOffsetModifierAlt: boolean;
  115151. /**
  115152. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115153. */
  115154. keysRotationOffsetModifierCtrl: boolean;
  115155. /**
  115156. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115157. */
  115158. keysRotationOffsetModifierShift: boolean;
  115159. /**
  115160. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115161. */
  115162. keysRadiusIncr: number[];
  115163. /**
  115164. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115165. */
  115166. keysRadiusDecr: number[];
  115167. /**
  115168. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115169. */
  115170. keysRadiusModifierAlt: boolean;
  115171. /**
  115172. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115173. */
  115174. keysRadiusModifierCtrl: boolean;
  115175. /**
  115176. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115177. */
  115178. keysRadiusModifierShift: boolean;
  115179. /**
  115180. * Defines the rate of change of heightOffset.
  115181. */
  115182. heightSensibility: number;
  115183. /**
  115184. * Defines the rate of change of rotationOffset.
  115185. */
  115186. rotationSensibility: number;
  115187. /**
  115188. * Defines the rate of change of radius.
  115189. */
  115190. radiusSensibility: number;
  115191. private _keys;
  115192. private _ctrlPressed;
  115193. private _altPressed;
  115194. private _shiftPressed;
  115195. private _onCanvasBlurObserver;
  115196. private _onKeyboardObserver;
  115197. private _engine;
  115198. private _scene;
  115199. /**
  115200. * Attach the input controls to a specific dom element to get the input from.
  115201. * @param element Defines the element the controls should be listened from
  115202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115203. */
  115204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115205. /**
  115206. * Detach the current controls from the specified dom element.
  115207. * @param element Defines the element to stop listening the inputs from
  115208. */
  115209. detachControl(element: Nullable<HTMLElement>): void;
  115210. /**
  115211. * Update the current camera state depending on the inputs that have been used this frame.
  115212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115213. */
  115214. checkInputs(): void;
  115215. /**
  115216. * Gets the class name of the current input.
  115217. * @returns the class name
  115218. */
  115219. getClassName(): string;
  115220. /**
  115221. * Get the friendly name associated with the input class.
  115222. * @returns the input friendly name
  115223. */
  115224. getSimpleName(): string;
  115225. /**
  115226. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115227. * allow modification of the heightOffset value.
  115228. */
  115229. private _modifierHeightOffset;
  115230. /**
  115231. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115232. * allow modification of the rotationOffset value.
  115233. */
  115234. private _modifierRotationOffset;
  115235. /**
  115236. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115237. * allow modification of the radius value.
  115238. */
  115239. private _modifierRadius;
  115240. }
  115241. }
  115242. declare module BABYLON {
  115243. interface FreeCameraInputsManager {
  115244. /**
  115245. * @hidden
  115246. */
  115247. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115248. /**
  115249. * Add orientation input support to the input manager.
  115250. * @returns the current input manager
  115251. */
  115252. addDeviceOrientation(): FreeCameraInputsManager;
  115253. }
  115254. /**
  115255. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115256. * Screen rotation is taken into account.
  115257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115258. */
  115259. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115260. private _camera;
  115261. private _screenOrientationAngle;
  115262. private _constantTranform;
  115263. private _screenQuaternion;
  115264. private _alpha;
  115265. private _beta;
  115266. private _gamma;
  115267. /**
  115268. * Can be used to detect if a device orientation sensor is available on a device
  115269. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115270. * @returns a promise that will resolve on orientation change
  115271. */
  115272. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115273. /**
  115274. * @hidden
  115275. */
  115276. _onDeviceOrientationChangedObservable: Observable<void>;
  115277. /**
  115278. * Instantiates a new input
  115279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115280. */
  115281. constructor();
  115282. /**
  115283. * Define the camera controlled by the input.
  115284. */
  115285. get camera(): FreeCamera;
  115286. set camera(camera: FreeCamera);
  115287. /**
  115288. * Attach the input controls to a specific dom element to get the input from.
  115289. * @param element Defines the element the controls should be listened from
  115290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115291. */
  115292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115293. private _orientationChanged;
  115294. private _deviceOrientation;
  115295. /**
  115296. * Detach the current controls from the specified dom element.
  115297. * @param element Defines the element to stop listening the inputs from
  115298. */
  115299. detachControl(element: Nullable<HTMLElement>): void;
  115300. /**
  115301. * Update the current camera state depending on the inputs that have been used this frame.
  115302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115303. */
  115304. checkInputs(): void;
  115305. /**
  115306. * Gets the class name of the current intput.
  115307. * @returns the class name
  115308. */
  115309. getClassName(): string;
  115310. /**
  115311. * Get the friendly name associated with the input class.
  115312. * @returns the input friendly name
  115313. */
  115314. getSimpleName(): string;
  115315. }
  115316. }
  115317. declare module BABYLON {
  115318. /**
  115319. * Manage the gamepad inputs to control a free camera.
  115320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115321. */
  115322. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115323. /**
  115324. * Define the camera the input is attached to.
  115325. */
  115326. camera: FreeCamera;
  115327. /**
  115328. * Define the Gamepad controlling the input
  115329. */
  115330. gamepad: Nullable<Gamepad>;
  115331. /**
  115332. * Defines the gamepad rotation sensiblity.
  115333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115334. */
  115335. gamepadAngularSensibility: number;
  115336. /**
  115337. * Defines the gamepad move sensiblity.
  115338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115339. */
  115340. gamepadMoveSensibility: number;
  115341. private _yAxisScale;
  115342. /**
  115343. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115344. */
  115345. get invertYAxis(): boolean;
  115346. set invertYAxis(value: boolean);
  115347. private _onGamepadConnectedObserver;
  115348. private _onGamepadDisconnectedObserver;
  115349. private _cameraTransform;
  115350. private _deltaTransform;
  115351. private _vector3;
  115352. private _vector2;
  115353. /**
  115354. * Attach the input controls to a specific dom element to get the input from.
  115355. * @param element Defines the element the controls should be listened from
  115356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115357. */
  115358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115359. /**
  115360. * Detach the current controls from the specified dom element.
  115361. * @param element Defines the element to stop listening the inputs from
  115362. */
  115363. detachControl(element: Nullable<HTMLElement>): void;
  115364. /**
  115365. * Update the current camera state depending on the inputs that have been used this frame.
  115366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115367. */
  115368. checkInputs(): void;
  115369. /**
  115370. * Gets the class name of the current intput.
  115371. * @returns the class name
  115372. */
  115373. getClassName(): string;
  115374. /**
  115375. * Get the friendly name associated with the input class.
  115376. * @returns the input friendly name
  115377. */
  115378. getSimpleName(): string;
  115379. }
  115380. }
  115381. declare module BABYLON {
  115382. /**
  115383. * Defines the potential axis of a Joystick
  115384. */
  115385. export enum JoystickAxis {
  115386. /** X axis */
  115387. X = 0,
  115388. /** Y axis */
  115389. Y = 1,
  115390. /** Z axis */
  115391. Z = 2
  115392. }
  115393. /**
  115394. * Class used to define virtual joystick (used in touch mode)
  115395. */
  115396. export class VirtualJoystick {
  115397. /**
  115398. * Gets or sets a boolean indicating that left and right values must be inverted
  115399. */
  115400. reverseLeftRight: boolean;
  115401. /**
  115402. * Gets or sets a boolean indicating that up and down values must be inverted
  115403. */
  115404. reverseUpDown: boolean;
  115405. /**
  115406. * Gets the offset value for the position (ie. the change of the position value)
  115407. */
  115408. deltaPosition: Vector3;
  115409. /**
  115410. * Gets a boolean indicating if the virtual joystick was pressed
  115411. */
  115412. pressed: boolean;
  115413. /**
  115414. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115415. */
  115416. static Canvas: Nullable<HTMLCanvasElement>;
  115417. private static _globalJoystickIndex;
  115418. private static vjCanvasContext;
  115419. private static vjCanvasWidth;
  115420. private static vjCanvasHeight;
  115421. private static halfWidth;
  115422. private _action;
  115423. private _axisTargetedByLeftAndRight;
  115424. private _axisTargetedByUpAndDown;
  115425. private _joystickSensibility;
  115426. private _inversedSensibility;
  115427. private _joystickPointerID;
  115428. private _joystickColor;
  115429. private _joystickPointerPos;
  115430. private _joystickPreviousPointerPos;
  115431. private _joystickPointerStartPos;
  115432. private _deltaJoystickVector;
  115433. private _leftJoystick;
  115434. private _touches;
  115435. private _onPointerDownHandlerRef;
  115436. private _onPointerMoveHandlerRef;
  115437. private _onPointerUpHandlerRef;
  115438. private _onResize;
  115439. /**
  115440. * Creates a new virtual joystick
  115441. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115442. */
  115443. constructor(leftJoystick?: boolean);
  115444. /**
  115445. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115446. * @param newJoystickSensibility defines the new sensibility
  115447. */
  115448. setJoystickSensibility(newJoystickSensibility: number): void;
  115449. private _onPointerDown;
  115450. private _onPointerMove;
  115451. private _onPointerUp;
  115452. /**
  115453. * Change the color of the virtual joystick
  115454. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115455. */
  115456. setJoystickColor(newColor: string): void;
  115457. /**
  115458. * Defines a callback to call when the joystick is touched
  115459. * @param action defines the callback
  115460. */
  115461. setActionOnTouch(action: () => any): void;
  115462. /**
  115463. * Defines which axis you'd like to control for left & right
  115464. * @param axis defines the axis to use
  115465. */
  115466. setAxisForLeftRight(axis: JoystickAxis): void;
  115467. /**
  115468. * Defines which axis you'd like to control for up & down
  115469. * @param axis defines the axis to use
  115470. */
  115471. setAxisForUpDown(axis: JoystickAxis): void;
  115472. private _drawVirtualJoystick;
  115473. /**
  115474. * Release internal HTML canvas
  115475. */
  115476. releaseCanvas(): void;
  115477. }
  115478. }
  115479. declare module BABYLON {
  115480. interface FreeCameraInputsManager {
  115481. /**
  115482. * Add virtual joystick input support to the input manager.
  115483. * @returns the current input manager
  115484. */
  115485. addVirtualJoystick(): FreeCameraInputsManager;
  115486. }
  115487. /**
  115488. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115490. */
  115491. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115492. /**
  115493. * Defines the camera the input is attached to.
  115494. */
  115495. camera: FreeCamera;
  115496. private _leftjoystick;
  115497. private _rightjoystick;
  115498. /**
  115499. * Gets the left stick of the virtual joystick.
  115500. * @returns The virtual Joystick
  115501. */
  115502. getLeftJoystick(): VirtualJoystick;
  115503. /**
  115504. * Gets the right stick of the virtual joystick.
  115505. * @returns The virtual Joystick
  115506. */
  115507. getRightJoystick(): VirtualJoystick;
  115508. /**
  115509. * Update the current camera state depending on the inputs that have been used this frame.
  115510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115511. */
  115512. checkInputs(): void;
  115513. /**
  115514. * Attach the input controls to a specific dom element to get the input from.
  115515. * @param element Defines the element the controls should be listened from
  115516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115517. */
  115518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115519. /**
  115520. * Detach the current controls from the specified dom element.
  115521. * @param element Defines the element to stop listening the inputs from
  115522. */
  115523. detachControl(element: Nullable<HTMLElement>): void;
  115524. /**
  115525. * Gets the class name of the current intput.
  115526. * @returns the class name
  115527. */
  115528. getClassName(): string;
  115529. /**
  115530. * Get the friendly name associated with the input class.
  115531. * @returns the input friendly name
  115532. */
  115533. getSimpleName(): string;
  115534. }
  115535. }
  115536. declare module BABYLON {
  115537. /**
  115538. * This represents a FPS type of camera controlled by touch.
  115539. * This is like a universal camera minus the Gamepad controls.
  115540. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115541. */
  115542. export class TouchCamera extends FreeCamera {
  115543. /**
  115544. * Defines the touch sensibility for rotation.
  115545. * The higher the faster.
  115546. */
  115547. get touchAngularSensibility(): number;
  115548. set touchAngularSensibility(value: number);
  115549. /**
  115550. * Defines the touch sensibility for move.
  115551. * The higher the faster.
  115552. */
  115553. get touchMoveSensibility(): number;
  115554. set touchMoveSensibility(value: number);
  115555. /**
  115556. * Instantiates a new touch camera.
  115557. * This represents a FPS type of camera controlled by touch.
  115558. * This is like a universal camera minus the Gamepad controls.
  115559. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115560. * @param name Define the name of the camera in the scene
  115561. * @param position Define the start position of the camera in the scene
  115562. * @param scene Define the scene the camera belongs to
  115563. */
  115564. constructor(name: string, position: Vector3, scene: Scene);
  115565. /**
  115566. * Gets the current object class name.
  115567. * @return the class name
  115568. */
  115569. getClassName(): string;
  115570. /** @hidden */
  115571. _setupInputs(): void;
  115572. }
  115573. }
  115574. declare module BABYLON {
  115575. /**
  115576. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115577. * being tilted forward or back and left or right.
  115578. */
  115579. export class DeviceOrientationCamera extends FreeCamera {
  115580. private _initialQuaternion;
  115581. private _quaternionCache;
  115582. private _tmpDragQuaternion;
  115583. private _disablePointerInputWhenUsingDeviceOrientation;
  115584. /**
  115585. * Creates a new device orientation camera
  115586. * @param name The name of the camera
  115587. * @param position The start position camera
  115588. * @param scene The scene the camera belongs to
  115589. */
  115590. constructor(name: string, position: Vector3, scene: Scene);
  115591. /**
  115592. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115593. */
  115594. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115595. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115596. private _dragFactor;
  115597. /**
  115598. * Enabled turning on the y axis when the orientation sensor is active
  115599. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115600. */
  115601. enableHorizontalDragging(dragFactor?: number): void;
  115602. /**
  115603. * Gets the current instance class name ("DeviceOrientationCamera").
  115604. * This helps avoiding instanceof at run time.
  115605. * @returns the class name
  115606. */
  115607. getClassName(): string;
  115608. /**
  115609. * @hidden
  115610. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115611. */
  115612. _checkInputs(): void;
  115613. /**
  115614. * Reset the camera to its default orientation on the specified axis only.
  115615. * @param axis The axis to reset
  115616. */
  115617. resetToCurrentRotation(axis?: Axis): void;
  115618. }
  115619. }
  115620. declare module BABYLON {
  115621. /**
  115622. * Defines supported buttons for XBox360 compatible gamepads
  115623. */
  115624. export enum Xbox360Button {
  115625. /** A */
  115626. A = 0,
  115627. /** B */
  115628. B = 1,
  115629. /** X */
  115630. X = 2,
  115631. /** Y */
  115632. Y = 3,
  115633. /** Left button */
  115634. LB = 4,
  115635. /** Right button */
  115636. RB = 5,
  115637. /** Back */
  115638. Back = 8,
  115639. /** Start */
  115640. Start = 9,
  115641. /** Left stick */
  115642. LeftStick = 10,
  115643. /** Right stick */
  115644. RightStick = 11
  115645. }
  115646. /** Defines values for XBox360 DPad */
  115647. export enum Xbox360Dpad {
  115648. /** Up */
  115649. Up = 12,
  115650. /** Down */
  115651. Down = 13,
  115652. /** Left */
  115653. Left = 14,
  115654. /** Right */
  115655. Right = 15
  115656. }
  115657. /**
  115658. * Defines a XBox360 gamepad
  115659. */
  115660. export class Xbox360Pad extends Gamepad {
  115661. private _leftTrigger;
  115662. private _rightTrigger;
  115663. private _onlefttriggerchanged;
  115664. private _onrighttriggerchanged;
  115665. private _onbuttondown;
  115666. private _onbuttonup;
  115667. private _ondpaddown;
  115668. private _ondpadup;
  115669. /** Observable raised when a button is pressed */
  115670. onButtonDownObservable: Observable<Xbox360Button>;
  115671. /** Observable raised when a button is released */
  115672. onButtonUpObservable: Observable<Xbox360Button>;
  115673. /** Observable raised when a pad is pressed */
  115674. onPadDownObservable: Observable<Xbox360Dpad>;
  115675. /** Observable raised when a pad is released */
  115676. onPadUpObservable: Observable<Xbox360Dpad>;
  115677. private _buttonA;
  115678. private _buttonB;
  115679. private _buttonX;
  115680. private _buttonY;
  115681. private _buttonBack;
  115682. private _buttonStart;
  115683. private _buttonLB;
  115684. private _buttonRB;
  115685. private _buttonLeftStick;
  115686. private _buttonRightStick;
  115687. private _dPadUp;
  115688. private _dPadDown;
  115689. private _dPadLeft;
  115690. private _dPadRight;
  115691. private _isXboxOnePad;
  115692. /**
  115693. * Creates a new XBox360 gamepad object
  115694. * @param id defines the id of this gamepad
  115695. * @param index defines its index
  115696. * @param gamepad defines the internal HTML gamepad object
  115697. * @param xboxOne defines if it is a XBox One gamepad
  115698. */
  115699. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115700. /**
  115701. * Defines the callback to call when left trigger is pressed
  115702. * @param callback defines the callback to use
  115703. */
  115704. onlefttriggerchanged(callback: (value: number) => void): void;
  115705. /**
  115706. * Defines the callback to call when right trigger is pressed
  115707. * @param callback defines the callback to use
  115708. */
  115709. onrighttriggerchanged(callback: (value: number) => void): void;
  115710. /**
  115711. * Gets the left trigger value
  115712. */
  115713. get leftTrigger(): number;
  115714. /**
  115715. * Sets the left trigger value
  115716. */
  115717. set leftTrigger(newValue: number);
  115718. /**
  115719. * Gets the right trigger value
  115720. */
  115721. get rightTrigger(): number;
  115722. /**
  115723. * Sets the right trigger value
  115724. */
  115725. set rightTrigger(newValue: number);
  115726. /**
  115727. * Defines the callback to call when a button is pressed
  115728. * @param callback defines the callback to use
  115729. */
  115730. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115731. /**
  115732. * Defines the callback to call when a button is released
  115733. * @param callback defines the callback to use
  115734. */
  115735. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115736. /**
  115737. * Defines the callback to call when a pad is pressed
  115738. * @param callback defines the callback to use
  115739. */
  115740. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115741. /**
  115742. * Defines the callback to call when a pad is released
  115743. * @param callback defines the callback to use
  115744. */
  115745. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115746. private _setButtonValue;
  115747. private _setDPadValue;
  115748. /**
  115749. * Gets the value of the `A` button
  115750. */
  115751. get buttonA(): number;
  115752. /**
  115753. * Sets the value of the `A` button
  115754. */
  115755. set buttonA(value: number);
  115756. /**
  115757. * Gets the value of the `B` button
  115758. */
  115759. get buttonB(): number;
  115760. /**
  115761. * Sets the value of the `B` button
  115762. */
  115763. set buttonB(value: number);
  115764. /**
  115765. * Gets the value of the `X` button
  115766. */
  115767. get buttonX(): number;
  115768. /**
  115769. * Sets the value of the `X` button
  115770. */
  115771. set buttonX(value: number);
  115772. /**
  115773. * Gets the value of the `Y` button
  115774. */
  115775. get buttonY(): number;
  115776. /**
  115777. * Sets the value of the `Y` button
  115778. */
  115779. set buttonY(value: number);
  115780. /**
  115781. * Gets the value of the `Start` button
  115782. */
  115783. get buttonStart(): number;
  115784. /**
  115785. * Sets the value of the `Start` button
  115786. */
  115787. set buttonStart(value: number);
  115788. /**
  115789. * Gets the value of the `Back` button
  115790. */
  115791. get buttonBack(): number;
  115792. /**
  115793. * Sets the value of the `Back` button
  115794. */
  115795. set buttonBack(value: number);
  115796. /**
  115797. * Gets the value of the `Left` button
  115798. */
  115799. get buttonLB(): number;
  115800. /**
  115801. * Sets the value of the `Left` button
  115802. */
  115803. set buttonLB(value: number);
  115804. /**
  115805. * Gets the value of the `Right` button
  115806. */
  115807. get buttonRB(): number;
  115808. /**
  115809. * Sets the value of the `Right` button
  115810. */
  115811. set buttonRB(value: number);
  115812. /**
  115813. * Gets the value of the Left joystick
  115814. */
  115815. get buttonLeftStick(): number;
  115816. /**
  115817. * Sets the value of the Left joystick
  115818. */
  115819. set buttonLeftStick(value: number);
  115820. /**
  115821. * Gets the value of the Right joystick
  115822. */
  115823. get buttonRightStick(): number;
  115824. /**
  115825. * Sets the value of the Right joystick
  115826. */
  115827. set buttonRightStick(value: number);
  115828. /**
  115829. * Gets the value of D-pad up
  115830. */
  115831. get dPadUp(): number;
  115832. /**
  115833. * Sets the value of D-pad up
  115834. */
  115835. set dPadUp(value: number);
  115836. /**
  115837. * Gets the value of D-pad down
  115838. */
  115839. get dPadDown(): number;
  115840. /**
  115841. * Sets the value of D-pad down
  115842. */
  115843. set dPadDown(value: number);
  115844. /**
  115845. * Gets the value of D-pad left
  115846. */
  115847. get dPadLeft(): number;
  115848. /**
  115849. * Sets the value of D-pad left
  115850. */
  115851. set dPadLeft(value: number);
  115852. /**
  115853. * Gets the value of D-pad right
  115854. */
  115855. get dPadRight(): number;
  115856. /**
  115857. * Sets the value of D-pad right
  115858. */
  115859. set dPadRight(value: number);
  115860. /**
  115861. * Force the gamepad to synchronize with device values
  115862. */
  115863. update(): void;
  115864. /**
  115865. * Disposes the gamepad
  115866. */
  115867. dispose(): void;
  115868. }
  115869. }
  115870. declare module BABYLON {
  115871. /**
  115872. * Defines supported buttons for DualShock compatible gamepads
  115873. */
  115874. export enum DualShockButton {
  115875. /** Cross */
  115876. Cross = 0,
  115877. /** Circle */
  115878. Circle = 1,
  115879. /** Square */
  115880. Square = 2,
  115881. /** Triangle */
  115882. Triangle = 3,
  115883. /** L1 */
  115884. L1 = 4,
  115885. /** R1 */
  115886. R1 = 5,
  115887. /** Share */
  115888. Share = 8,
  115889. /** Options */
  115890. Options = 9,
  115891. /** Left stick */
  115892. LeftStick = 10,
  115893. /** Right stick */
  115894. RightStick = 11
  115895. }
  115896. /** Defines values for DualShock DPad */
  115897. export enum DualShockDpad {
  115898. /** Up */
  115899. Up = 12,
  115900. /** Down */
  115901. Down = 13,
  115902. /** Left */
  115903. Left = 14,
  115904. /** Right */
  115905. Right = 15
  115906. }
  115907. /**
  115908. * Defines a DualShock gamepad
  115909. */
  115910. export class DualShockPad extends Gamepad {
  115911. private _leftTrigger;
  115912. private _rightTrigger;
  115913. private _onlefttriggerchanged;
  115914. private _onrighttriggerchanged;
  115915. private _onbuttondown;
  115916. private _onbuttonup;
  115917. private _ondpaddown;
  115918. private _ondpadup;
  115919. /** Observable raised when a button is pressed */
  115920. onButtonDownObservable: Observable<DualShockButton>;
  115921. /** Observable raised when a button is released */
  115922. onButtonUpObservable: Observable<DualShockButton>;
  115923. /** Observable raised when a pad is pressed */
  115924. onPadDownObservable: Observable<DualShockDpad>;
  115925. /** Observable raised when a pad is released */
  115926. onPadUpObservable: Observable<DualShockDpad>;
  115927. private _buttonCross;
  115928. private _buttonCircle;
  115929. private _buttonSquare;
  115930. private _buttonTriangle;
  115931. private _buttonShare;
  115932. private _buttonOptions;
  115933. private _buttonL1;
  115934. private _buttonR1;
  115935. private _buttonLeftStick;
  115936. private _buttonRightStick;
  115937. private _dPadUp;
  115938. private _dPadDown;
  115939. private _dPadLeft;
  115940. private _dPadRight;
  115941. /**
  115942. * Creates a new DualShock gamepad object
  115943. * @param id defines the id of this gamepad
  115944. * @param index defines its index
  115945. * @param gamepad defines the internal HTML gamepad object
  115946. */
  115947. constructor(id: string, index: number, gamepad: any);
  115948. /**
  115949. * Defines the callback to call when left trigger is pressed
  115950. * @param callback defines the callback to use
  115951. */
  115952. onlefttriggerchanged(callback: (value: number) => void): void;
  115953. /**
  115954. * Defines the callback to call when right trigger is pressed
  115955. * @param callback defines the callback to use
  115956. */
  115957. onrighttriggerchanged(callback: (value: number) => void): void;
  115958. /**
  115959. * Gets the left trigger value
  115960. */
  115961. get leftTrigger(): number;
  115962. /**
  115963. * Sets the left trigger value
  115964. */
  115965. set leftTrigger(newValue: number);
  115966. /**
  115967. * Gets the right trigger value
  115968. */
  115969. get rightTrigger(): number;
  115970. /**
  115971. * Sets the right trigger value
  115972. */
  115973. set rightTrigger(newValue: number);
  115974. /**
  115975. * Defines the callback to call when a button is pressed
  115976. * @param callback defines the callback to use
  115977. */
  115978. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115979. /**
  115980. * Defines the callback to call when a button is released
  115981. * @param callback defines the callback to use
  115982. */
  115983. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115984. /**
  115985. * Defines the callback to call when a pad is pressed
  115986. * @param callback defines the callback to use
  115987. */
  115988. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115989. /**
  115990. * Defines the callback to call when a pad is released
  115991. * @param callback defines the callback to use
  115992. */
  115993. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115994. private _setButtonValue;
  115995. private _setDPadValue;
  115996. /**
  115997. * Gets the value of the `Cross` button
  115998. */
  115999. get buttonCross(): number;
  116000. /**
  116001. * Sets the value of the `Cross` button
  116002. */
  116003. set buttonCross(value: number);
  116004. /**
  116005. * Gets the value of the `Circle` button
  116006. */
  116007. get buttonCircle(): number;
  116008. /**
  116009. * Sets the value of the `Circle` button
  116010. */
  116011. set buttonCircle(value: number);
  116012. /**
  116013. * Gets the value of the `Square` button
  116014. */
  116015. get buttonSquare(): number;
  116016. /**
  116017. * Sets the value of the `Square` button
  116018. */
  116019. set buttonSquare(value: number);
  116020. /**
  116021. * Gets the value of the `Triangle` button
  116022. */
  116023. get buttonTriangle(): number;
  116024. /**
  116025. * Sets the value of the `Triangle` button
  116026. */
  116027. set buttonTriangle(value: number);
  116028. /**
  116029. * Gets the value of the `Options` button
  116030. */
  116031. get buttonOptions(): number;
  116032. /**
  116033. * Sets the value of the `Options` button
  116034. */
  116035. set buttonOptions(value: number);
  116036. /**
  116037. * Gets the value of the `Share` button
  116038. */
  116039. get buttonShare(): number;
  116040. /**
  116041. * Sets the value of the `Share` button
  116042. */
  116043. set buttonShare(value: number);
  116044. /**
  116045. * Gets the value of the `L1` button
  116046. */
  116047. get buttonL1(): number;
  116048. /**
  116049. * Sets the value of the `L1` button
  116050. */
  116051. set buttonL1(value: number);
  116052. /**
  116053. * Gets the value of the `R1` button
  116054. */
  116055. get buttonR1(): number;
  116056. /**
  116057. * Sets the value of the `R1` button
  116058. */
  116059. set buttonR1(value: number);
  116060. /**
  116061. * Gets the value of the Left joystick
  116062. */
  116063. get buttonLeftStick(): number;
  116064. /**
  116065. * Sets the value of the Left joystick
  116066. */
  116067. set buttonLeftStick(value: number);
  116068. /**
  116069. * Gets the value of the Right joystick
  116070. */
  116071. get buttonRightStick(): number;
  116072. /**
  116073. * Sets the value of the Right joystick
  116074. */
  116075. set buttonRightStick(value: number);
  116076. /**
  116077. * Gets the value of D-pad up
  116078. */
  116079. get dPadUp(): number;
  116080. /**
  116081. * Sets the value of D-pad up
  116082. */
  116083. set dPadUp(value: number);
  116084. /**
  116085. * Gets the value of D-pad down
  116086. */
  116087. get dPadDown(): number;
  116088. /**
  116089. * Sets the value of D-pad down
  116090. */
  116091. set dPadDown(value: number);
  116092. /**
  116093. * Gets the value of D-pad left
  116094. */
  116095. get dPadLeft(): number;
  116096. /**
  116097. * Sets the value of D-pad left
  116098. */
  116099. set dPadLeft(value: number);
  116100. /**
  116101. * Gets the value of D-pad right
  116102. */
  116103. get dPadRight(): number;
  116104. /**
  116105. * Sets the value of D-pad right
  116106. */
  116107. set dPadRight(value: number);
  116108. /**
  116109. * Force the gamepad to synchronize with device values
  116110. */
  116111. update(): void;
  116112. /**
  116113. * Disposes the gamepad
  116114. */
  116115. dispose(): void;
  116116. }
  116117. }
  116118. declare module BABYLON {
  116119. /**
  116120. * Manager for handling gamepads
  116121. */
  116122. export class GamepadManager {
  116123. private _scene?;
  116124. private _babylonGamepads;
  116125. private _oneGamepadConnected;
  116126. /** @hidden */
  116127. _isMonitoring: boolean;
  116128. private _gamepadEventSupported;
  116129. private _gamepadSupport?;
  116130. /**
  116131. * observable to be triggered when the gamepad controller has been connected
  116132. */
  116133. onGamepadConnectedObservable: Observable<Gamepad>;
  116134. /**
  116135. * observable to be triggered when the gamepad controller has been disconnected
  116136. */
  116137. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116138. private _onGamepadConnectedEvent;
  116139. private _onGamepadDisconnectedEvent;
  116140. /**
  116141. * Initializes the gamepad manager
  116142. * @param _scene BabylonJS scene
  116143. */
  116144. constructor(_scene?: Scene | undefined);
  116145. /**
  116146. * The gamepads in the game pad manager
  116147. */
  116148. get gamepads(): Gamepad[];
  116149. /**
  116150. * Get the gamepad controllers based on type
  116151. * @param type The type of gamepad controller
  116152. * @returns Nullable gamepad
  116153. */
  116154. getGamepadByType(type?: number): Nullable<Gamepad>;
  116155. /**
  116156. * Disposes the gamepad manager
  116157. */
  116158. dispose(): void;
  116159. private _addNewGamepad;
  116160. private _startMonitoringGamepads;
  116161. private _stopMonitoringGamepads;
  116162. /** @hidden */
  116163. _checkGamepadsStatus(): void;
  116164. private _updateGamepadObjects;
  116165. }
  116166. }
  116167. declare module BABYLON {
  116168. interface Scene {
  116169. /** @hidden */
  116170. _gamepadManager: Nullable<GamepadManager>;
  116171. /**
  116172. * Gets the gamepad manager associated with the scene
  116173. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116174. */
  116175. gamepadManager: GamepadManager;
  116176. }
  116177. /**
  116178. * Interface representing a free camera inputs manager
  116179. */
  116180. interface FreeCameraInputsManager {
  116181. /**
  116182. * Adds gamepad input support to the FreeCameraInputsManager.
  116183. * @returns the FreeCameraInputsManager
  116184. */
  116185. addGamepad(): FreeCameraInputsManager;
  116186. }
  116187. /**
  116188. * Interface representing an arc rotate camera inputs manager
  116189. */
  116190. interface ArcRotateCameraInputsManager {
  116191. /**
  116192. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116193. * @returns the camera inputs manager
  116194. */
  116195. addGamepad(): ArcRotateCameraInputsManager;
  116196. }
  116197. /**
  116198. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116199. */
  116200. export class GamepadSystemSceneComponent implements ISceneComponent {
  116201. /**
  116202. * The component name helpfull to identify the component in the list of scene components.
  116203. */
  116204. readonly name: string;
  116205. /**
  116206. * The scene the component belongs to.
  116207. */
  116208. scene: Scene;
  116209. /**
  116210. * Creates a new instance of the component for the given scene
  116211. * @param scene Defines the scene to register the component in
  116212. */
  116213. constructor(scene: Scene);
  116214. /**
  116215. * Registers the component in a given scene
  116216. */
  116217. register(): void;
  116218. /**
  116219. * Rebuilds the elements related to this component in case of
  116220. * context lost for instance.
  116221. */
  116222. rebuild(): void;
  116223. /**
  116224. * Disposes the component and the associated ressources
  116225. */
  116226. dispose(): void;
  116227. private _beforeCameraUpdate;
  116228. }
  116229. }
  116230. declare module BABYLON {
  116231. /**
  116232. * 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,
  116233. * which still works and will still be found in many Playgrounds.
  116234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116235. */
  116236. export class UniversalCamera extends TouchCamera {
  116237. /**
  116238. * Defines the gamepad rotation sensiblity.
  116239. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116240. */
  116241. get gamepadAngularSensibility(): number;
  116242. set gamepadAngularSensibility(value: number);
  116243. /**
  116244. * Defines the gamepad move sensiblity.
  116245. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116246. */
  116247. get gamepadMoveSensibility(): number;
  116248. set gamepadMoveSensibility(value: number);
  116249. /**
  116250. * 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,
  116251. * which still works and will still be found in many Playgrounds.
  116252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116253. * @param name Define the name of the camera in the scene
  116254. * @param position Define the start position of the camera in the scene
  116255. * @param scene Define the scene the camera belongs to
  116256. */
  116257. constructor(name: string, position: Vector3, scene: Scene);
  116258. /**
  116259. * Gets the current object class name.
  116260. * @return the class name
  116261. */
  116262. getClassName(): string;
  116263. }
  116264. }
  116265. declare module BABYLON {
  116266. /**
  116267. * This represents a FPS type of camera. This is only here for back compat purpose.
  116268. * Please use the UniversalCamera instead as both are identical.
  116269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116270. */
  116271. export class GamepadCamera extends UniversalCamera {
  116272. /**
  116273. * Instantiates a new Gamepad Camera
  116274. * This represents a FPS type of camera. This is only here for back compat purpose.
  116275. * Please use the UniversalCamera instead as both are identical.
  116276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116277. * @param name Define the name of the camera in the scene
  116278. * @param position Define the start position of the camera in the scene
  116279. * @param scene Define the scene the camera belongs to
  116280. */
  116281. constructor(name: string, position: Vector3, scene: Scene);
  116282. /**
  116283. * Gets the current object class name.
  116284. * @return the class name
  116285. */
  116286. getClassName(): string;
  116287. }
  116288. }
  116289. declare module BABYLON {
  116290. /** @hidden */
  116291. export var passPixelShader: {
  116292. name: string;
  116293. shader: string;
  116294. };
  116295. }
  116296. declare module BABYLON {
  116297. /** @hidden */
  116298. export var passCubePixelShader: {
  116299. name: string;
  116300. shader: string;
  116301. };
  116302. }
  116303. declare module BABYLON {
  116304. /**
  116305. * PassPostProcess which produces an output the same as it's input
  116306. */
  116307. export class PassPostProcess extends PostProcess {
  116308. /**
  116309. * Creates the PassPostProcess
  116310. * @param name The name of the effect.
  116311. * @param options The required width/height ratio to downsize to before computing the render pass.
  116312. * @param camera The camera to apply the render pass to.
  116313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116314. * @param engine The engine which the post process will be applied. (default: current engine)
  116315. * @param reusable If the post process can be reused on the same frame. (default: false)
  116316. * @param textureType The type of texture to be used when performing the post processing.
  116317. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  116318. */
  116319. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116320. }
  116321. /**
  116322. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116323. */
  116324. export class PassCubePostProcess extends PostProcess {
  116325. private _face;
  116326. /**
  116327. * Gets or sets the cube face to display.
  116328. * * 0 is +X
  116329. * * 1 is -X
  116330. * * 2 is +Y
  116331. * * 3 is -Y
  116332. * * 4 is +Z
  116333. * * 5 is -Z
  116334. */
  116335. get face(): number;
  116336. set face(value: number);
  116337. /**
  116338. * Creates the PassCubePostProcess
  116339. * @param name The name of the effect.
  116340. * @param options The required width/height ratio to downsize to before computing the render pass.
  116341. * @param camera The camera to apply the render pass to.
  116342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116343. * @param engine The engine which the post process will be applied. (default: current engine)
  116344. * @param reusable If the post process can be reused on the same frame. (default: false)
  116345. * @param textureType The type of texture to be used when performing the post processing.
  116346. * @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)
  116347. */
  116348. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116349. }
  116350. }
  116351. declare module BABYLON {
  116352. /** @hidden */
  116353. export var anaglyphPixelShader: {
  116354. name: string;
  116355. shader: string;
  116356. };
  116357. }
  116358. declare module BABYLON {
  116359. /**
  116360. * Postprocess used to generate anaglyphic rendering
  116361. */
  116362. export class AnaglyphPostProcess extends PostProcess {
  116363. private _passedProcess;
  116364. /**
  116365. * Creates a new AnaglyphPostProcess
  116366. * @param name defines postprocess name
  116367. * @param options defines creation options or target ratio scale
  116368. * @param rigCameras defines cameras using this postprocess
  116369. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116370. * @param engine defines hosting engine
  116371. * @param reusable defines if the postprocess will be reused multiple times per frame
  116372. */
  116373. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116374. }
  116375. }
  116376. declare module BABYLON {
  116377. /**
  116378. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116380. */
  116381. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116382. /**
  116383. * Creates a new AnaglyphArcRotateCamera
  116384. * @param name defines camera name
  116385. * @param alpha defines alpha angle (in radians)
  116386. * @param beta defines beta angle (in radians)
  116387. * @param radius defines radius
  116388. * @param target defines camera target
  116389. * @param interaxialDistance defines distance between each color axis
  116390. * @param scene defines the hosting scene
  116391. */
  116392. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116393. /**
  116394. * Gets camera class name
  116395. * @returns AnaglyphArcRotateCamera
  116396. */
  116397. getClassName(): string;
  116398. }
  116399. }
  116400. declare module BABYLON {
  116401. /**
  116402. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116403. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116404. */
  116405. export class AnaglyphFreeCamera extends FreeCamera {
  116406. /**
  116407. * Creates a new AnaglyphFreeCamera
  116408. * @param name defines camera name
  116409. * @param position defines initial position
  116410. * @param interaxialDistance defines distance between each color axis
  116411. * @param scene defines the hosting scene
  116412. */
  116413. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116414. /**
  116415. * Gets camera class name
  116416. * @returns AnaglyphFreeCamera
  116417. */
  116418. getClassName(): string;
  116419. }
  116420. }
  116421. declare module BABYLON {
  116422. /**
  116423. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116424. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116425. */
  116426. export class AnaglyphGamepadCamera extends GamepadCamera {
  116427. /**
  116428. * Creates a new AnaglyphGamepadCamera
  116429. * @param name defines camera name
  116430. * @param position defines initial position
  116431. * @param interaxialDistance defines distance between each color axis
  116432. * @param scene defines the hosting scene
  116433. */
  116434. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116435. /**
  116436. * Gets camera class name
  116437. * @returns AnaglyphGamepadCamera
  116438. */
  116439. getClassName(): string;
  116440. }
  116441. }
  116442. declare module BABYLON {
  116443. /**
  116444. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116445. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116446. */
  116447. export class AnaglyphUniversalCamera extends UniversalCamera {
  116448. /**
  116449. * Creates a new AnaglyphUniversalCamera
  116450. * @param name defines camera name
  116451. * @param position defines initial position
  116452. * @param interaxialDistance defines distance between each color axis
  116453. * @param scene defines the hosting scene
  116454. */
  116455. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116456. /**
  116457. * Gets camera class name
  116458. * @returns AnaglyphUniversalCamera
  116459. */
  116460. getClassName(): string;
  116461. }
  116462. }
  116463. declare module BABYLON {
  116464. /** @hidden */
  116465. export var stereoscopicInterlacePixelShader: {
  116466. name: string;
  116467. shader: string;
  116468. };
  116469. }
  116470. declare module BABYLON {
  116471. /**
  116472. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116473. */
  116474. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116475. private _stepSize;
  116476. private _passedProcess;
  116477. /**
  116478. * Initializes a StereoscopicInterlacePostProcessI
  116479. * @param name The name of the effect.
  116480. * @param rigCameras The rig cameras to be appled to the post process
  116481. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116482. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  116483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116484. * @param engine The engine which the post process will be applied. (default: current engine)
  116485. * @param reusable If the post process can be reused on the same frame. (default: false)
  116486. */
  116487. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116488. }
  116489. /**
  116490. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116491. */
  116492. export class StereoscopicInterlacePostProcess extends PostProcess {
  116493. private _stepSize;
  116494. private _passedProcess;
  116495. /**
  116496. * Initializes a StereoscopicInterlacePostProcess
  116497. * @param name The name of the effect.
  116498. * @param rigCameras The rig cameras to be appled to the post process
  116499. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  116500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116501. * @param engine The engine which the post process will be applied. (default: current engine)
  116502. * @param reusable If the post process can be reused on the same frame. (default: false)
  116503. */
  116504. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116505. }
  116506. }
  116507. declare module BABYLON {
  116508. /**
  116509. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116510. * @see http://doc.babylonjs.com/features/cameras
  116511. */
  116512. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116513. /**
  116514. * Creates a new StereoscopicArcRotateCamera
  116515. * @param name defines camera name
  116516. * @param alpha defines alpha angle (in radians)
  116517. * @param beta defines beta angle (in radians)
  116518. * @param radius defines radius
  116519. * @param target defines camera target
  116520. * @param interaxialDistance defines distance between each color axis
  116521. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116522. * @param scene defines the hosting scene
  116523. */
  116524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116525. /**
  116526. * Gets camera class name
  116527. * @returns StereoscopicArcRotateCamera
  116528. */
  116529. getClassName(): string;
  116530. }
  116531. }
  116532. declare module BABYLON {
  116533. /**
  116534. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116535. * @see http://doc.babylonjs.com/features/cameras
  116536. */
  116537. export class StereoscopicFreeCamera extends FreeCamera {
  116538. /**
  116539. * Creates a new StereoscopicFreeCamera
  116540. * @param name defines camera name
  116541. * @param position defines initial position
  116542. * @param interaxialDistance defines distance between each color axis
  116543. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116544. * @param scene defines the hosting scene
  116545. */
  116546. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116547. /**
  116548. * Gets camera class name
  116549. * @returns StereoscopicFreeCamera
  116550. */
  116551. getClassName(): string;
  116552. }
  116553. }
  116554. declare module BABYLON {
  116555. /**
  116556. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116557. * @see http://doc.babylonjs.com/features/cameras
  116558. */
  116559. export class StereoscopicGamepadCamera extends GamepadCamera {
  116560. /**
  116561. * Creates a new StereoscopicGamepadCamera
  116562. * @param name defines camera name
  116563. * @param position defines initial position
  116564. * @param interaxialDistance defines distance between each color axis
  116565. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116566. * @param scene defines the hosting scene
  116567. */
  116568. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116569. /**
  116570. * Gets camera class name
  116571. * @returns StereoscopicGamepadCamera
  116572. */
  116573. getClassName(): string;
  116574. }
  116575. }
  116576. declare module BABYLON {
  116577. /**
  116578. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116579. * @see http://doc.babylonjs.com/features/cameras
  116580. */
  116581. export class StereoscopicUniversalCamera extends UniversalCamera {
  116582. /**
  116583. * Creates a new StereoscopicUniversalCamera
  116584. * @param name defines camera name
  116585. * @param position defines initial position
  116586. * @param interaxialDistance defines distance between each color axis
  116587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116588. * @param scene defines the hosting scene
  116589. */
  116590. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116591. /**
  116592. * Gets camera class name
  116593. * @returns StereoscopicUniversalCamera
  116594. */
  116595. getClassName(): string;
  116596. }
  116597. }
  116598. declare module BABYLON {
  116599. /**
  116600. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116601. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116602. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116603. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116604. */
  116605. export class VirtualJoysticksCamera extends FreeCamera {
  116606. /**
  116607. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116608. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116609. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116610. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116611. * @param name Define the name of the camera in the scene
  116612. * @param position Define the start position of the camera in the scene
  116613. * @param scene Define the scene the camera belongs to
  116614. */
  116615. constructor(name: string, position: Vector3, scene: Scene);
  116616. /**
  116617. * Gets the current object class name.
  116618. * @return the class name
  116619. */
  116620. getClassName(): string;
  116621. }
  116622. }
  116623. declare module BABYLON {
  116624. /**
  116625. * This represents all the required metrics to create a VR camera.
  116626. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116627. */
  116628. export class VRCameraMetrics {
  116629. /**
  116630. * Define the horizontal resolution off the screen.
  116631. */
  116632. hResolution: number;
  116633. /**
  116634. * Define the vertical resolution off the screen.
  116635. */
  116636. vResolution: number;
  116637. /**
  116638. * Define the horizontal screen size.
  116639. */
  116640. hScreenSize: number;
  116641. /**
  116642. * Define the vertical screen size.
  116643. */
  116644. vScreenSize: number;
  116645. /**
  116646. * Define the vertical screen center position.
  116647. */
  116648. vScreenCenter: number;
  116649. /**
  116650. * Define the distance of the eyes to the screen.
  116651. */
  116652. eyeToScreenDistance: number;
  116653. /**
  116654. * Define the distance between both lenses
  116655. */
  116656. lensSeparationDistance: number;
  116657. /**
  116658. * Define the distance between both viewer's eyes.
  116659. */
  116660. interpupillaryDistance: number;
  116661. /**
  116662. * Define the distortion factor of the VR postprocess.
  116663. * Please, touch with care.
  116664. */
  116665. distortionK: number[];
  116666. /**
  116667. * Define the chromatic aberration correction factors for the VR post process.
  116668. */
  116669. chromaAbCorrection: number[];
  116670. /**
  116671. * Define the scale factor of the post process.
  116672. * The smaller the better but the slower.
  116673. */
  116674. postProcessScaleFactor: number;
  116675. /**
  116676. * Define an offset for the lens center.
  116677. */
  116678. lensCenterOffset: number;
  116679. /**
  116680. * Define if the current vr camera should compensate the distortion of the lense or not.
  116681. */
  116682. compensateDistortion: boolean;
  116683. /**
  116684. * Defines if multiview should be enabled when rendering (Default: false)
  116685. */
  116686. multiviewEnabled: boolean;
  116687. /**
  116688. * Gets the rendering aspect ratio based on the provided resolutions.
  116689. */
  116690. get aspectRatio(): number;
  116691. /**
  116692. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116693. */
  116694. get aspectRatioFov(): number;
  116695. /**
  116696. * @hidden
  116697. */
  116698. get leftHMatrix(): Matrix;
  116699. /**
  116700. * @hidden
  116701. */
  116702. get rightHMatrix(): Matrix;
  116703. /**
  116704. * @hidden
  116705. */
  116706. get leftPreViewMatrix(): Matrix;
  116707. /**
  116708. * @hidden
  116709. */
  116710. get rightPreViewMatrix(): Matrix;
  116711. /**
  116712. * Get the default VRMetrics based on the most generic setup.
  116713. * @returns the default vr metrics
  116714. */
  116715. static GetDefault(): VRCameraMetrics;
  116716. }
  116717. }
  116718. declare module BABYLON {
  116719. /** @hidden */
  116720. export var vrDistortionCorrectionPixelShader: {
  116721. name: string;
  116722. shader: string;
  116723. };
  116724. }
  116725. declare module BABYLON {
  116726. /**
  116727. * VRDistortionCorrectionPostProcess used for mobile VR
  116728. */
  116729. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116730. private _isRightEye;
  116731. private _distortionFactors;
  116732. private _postProcessScaleFactor;
  116733. private _lensCenterOffset;
  116734. private _scaleIn;
  116735. private _scaleFactor;
  116736. private _lensCenter;
  116737. /**
  116738. * Initializes the VRDistortionCorrectionPostProcess
  116739. * @param name The name of the effect.
  116740. * @param camera The camera to apply the render pass to.
  116741. * @param isRightEye If this is for the right eye distortion
  116742. * @param vrMetrics All the required metrics for the VR camera
  116743. */
  116744. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116745. }
  116746. }
  116747. declare module BABYLON {
  116748. /**
  116749. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116750. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116751. */
  116752. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116753. /**
  116754. * Creates a new VRDeviceOrientationArcRotateCamera
  116755. * @param name defines camera name
  116756. * @param alpha defines the camera rotation along the logitudinal axis
  116757. * @param beta defines the camera rotation along the latitudinal axis
  116758. * @param radius defines the camera distance from its target
  116759. * @param target defines the camera target
  116760. * @param scene defines the scene the camera belongs to
  116761. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116762. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116763. */
  116764. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116765. /**
  116766. * Gets camera class name
  116767. * @returns VRDeviceOrientationArcRotateCamera
  116768. */
  116769. getClassName(): string;
  116770. }
  116771. }
  116772. declare module BABYLON {
  116773. /**
  116774. * Camera used to simulate VR rendering (based on FreeCamera)
  116775. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116776. */
  116777. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116778. /**
  116779. * Creates a new VRDeviceOrientationFreeCamera
  116780. * @param name defines camera name
  116781. * @param position defines the start position of the camera
  116782. * @param scene defines the scene the camera belongs to
  116783. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116784. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116785. */
  116786. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116787. /**
  116788. * Gets camera class name
  116789. * @returns VRDeviceOrientationFreeCamera
  116790. */
  116791. getClassName(): string;
  116792. }
  116793. }
  116794. declare module BABYLON {
  116795. /**
  116796. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116797. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116798. */
  116799. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116800. /**
  116801. * Creates a new VRDeviceOrientationGamepadCamera
  116802. * @param name defines camera name
  116803. * @param position defines the start position of the camera
  116804. * @param scene defines the scene the camera belongs to
  116805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116807. */
  116808. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116809. /**
  116810. * Gets camera class name
  116811. * @returns VRDeviceOrientationGamepadCamera
  116812. */
  116813. getClassName(): string;
  116814. }
  116815. }
  116816. declare module BABYLON {
  116817. /** @hidden */
  116818. export var imageProcessingPixelShader: {
  116819. name: string;
  116820. shader: string;
  116821. };
  116822. }
  116823. declare module BABYLON {
  116824. /**
  116825. * ImageProcessingPostProcess
  116826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116827. */
  116828. export class ImageProcessingPostProcess extends PostProcess {
  116829. /**
  116830. * Default configuration related to image processing available in the PBR Material.
  116831. */
  116832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116833. /**
  116834. * Gets the image processing configuration used either in this material.
  116835. */
  116836. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116837. /**
  116838. * Sets the Default image processing configuration used either in the this material.
  116839. *
  116840. * If sets to null, the scene one is in use.
  116841. */
  116842. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116843. /**
  116844. * Keep track of the image processing observer to allow dispose and replace.
  116845. */
  116846. private _imageProcessingObserver;
  116847. /**
  116848. * Attaches a new image processing configuration to the PBR Material.
  116849. * @param configuration
  116850. */
  116851. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116852. /**
  116853. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116854. */
  116855. get colorCurves(): Nullable<ColorCurves>;
  116856. /**
  116857. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116858. */
  116859. set colorCurves(value: Nullable<ColorCurves>);
  116860. /**
  116861. * Gets wether the color curves effect is enabled.
  116862. */
  116863. get colorCurvesEnabled(): boolean;
  116864. /**
  116865. * Sets wether the color curves effect is enabled.
  116866. */
  116867. set colorCurvesEnabled(value: boolean);
  116868. /**
  116869. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116870. */
  116871. get colorGradingTexture(): Nullable<BaseTexture>;
  116872. /**
  116873. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116874. */
  116875. set colorGradingTexture(value: Nullable<BaseTexture>);
  116876. /**
  116877. * Gets wether the color grading effect is enabled.
  116878. */
  116879. get colorGradingEnabled(): boolean;
  116880. /**
  116881. * Gets wether the color grading effect is enabled.
  116882. */
  116883. set colorGradingEnabled(value: boolean);
  116884. /**
  116885. * Gets exposure used in the effect.
  116886. */
  116887. get exposure(): number;
  116888. /**
  116889. * Sets exposure used in the effect.
  116890. */
  116891. set exposure(value: number);
  116892. /**
  116893. * Gets wether tonemapping is enabled or not.
  116894. */
  116895. get toneMappingEnabled(): boolean;
  116896. /**
  116897. * Sets wether tonemapping is enabled or not
  116898. */
  116899. set toneMappingEnabled(value: boolean);
  116900. /**
  116901. * Gets the type of tone mapping effect.
  116902. */
  116903. get toneMappingType(): number;
  116904. /**
  116905. * Sets the type of tone mapping effect.
  116906. */
  116907. set toneMappingType(value: number);
  116908. /**
  116909. * Gets contrast used in the effect.
  116910. */
  116911. get contrast(): number;
  116912. /**
  116913. * Sets contrast used in the effect.
  116914. */
  116915. set contrast(value: number);
  116916. /**
  116917. * Gets Vignette stretch size.
  116918. */
  116919. get vignetteStretch(): number;
  116920. /**
  116921. * Sets Vignette stretch size.
  116922. */
  116923. set vignetteStretch(value: number);
  116924. /**
  116925. * Gets Vignette centre X Offset.
  116926. */
  116927. get vignetteCentreX(): number;
  116928. /**
  116929. * Sets Vignette centre X Offset.
  116930. */
  116931. set vignetteCentreX(value: number);
  116932. /**
  116933. * Gets Vignette centre Y Offset.
  116934. */
  116935. get vignetteCentreY(): number;
  116936. /**
  116937. * Sets Vignette centre Y Offset.
  116938. */
  116939. set vignetteCentreY(value: number);
  116940. /**
  116941. * Gets Vignette weight or intensity of the vignette effect.
  116942. */
  116943. get vignetteWeight(): number;
  116944. /**
  116945. * Sets Vignette weight or intensity of the vignette effect.
  116946. */
  116947. set vignetteWeight(value: number);
  116948. /**
  116949. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116950. * if vignetteEnabled is set to true.
  116951. */
  116952. get vignetteColor(): Color4;
  116953. /**
  116954. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116955. * if vignetteEnabled is set to true.
  116956. */
  116957. set vignetteColor(value: Color4);
  116958. /**
  116959. * Gets Camera field of view used by the Vignette effect.
  116960. */
  116961. get vignetteCameraFov(): number;
  116962. /**
  116963. * Sets Camera field of view used by the Vignette effect.
  116964. */
  116965. set vignetteCameraFov(value: number);
  116966. /**
  116967. * Gets the vignette blend mode allowing different kind of effect.
  116968. */
  116969. get vignetteBlendMode(): number;
  116970. /**
  116971. * Sets the vignette blend mode allowing different kind of effect.
  116972. */
  116973. set vignetteBlendMode(value: number);
  116974. /**
  116975. * Gets wether the vignette effect is enabled.
  116976. */
  116977. get vignetteEnabled(): boolean;
  116978. /**
  116979. * Sets wether the vignette effect is enabled.
  116980. */
  116981. set vignetteEnabled(value: boolean);
  116982. private _fromLinearSpace;
  116983. /**
  116984. * Gets wether the input of the processing is in Gamma or Linear Space.
  116985. */
  116986. get fromLinearSpace(): boolean;
  116987. /**
  116988. * Sets wether the input of the processing is in Gamma or Linear Space.
  116989. */
  116990. set fromLinearSpace(value: boolean);
  116991. /**
  116992. * Defines cache preventing GC.
  116993. */
  116994. private _defines;
  116995. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116996. /**
  116997. * "ImageProcessingPostProcess"
  116998. * @returns "ImageProcessingPostProcess"
  116999. */
  117000. getClassName(): string;
  117001. protected _updateParameters(): void;
  117002. dispose(camera?: Camera): void;
  117003. }
  117004. }
  117005. declare module BABYLON {
  117006. /**
  117007. * Class containing static functions to help procedurally build meshes
  117008. */
  117009. export class GroundBuilder {
  117010. /**
  117011. * Creates a ground mesh
  117012. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117013. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117015. * @param name defines the name of the mesh
  117016. * @param options defines the options used to create the mesh
  117017. * @param scene defines the hosting scene
  117018. * @returns the ground mesh
  117019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117020. */
  117021. static CreateGround(name: string, options: {
  117022. width?: number;
  117023. height?: number;
  117024. subdivisions?: number;
  117025. subdivisionsX?: number;
  117026. subdivisionsY?: number;
  117027. updatable?: boolean;
  117028. }, scene: any): Mesh;
  117029. /**
  117030. * Creates a tiled ground mesh
  117031. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117032. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117033. * * 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
  117034. * * 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
  117035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117036. * @param name defines the name of the mesh
  117037. * @param options defines the options used to create the mesh
  117038. * @param scene defines the hosting scene
  117039. * @returns the tiled ground mesh
  117040. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117041. */
  117042. static CreateTiledGround(name: string, options: {
  117043. xmin: number;
  117044. zmin: number;
  117045. xmax: number;
  117046. zmax: number;
  117047. subdivisions?: {
  117048. w: number;
  117049. h: number;
  117050. };
  117051. precision?: {
  117052. w: number;
  117053. h: number;
  117054. };
  117055. updatable?: boolean;
  117056. }, scene?: Nullable<Scene>): Mesh;
  117057. /**
  117058. * Creates a ground mesh from a height map
  117059. * * The parameter `url` sets the URL of the height map image resource.
  117060. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117061. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117062. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117063. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117064. * * 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.
  117065. * * 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).
  117066. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117068. * @param name defines the name of the mesh
  117069. * @param url defines the url to the height map
  117070. * @param options defines the options used to create the mesh
  117071. * @param scene defines the hosting scene
  117072. * @returns the ground mesh
  117073. * @see https://doc.babylonjs.com/babylon101/height_map
  117074. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117075. */
  117076. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117077. width?: number;
  117078. height?: number;
  117079. subdivisions?: number;
  117080. minHeight?: number;
  117081. maxHeight?: number;
  117082. colorFilter?: Color3;
  117083. alphaFilter?: number;
  117084. updatable?: boolean;
  117085. onReady?: (mesh: GroundMesh) => void;
  117086. }, scene?: Nullable<Scene>): GroundMesh;
  117087. }
  117088. }
  117089. declare module BABYLON {
  117090. /**
  117091. * Class containing static functions to help procedurally build meshes
  117092. */
  117093. export class TorusBuilder {
  117094. /**
  117095. * Creates a torus mesh
  117096. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117097. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117098. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117102. * @param name defines the name of the mesh
  117103. * @param options defines the options used to create the mesh
  117104. * @param scene defines the hosting scene
  117105. * @returns the torus mesh
  117106. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117107. */
  117108. static CreateTorus(name: string, options: {
  117109. diameter?: number;
  117110. thickness?: number;
  117111. tessellation?: number;
  117112. updatable?: boolean;
  117113. sideOrientation?: number;
  117114. frontUVs?: Vector4;
  117115. backUVs?: Vector4;
  117116. }, scene: any): Mesh;
  117117. }
  117118. }
  117119. declare module BABYLON {
  117120. /**
  117121. * Class containing static functions to help procedurally build meshes
  117122. */
  117123. export class CylinderBuilder {
  117124. /**
  117125. * Creates a cylinder or a cone mesh
  117126. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117127. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117128. * * 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.
  117129. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117130. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117131. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117132. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117133. * * 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).
  117134. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117135. * * 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).
  117136. * * 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
  117137. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117138. * * 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
  117139. * * 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.
  117140. * * If `enclose` is false, a ring surface is one element.
  117141. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117142. * * 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
  117143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117146. * @param name defines the name of the mesh
  117147. * @param options defines the options used to create the mesh
  117148. * @param scene defines the hosting scene
  117149. * @returns the cylinder mesh
  117150. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117151. */
  117152. static CreateCylinder(name: string, options: {
  117153. height?: number;
  117154. diameterTop?: number;
  117155. diameterBottom?: number;
  117156. diameter?: number;
  117157. tessellation?: number;
  117158. subdivisions?: number;
  117159. arc?: number;
  117160. faceColors?: Color4[];
  117161. faceUV?: Vector4[];
  117162. updatable?: boolean;
  117163. hasRings?: boolean;
  117164. enclose?: boolean;
  117165. cap?: number;
  117166. sideOrientation?: number;
  117167. frontUVs?: Vector4;
  117168. backUVs?: Vector4;
  117169. }, scene: any): Mesh;
  117170. }
  117171. }
  117172. declare module BABYLON {
  117173. /**
  117174. * States of the webXR experience
  117175. */
  117176. export enum WebXRState {
  117177. /**
  117178. * Transitioning to being in XR mode
  117179. */
  117180. ENTERING_XR = 0,
  117181. /**
  117182. * Transitioning to non XR mode
  117183. */
  117184. EXITING_XR = 1,
  117185. /**
  117186. * In XR mode and presenting
  117187. */
  117188. IN_XR = 2,
  117189. /**
  117190. * Not entered XR mode
  117191. */
  117192. NOT_IN_XR = 3
  117193. }
  117194. /**
  117195. * Abstraction of the XR render target
  117196. */
  117197. export interface WebXRRenderTarget extends IDisposable {
  117198. /**
  117199. * xrpresent context of the canvas which can be used to display/mirror xr content
  117200. */
  117201. canvasContext: WebGLRenderingContext;
  117202. /**
  117203. * xr layer for the canvas
  117204. */
  117205. xrLayer: Nullable<XRWebGLLayer>;
  117206. /**
  117207. * Initializes the xr layer for the session
  117208. * @param xrSession xr session
  117209. * @returns a promise that will resolve once the XR Layer has been created
  117210. */
  117211. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117212. }
  117213. }
  117214. declare module BABYLON {
  117215. /**
  117216. * COnfiguration object for WebXR output canvas
  117217. */
  117218. export class WebXRManagedOutputCanvasOptions {
  117219. /**
  117220. * An optional canvas in case you wish to create it yourself and provide it here.
  117221. * If not provided, a new canvas will be created
  117222. */
  117223. canvasElement?: HTMLCanvasElement;
  117224. /**
  117225. * Options for this XR Layer output
  117226. */
  117227. canvasOptions?: XRWebGLLayerOptions;
  117228. /**
  117229. * CSS styling for a newly created canvas (if not provided)
  117230. */
  117231. newCanvasCssStyle?: string;
  117232. /**
  117233. * Get the default values of the configuration object
  117234. * @returns default values of this configuration object
  117235. */
  117236. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117237. }
  117238. /**
  117239. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117240. */
  117241. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117242. private _options;
  117243. private _canvas;
  117244. private _engine;
  117245. /**
  117246. * Rendering context of the canvas which can be used to display/mirror xr content
  117247. */
  117248. canvasContext: WebGLRenderingContext;
  117249. /**
  117250. * xr layer for the canvas
  117251. */
  117252. xrLayer: Nullable<XRWebGLLayer>;
  117253. /**
  117254. * Initializes the canvas to be added/removed upon entering/exiting xr
  117255. * @param _xrSessionManager The XR Session manager
  117256. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117257. */
  117258. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117259. /**
  117260. * Disposes of the object
  117261. */
  117262. dispose(): void;
  117263. /**
  117264. * Initializes the xr layer for the session
  117265. * @param xrSession xr session
  117266. * @returns a promise that will resolve once the XR Layer has been created
  117267. */
  117268. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117269. private _addCanvas;
  117270. private _removeCanvas;
  117271. private _setManagedOutputCanvas;
  117272. }
  117273. }
  117274. declare module BABYLON {
  117275. /**
  117276. * Manages an XRSession to work with Babylon's engine
  117277. * @see https://doc.babylonjs.com/how_to/webxr
  117278. */
  117279. export class WebXRSessionManager implements IDisposable {
  117280. /** The scene which the session should be created for */
  117281. scene: Scene;
  117282. private _referenceSpace;
  117283. private _rttProvider;
  117284. private _sessionEnded;
  117285. private _xrNavigator;
  117286. private baseLayer;
  117287. /**
  117288. * The base reference space from which the session started. good if you want to reset your
  117289. * reference space
  117290. */
  117291. baseReferenceSpace: XRReferenceSpace;
  117292. /**
  117293. * Current XR frame
  117294. */
  117295. currentFrame: Nullable<XRFrame>;
  117296. /** WebXR timestamp updated every frame */
  117297. currentTimestamp: number;
  117298. /**
  117299. * Used just in case of a failure to initialize an immersive session.
  117300. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117301. */
  117302. defaultHeightCompensation: number;
  117303. /**
  117304. * Fires every time a new xrFrame arrives which can be used to update the camera
  117305. */
  117306. onXRFrameObservable: Observable<XRFrame>;
  117307. /**
  117308. * Fires when the reference space changed
  117309. */
  117310. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117311. /**
  117312. * Fires when the xr session is ended either by the device or manually done
  117313. */
  117314. onXRSessionEnded: Observable<any>;
  117315. /**
  117316. * Fires when the xr session is ended either by the device or manually done
  117317. */
  117318. onXRSessionInit: Observable<XRSession>;
  117319. /**
  117320. * Underlying xr session
  117321. */
  117322. session: XRSession;
  117323. /**
  117324. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117325. * or get the offset the player is currently at.
  117326. */
  117327. viewerReferenceSpace: XRReferenceSpace;
  117328. /**
  117329. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117330. * @param scene The scene which the session should be created for
  117331. */
  117332. constructor(
  117333. /** The scene which the session should be created for */
  117334. scene: Scene);
  117335. /**
  117336. * The current reference space used in this session. This reference space can constantly change!
  117337. * It is mainly used to offset the camera's position.
  117338. */
  117339. get referenceSpace(): XRReferenceSpace;
  117340. /**
  117341. * Set a new reference space and triggers the observable
  117342. */
  117343. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117344. /**
  117345. * Disposes of the session manager
  117346. */
  117347. dispose(): void;
  117348. /**
  117349. * Stops the xrSession and restores the render loop
  117350. * @returns Promise which resolves after it exits XR
  117351. */
  117352. exitXRAsync(): Promise<void>;
  117353. /**
  117354. * Gets the correct render target texture to be rendered this frame for this eye
  117355. * @param eye the eye for which to get the render target
  117356. * @returns the render target for the specified eye
  117357. */
  117358. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117359. /**
  117360. * Creates a WebXRRenderTarget object for the XR session
  117361. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117362. * @param options optional options to provide when creating a new render target
  117363. * @returns a WebXR render target to which the session can render
  117364. */
  117365. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117366. /**
  117367. * Initializes the manager
  117368. * After initialization enterXR can be called to start an XR session
  117369. * @returns Promise which resolves after it is initialized
  117370. */
  117371. initializeAsync(): Promise<void>;
  117372. /**
  117373. * Initializes an xr session
  117374. * @param xrSessionMode mode to initialize
  117375. * @param xrSessionInit defines optional and required values to pass to the session builder
  117376. * @returns a promise which will resolve once the session has been initialized
  117377. */
  117378. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117379. /**
  117380. * Checks if a session would be supported for the creation options specified
  117381. * @param sessionMode session mode to check if supported eg. immersive-vr
  117382. * @returns A Promise that resolves to true if supported and false if not
  117383. */
  117384. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117385. /**
  117386. * Resets the reference space to the one started the session
  117387. */
  117388. resetReferenceSpace(): void;
  117389. /**
  117390. * Starts rendering to the xr layer
  117391. */
  117392. runXRRenderLoop(): void;
  117393. /**
  117394. * Sets the reference space on the xr session
  117395. * @param referenceSpaceType space to set
  117396. * @returns a promise that will resolve once the reference space has been set
  117397. */
  117398. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117399. /**
  117400. * Updates the render state of the session
  117401. * @param state state to set
  117402. * @returns a promise that resolves once the render state has been updated
  117403. */
  117404. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117405. /**
  117406. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117407. * @param sessionMode defines the session to test
  117408. * @returns a promise with boolean as final value
  117409. */
  117410. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117411. private _createRenderTargetTexture;
  117412. }
  117413. }
  117414. declare module BABYLON {
  117415. /**
  117416. * WebXR Camera which holds the views for the xrSession
  117417. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117418. */
  117419. export class WebXRCamera extends FreeCamera {
  117420. private _xrSessionManager;
  117421. private _firstFrame;
  117422. private _referenceQuaternion;
  117423. private _referencedPosition;
  117424. private _xrInvPositionCache;
  117425. private _xrInvQuaternionCache;
  117426. /**
  117427. * Should position compensation execute on first frame.
  117428. * This is used when copying the position from a native (non XR) camera
  117429. */
  117430. compensateOnFirstFrame: boolean;
  117431. /**
  117432. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117433. * @param name the name of the camera
  117434. * @param scene the scene to add the camera to
  117435. * @param _xrSessionManager a constructed xr session manager
  117436. */
  117437. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117438. /**
  117439. * Return the user's height, unrelated to the current ground.
  117440. * This will be the y position of this camera, when ground level is 0.
  117441. */
  117442. get realWorldHeight(): number;
  117443. /** @hidden */
  117444. _updateForDualEyeDebugging(): void;
  117445. /**
  117446. * Sets this camera's transformation based on a non-vr camera
  117447. * @param otherCamera the non-vr camera to copy the transformation from
  117448. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117449. */
  117450. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117451. /**
  117452. * Gets the current instance class name ("WebXRCamera").
  117453. * @returns the class name
  117454. */
  117455. getClassName(): string;
  117456. private _updateFromXRSession;
  117457. private _updateNumberOfRigCameras;
  117458. private _updateReferenceSpace;
  117459. private _updateReferenceSpaceOffset;
  117460. }
  117461. }
  117462. declare module BABYLON {
  117463. /**
  117464. * Defining the interface required for a (webxr) feature
  117465. */
  117466. export interface IWebXRFeature extends IDisposable {
  117467. /**
  117468. * Is this feature attached
  117469. */
  117470. attached: boolean;
  117471. /**
  117472. * Should auto-attach be disabled?
  117473. */
  117474. disableAutoAttach: boolean;
  117475. /**
  117476. * Attach the feature to the session
  117477. * Will usually be called by the features manager
  117478. *
  117479. * @param force should attachment be forced (even when already attached)
  117480. * @returns true if successful.
  117481. */
  117482. attach(force?: boolean): boolean;
  117483. /**
  117484. * Detach the feature from the session
  117485. * Will usually be called by the features manager
  117486. *
  117487. * @returns true if successful.
  117488. */
  117489. detach(): boolean;
  117490. }
  117491. /**
  117492. * A list of the currently available features without referencing them
  117493. */
  117494. export class WebXRFeatureName {
  117495. /**
  117496. * The name of the anchor system feature
  117497. */
  117498. static ANCHOR_SYSTEM: string;
  117499. /**
  117500. * The name of the background remover feature
  117501. */
  117502. static BACKGROUND_REMOVER: string;
  117503. /**
  117504. * The name of the hit test feature
  117505. */
  117506. static HIT_TEST: string;
  117507. /**
  117508. * physics impostors for xr controllers feature
  117509. */
  117510. static PHYSICS_CONTROLLERS: string;
  117511. /**
  117512. * The name of the plane detection feature
  117513. */
  117514. static PLANE_DETECTION: string;
  117515. /**
  117516. * The name of the pointer selection feature
  117517. */
  117518. static POINTER_SELECTION: string;
  117519. /**
  117520. * The name of the teleportation feature
  117521. */
  117522. static TELEPORTATION: string;
  117523. }
  117524. /**
  117525. * Defining the constructor of a feature. Used to register the modules.
  117526. */
  117527. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117528. /**
  117529. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117530. * It is mainly used in AR sessions.
  117531. *
  117532. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117533. */
  117534. export class WebXRFeaturesManager implements IDisposable {
  117535. private _xrSessionManager;
  117536. private static readonly _AvailableFeatures;
  117537. private _features;
  117538. /**
  117539. * constructs a new features manages.
  117540. *
  117541. * @param _xrSessionManager an instance of WebXRSessionManager
  117542. */
  117543. constructor(_xrSessionManager: WebXRSessionManager);
  117544. /**
  117545. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117546. * Mainly used internally.
  117547. *
  117548. * @param featureName the name of the feature to register
  117549. * @param constructorFunction the function used to construct the module
  117550. * @param version the (babylon) version of the module
  117551. * @param stable is that a stable version of this module
  117552. */
  117553. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117554. /**
  117555. * Returns a constructor of a specific feature.
  117556. *
  117557. * @param featureName the name of the feature to construct
  117558. * @param version the version of the feature to load
  117559. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117560. * @param options optional options provided to the module.
  117561. * @returns a function that, when called, will return a new instance of this feature
  117562. */
  117563. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117564. /**
  117565. * Can be used to return the list of features currently registered
  117566. *
  117567. * @returns an Array of available features
  117568. */
  117569. static GetAvailableFeatures(): string[];
  117570. /**
  117571. * Gets the versions available for a specific feature
  117572. * @param featureName the name of the feature
  117573. * @returns an array with the available versions
  117574. */
  117575. static GetAvailableVersions(featureName: string): string[];
  117576. /**
  117577. * Return the latest unstable version of this feature
  117578. * @param featureName the name of the feature to search
  117579. * @returns the version number. if not found will return -1
  117580. */
  117581. static GetLatestVersionOfFeature(featureName: string): number;
  117582. /**
  117583. * Return the latest stable version of this feature
  117584. * @param featureName the name of the feature to search
  117585. * @returns the version number. if not found will return -1
  117586. */
  117587. static GetStableVersionOfFeature(featureName: string): number;
  117588. /**
  117589. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117590. * Can be used during a session to start a feature
  117591. * @param featureName the name of feature to attach
  117592. */
  117593. attachFeature(featureName: string): void;
  117594. /**
  117595. * Can be used inside a session or when the session ends to detach a specific feature
  117596. * @param featureName the name of the feature to detach
  117597. */
  117598. detachFeature(featureName: string): void;
  117599. /**
  117600. * Used to disable an already-enabled feature
  117601. * The feature will be disposed and will be recreated once enabled.
  117602. * @param featureName the feature to disable
  117603. * @returns true if disable was successful
  117604. */
  117605. disableFeature(featureName: string | {
  117606. Name: string;
  117607. }): boolean;
  117608. /**
  117609. * dispose this features manager
  117610. */
  117611. dispose(): void;
  117612. /**
  117613. * 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.
  117614. * 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.
  117615. *
  117616. * @param featureName the name of the feature to load or the class of the feature
  117617. * @param version optional version to load. if not provided the latest version will be enabled
  117618. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117619. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117620. * @returns a new constructed feature or throws an error if feature not found.
  117621. */
  117622. enableFeature(featureName: string | {
  117623. Name: string;
  117624. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117625. /**
  117626. * get the implementation of an enabled feature.
  117627. * @param featureName the name of the feature to load
  117628. * @returns the feature class, if found
  117629. */
  117630. getEnabledFeature(featureName: string): IWebXRFeature;
  117631. /**
  117632. * Get the list of enabled features
  117633. * @returns an array of enabled features
  117634. */
  117635. getEnabledFeatures(): string[];
  117636. }
  117637. }
  117638. declare module BABYLON {
  117639. /**
  117640. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117641. * @see https://doc.babylonjs.com/how_to/webxr
  117642. */
  117643. export class WebXRExperienceHelper implements IDisposable {
  117644. private scene;
  117645. private _nonVRCamera;
  117646. private _originalSceneAutoClear;
  117647. private _supported;
  117648. /**
  117649. * Camera used to render xr content
  117650. */
  117651. camera: WebXRCamera;
  117652. /** A features manager for this xr session */
  117653. featuresManager: WebXRFeaturesManager;
  117654. /**
  117655. * Observers registered here will be triggered after the camera's initial transformation is set
  117656. * This can be used to set a different ground level or an extra rotation.
  117657. *
  117658. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117659. * to the position set after this observable is done executing.
  117660. */
  117661. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117662. /**
  117663. * Fires when the state of the experience helper has changed
  117664. */
  117665. onStateChangedObservable: Observable<WebXRState>;
  117666. /** Session manager used to keep track of xr session */
  117667. sessionManager: WebXRSessionManager;
  117668. /**
  117669. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117670. */
  117671. state: WebXRState;
  117672. /**
  117673. * Creates a WebXRExperienceHelper
  117674. * @param scene The scene the helper should be created in
  117675. */
  117676. private constructor();
  117677. /**
  117678. * Creates the experience helper
  117679. * @param scene the scene to attach the experience helper to
  117680. * @returns a promise for the experience helper
  117681. */
  117682. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117683. /**
  117684. * Disposes of the experience helper
  117685. */
  117686. dispose(): void;
  117687. /**
  117688. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117689. * @param sessionMode options for the XR session
  117690. * @param referenceSpaceType frame of reference of the XR session
  117691. * @param renderTarget the output canvas that will be used to enter XR mode
  117692. * @returns promise that resolves after xr mode has entered
  117693. */
  117694. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117695. /**
  117696. * Exits XR mode and returns the scene to its original state
  117697. * @returns promise that resolves after xr mode has exited
  117698. */
  117699. exitXRAsync(): Promise<void>;
  117700. private _nonXRToXRCamera;
  117701. private _setState;
  117702. }
  117703. }
  117704. declare module BABYLON {
  117705. /**
  117706. * X-Y values for axes in WebXR
  117707. */
  117708. export interface IWebXRMotionControllerAxesValue {
  117709. /**
  117710. * The value of the x axis
  117711. */
  117712. x: number;
  117713. /**
  117714. * The value of the y-axis
  117715. */
  117716. y: number;
  117717. }
  117718. /**
  117719. * changed / previous values for the values of this component
  117720. */
  117721. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117722. /**
  117723. * current (this frame) value
  117724. */
  117725. current: T;
  117726. /**
  117727. * previous (last change) value
  117728. */
  117729. previous: T;
  117730. }
  117731. /**
  117732. * Represents changes in the component between current frame and last values recorded
  117733. */
  117734. export interface IWebXRMotionControllerComponentChanges {
  117735. /**
  117736. * will be populated with previous and current values if axes changed
  117737. */
  117738. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117739. /**
  117740. * will be populated with previous and current values if pressed changed
  117741. */
  117742. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117743. /**
  117744. * will be populated with previous and current values if touched changed
  117745. */
  117746. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117747. /**
  117748. * will be populated with previous and current values if value changed
  117749. */
  117750. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117751. }
  117752. /**
  117753. * This class represents a single component (for example button or thumbstick) of a motion controller
  117754. */
  117755. export class WebXRControllerComponent implements IDisposable {
  117756. /**
  117757. * the id of this component
  117758. */
  117759. id: string;
  117760. /**
  117761. * the type of the component
  117762. */
  117763. type: MotionControllerComponentType;
  117764. private _buttonIndex;
  117765. private _axesIndices;
  117766. private _axes;
  117767. private _changes;
  117768. private _currentValue;
  117769. private _hasChanges;
  117770. private _pressed;
  117771. private _touched;
  117772. /**
  117773. * button component type
  117774. */
  117775. static BUTTON_TYPE: MotionControllerComponentType;
  117776. /**
  117777. * squeeze component type
  117778. */
  117779. static SQUEEZE_TYPE: MotionControllerComponentType;
  117780. /**
  117781. * Thumbstick component type
  117782. */
  117783. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117784. /**
  117785. * Touchpad component type
  117786. */
  117787. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117788. /**
  117789. * trigger component type
  117790. */
  117791. static TRIGGER_TYPE: MotionControllerComponentType;
  117792. /**
  117793. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117794. * the axes data changes
  117795. */
  117796. onAxisValueChangedObservable: Observable<{
  117797. x: number;
  117798. y: number;
  117799. }>;
  117800. /**
  117801. * Observers registered here will be triggered when the state of a button changes
  117802. * State change is either pressed / touched / value
  117803. */
  117804. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117805. /**
  117806. * Creates a new component for a motion controller.
  117807. * It is created by the motion controller itself
  117808. *
  117809. * @param id the id of this component
  117810. * @param type the type of the component
  117811. * @param _buttonIndex index in the buttons array of the gamepad
  117812. * @param _axesIndices indices of the values in the axes array of the gamepad
  117813. */
  117814. constructor(
  117815. /**
  117816. * the id of this component
  117817. */
  117818. id: string,
  117819. /**
  117820. * the type of the component
  117821. */
  117822. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117823. /**
  117824. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117825. */
  117826. get axes(): IWebXRMotionControllerAxesValue;
  117827. /**
  117828. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117829. */
  117830. get changes(): IWebXRMotionControllerComponentChanges;
  117831. /**
  117832. * Return whether or not the component changed the last frame
  117833. */
  117834. get hasChanges(): boolean;
  117835. /**
  117836. * is the button currently pressed
  117837. */
  117838. get pressed(): boolean;
  117839. /**
  117840. * is the button currently touched
  117841. */
  117842. get touched(): boolean;
  117843. /**
  117844. * Get the current value of this component
  117845. */
  117846. get value(): number;
  117847. /**
  117848. * Dispose this component
  117849. */
  117850. dispose(): void;
  117851. /**
  117852. * Are there axes correlating to this component
  117853. * @return true is axes data is available
  117854. */
  117855. isAxes(): boolean;
  117856. /**
  117857. * Is this component a button (hence - pressable)
  117858. * @returns true if can be pressed
  117859. */
  117860. isButton(): boolean;
  117861. /**
  117862. * update this component using the gamepad object it is in. Called on every frame
  117863. * @param nativeController the native gamepad controller object
  117864. */
  117865. update(nativeController: IMinimalMotionControllerObject): void;
  117866. }
  117867. }
  117868. declare module BABYLON {
  117869. /**
  117870. * Class used to represent data loading progression
  117871. */
  117872. export class SceneLoaderProgressEvent {
  117873. /** defines if data length to load can be evaluated */
  117874. readonly lengthComputable: boolean;
  117875. /** defines the loaded data length */
  117876. readonly loaded: number;
  117877. /** defines the data length to load */
  117878. readonly total: number;
  117879. /**
  117880. * Create a new progress event
  117881. * @param lengthComputable defines if data length to load can be evaluated
  117882. * @param loaded defines the loaded data length
  117883. * @param total defines the data length to load
  117884. */
  117885. constructor(
  117886. /** defines if data length to load can be evaluated */
  117887. lengthComputable: boolean,
  117888. /** defines the loaded data length */
  117889. loaded: number,
  117890. /** defines the data length to load */
  117891. total: number);
  117892. /**
  117893. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117894. * @param event defines the source event
  117895. * @returns a new SceneLoaderProgressEvent
  117896. */
  117897. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117898. }
  117899. /**
  117900. * Interface used by SceneLoader plugins to define supported file extensions
  117901. */
  117902. export interface ISceneLoaderPluginExtensions {
  117903. /**
  117904. * Defines the list of supported extensions
  117905. */
  117906. [extension: string]: {
  117907. isBinary: boolean;
  117908. };
  117909. }
  117910. /**
  117911. * Interface used by SceneLoader plugin factory
  117912. */
  117913. export interface ISceneLoaderPluginFactory {
  117914. /**
  117915. * Defines the name of the factory
  117916. */
  117917. name: string;
  117918. /**
  117919. * Function called to create a new plugin
  117920. * @return the new plugin
  117921. */
  117922. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117923. /**
  117924. * The callback that returns true if the data can be directly loaded.
  117925. * @param data string containing the file data
  117926. * @returns if the data can be loaded directly
  117927. */
  117928. canDirectLoad?(data: string): boolean;
  117929. }
  117930. /**
  117931. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117932. */
  117933. export interface ISceneLoaderPluginBase {
  117934. /**
  117935. * The friendly name of this plugin.
  117936. */
  117937. name: string;
  117938. /**
  117939. * The file extensions supported by this plugin.
  117940. */
  117941. extensions: string | ISceneLoaderPluginExtensions;
  117942. /**
  117943. * The callback called when loading from a url.
  117944. * @param scene scene loading this url
  117945. * @param url url to load
  117946. * @param onSuccess callback called when the file successfully loads
  117947. * @param onProgress callback called while file is loading (if the server supports this mode)
  117948. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117949. * @param onError callback called when the file fails to load
  117950. * @returns a file request object
  117951. */
  117952. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117953. /**
  117954. * The callback called when loading from a file object.
  117955. * @param scene scene loading this file
  117956. * @param file defines the file to load
  117957. * @param onSuccess defines the callback to call when data is loaded
  117958. * @param onProgress defines the callback to call during loading process
  117959. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117960. * @param onError defines the callback to call when an error occurs
  117961. * @returns a file request object
  117962. */
  117963. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117964. /**
  117965. * The callback that returns true if the data can be directly loaded.
  117966. * @param data string containing the file data
  117967. * @returns if the data can be loaded directly
  117968. */
  117969. canDirectLoad?(data: string): boolean;
  117970. /**
  117971. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117972. * @param scene scene loading this data
  117973. * @param data string containing the data
  117974. * @returns data to pass to the plugin
  117975. */
  117976. directLoad?(scene: Scene, data: string): any;
  117977. /**
  117978. * The callback that allows custom handling of the root url based on the response url.
  117979. * @param rootUrl the original root url
  117980. * @param responseURL the response url if available
  117981. * @returns the new root url
  117982. */
  117983. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117984. }
  117985. /**
  117986. * Interface used to define a SceneLoader plugin
  117987. */
  117988. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117989. /**
  117990. * Import meshes into a scene.
  117991. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117992. * @param scene The scene to import into
  117993. * @param data The data to import
  117994. * @param rootUrl The root url for scene and resources
  117995. * @param meshes The meshes array to import into
  117996. * @param particleSystems The particle systems array to import into
  117997. * @param skeletons The skeletons array to import into
  117998. * @param onError The callback when import fails
  117999. * @returns True if successful or false otherwise
  118000. */
  118001. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  118002. /**
  118003. * Load into a scene.
  118004. * @param scene The scene to load into
  118005. * @param data The data to import
  118006. * @param rootUrl The root url for scene and resources
  118007. * @param onError The callback when import fails
  118008. * @returns True if successful or false otherwise
  118009. */
  118010. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  118011. /**
  118012. * Load into an asset container.
  118013. * @param scene The scene to load into
  118014. * @param data The data to import
  118015. * @param rootUrl The root url for scene and resources
  118016. * @param onError The callback when import fails
  118017. * @returns The loaded asset container
  118018. */
  118019. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  118020. }
  118021. /**
  118022. * Interface used to define an async SceneLoader plugin
  118023. */
  118024. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  118025. /**
  118026. * Import meshes into a scene.
  118027. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118028. * @param scene The scene to import into
  118029. * @param data The data to import
  118030. * @param rootUrl The root url for scene and resources
  118031. * @param onProgress The callback when the load progresses
  118032. * @param fileName Defines the name of the file to load
  118033. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118034. */
  118035. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118036. meshes: AbstractMesh[];
  118037. particleSystems: IParticleSystem[];
  118038. skeletons: Skeleton[];
  118039. animationGroups: AnimationGroup[];
  118040. }>;
  118041. /**
  118042. * Load into a scene.
  118043. * @param scene The scene to load into
  118044. * @param data The data to import
  118045. * @param rootUrl The root url for scene and resources
  118046. * @param onProgress The callback when the load progresses
  118047. * @param fileName Defines the name of the file to load
  118048. * @returns Nothing
  118049. */
  118050. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118051. /**
  118052. * Load into an asset container.
  118053. * @param scene The scene to load into
  118054. * @param data The data to import
  118055. * @param rootUrl The root url for scene and resources
  118056. * @param onProgress The callback when the load progresses
  118057. * @param fileName Defines the name of the file to load
  118058. * @returns The loaded asset container
  118059. */
  118060. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118061. }
  118062. /**
  118063. * Mode that determines how to handle old animation groups before loading new ones.
  118064. */
  118065. export enum SceneLoaderAnimationGroupLoadingMode {
  118066. /**
  118067. * Reset all old animations to initial state then dispose them.
  118068. */
  118069. Clean = 0,
  118070. /**
  118071. * Stop all old animations.
  118072. */
  118073. Stop = 1,
  118074. /**
  118075. * Restart old animations from first frame.
  118076. */
  118077. Sync = 2,
  118078. /**
  118079. * Old animations remains untouched.
  118080. */
  118081. NoSync = 3
  118082. }
  118083. /**
  118084. * Class used to load scene from various file formats using registered plugins
  118085. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118086. */
  118087. export class SceneLoader {
  118088. /**
  118089. * No logging while loading
  118090. */
  118091. static readonly NO_LOGGING: number;
  118092. /**
  118093. * Minimal logging while loading
  118094. */
  118095. static readonly MINIMAL_LOGGING: number;
  118096. /**
  118097. * Summary logging while loading
  118098. */
  118099. static readonly SUMMARY_LOGGING: number;
  118100. /**
  118101. * Detailled logging while loading
  118102. */
  118103. static readonly DETAILED_LOGGING: number;
  118104. /**
  118105. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118106. */
  118107. static get ForceFullSceneLoadingForIncremental(): boolean;
  118108. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118109. /**
  118110. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118111. */
  118112. static get ShowLoadingScreen(): boolean;
  118113. static set ShowLoadingScreen(value: boolean);
  118114. /**
  118115. * Defines the current logging level (while loading the scene)
  118116. * @ignorenaming
  118117. */
  118118. static get loggingLevel(): number;
  118119. static set loggingLevel(value: number);
  118120. /**
  118121. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118122. */
  118123. static get CleanBoneMatrixWeights(): boolean;
  118124. static set CleanBoneMatrixWeights(value: boolean);
  118125. /**
  118126. * Event raised when a plugin is used to load a scene
  118127. */
  118128. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118129. private static _registeredPlugins;
  118130. private static _getDefaultPlugin;
  118131. private static _getPluginForExtension;
  118132. private static _getPluginForDirectLoad;
  118133. private static _getPluginForFilename;
  118134. private static _getDirectLoad;
  118135. private static _loadData;
  118136. private static _getFileInfo;
  118137. /**
  118138. * Gets a plugin that can load the given extension
  118139. * @param extension defines the extension to load
  118140. * @returns a plugin or null if none works
  118141. */
  118142. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118143. /**
  118144. * Gets a boolean indicating that the given extension can be loaded
  118145. * @param extension defines the extension to load
  118146. * @returns true if the extension is supported
  118147. */
  118148. static IsPluginForExtensionAvailable(extension: string): boolean;
  118149. /**
  118150. * Adds a new plugin to the list of registered plugins
  118151. * @param plugin defines the plugin to add
  118152. */
  118153. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118154. /**
  118155. * Import meshes into a scene
  118156. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118157. * @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)
  118158. * @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)
  118159. * @param scene the instance of BABYLON.Scene to append to
  118160. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118161. * @param onProgress a callback with a progress event for each file being loaded
  118162. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118163. * @param pluginExtension the extension used to determine the plugin
  118164. * @returns The loaded plugin
  118165. */
  118166. 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>;
  118167. /**
  118168. * Import meshes into a scene
  118169. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118170. * @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)
  118171. * @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)
  118172. * @param scene the instance of BABYLON.Scene to append to
  118173. * @param onProgress a callback with a progress event for each file being loaded
  118174. * @param pluginExtension the extension used to determine the plugin
  118175. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118176. */
  118177. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118178. meshes: AbstractMesh[];
  118179. particleSystems: IParticleSystem[];
  118180. skeletons: Skeleton[];
  118181. animationGroups: AnimationGroup[];
  118182. }>;
  118183. /**
  118184. * Load a scene
  118185. * @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)
  118186. * @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)
  118187. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118188. * @param onSuccess a callback with the scene when import succeeds
  118189. * @param onProgress a callback with a progress event for each file being loaded
  118190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118191. * @param pluginExtension the extension used to determine the plugin
  118192. * @returns The loaded plugin
  118193. */
  118194. 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>;
  118195. /**
  118196. * Load a scene
  118197. * @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)
  118198. * @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)
  118199. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118200. * @param onProgress a callback with a progress event for each file being loaded
  118201. * @param pluginExtension the extension used to determine the plugin
  118202. * @returns The loaded scene
  118203. */
  118204. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118205. /**
  118206. * Append a scene
  118207. * @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)
  118208. * @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)
  118209. * @param scene is the instance of BABYLON.Scene to append to
  118210. * @param onSuccess a callback with the scene when import succeeds
  118211. * @param onProgress a callback with a progress event for each file being loaded
  118212. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118213. * @param pluginExtension the extension used to determine the plugin
  118214. * @returns The loaded plugin
  118215. */
  118216. 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>;
  118217. /**
  118218. * Append a scene
  118219. * @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)
  118220. * @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)
  118221. * @param scene is the instance of BABYLON.Scene to append to
  118222. * @param onProgress a callback with a progress event for each file being loaded
  118223. * @param pluginExtension the extension used to determine the plugin
  118224. * @returns The given scene
  118225. */
  118226. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118227. /**
  118228. * Load a scene into an asset container
  118229. * @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)
  118230. * @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)
  118231. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118232. * @param onSuccess a callback with the scene when import succeeds
  118233. * @param onProgress a callback with a progress event for each file being loaded
  118234. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118235. * @param pluginExtension the extension used to determine the plugin
  118236. * @returns The loaded plugin
  118237. */
  118238. 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>;
  118239. /**
  118240. * Load a scene into an asset container
  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 (default: empty string)
  118243. * @param scene is the instance of Scene to append to
  118244. * @param onProgress a callback with a progress event for each file being loaded
  118245. * @param pluginExtension the extension used to determine the plugin
  118246. * @returns The loaded asset container
  118247. */
  118248. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118249. /**
  118250. * Import animations from a file into a scene
  118251. * @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)
  118252. * @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)
  118253. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118254. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118255. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118256. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118257. * @param onSuccess a callback with the scene when import succeeds
  118258. * @param onProgress a callback with a progress event for each file being loaded
  118259. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118260. */
  118261. 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;
  118262. /**
  118263. * Import animations from a file into a scene
  118264. * @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)
  118265. * @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)
  118266. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118267. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118268. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118269. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118270. * @param onSuccess a callback with the scene when import succeeds
  118271. * @param onProgress a callback with a progress event for each file being loaded
  118272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118273. * @returns the updated scene with imported animations
  118274. */
  118275. 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>;
  118276. }
  118277. }
  118278. declare module BABYLON {
  118279. /**
  118280. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118281. */
  118282. export type MotionControllerHandness = "none" | "left" | "right";
  118283. /**
  118284. * The type of components available in motion controllers.
  118285. * This is not the name of the component.
  118286. */
  118287. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118288. /**
  118289. * The state of a controller component
  118290. */
  118291. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118292. /**
  118293. * The schema of motion controller layout.
  118294. * No object will be initialized using this interface
  118295. * This is used just to define the profile.
  118296. */
  118297. export interface IMotionControllerLayout {
  118298. /**
  118299. * Path to load the assets. Usually relative to the base path
  118300. */
  118301. assetPath: string;
  118302. /**
  118303. * Available components (unsorted)
  118304. */
  118305. components: {
  118306. /**
  118307. * A map of component Ids
  118308. */
  118309. [componentId: string]: {
  118310. /**
  118311. * The type of input the component outputs
  118312. */
  118313. type: MotionControllerComponentType;
  118314. /**
  118315. * The indices of this component in the gamepad object
  118316. */
  118317. gamepadIndices: {
  118318. /**
  118319. * Index of button
  118320. */
  118321. button?: number;
  118322. /**
  118323. * If available, index of x-axis
  118324. */
  118325. xAxis?: number;
  118326. /**
  118327. * If available, index of y-axis
  118328. */
  118329. yAxis?: number;
  118330. };
  118331. /**
  118332. * The mesh's root node name
  118333. */
  118334. rootNodeName: string;
  118335. /**
  118336. * Animation definitions for this model
  118337. */
  118338. visualResponses: {
  118339. [stateKey: string]: {
  118340. /**
  118341. * What property will be animated
  118342. */
  118343. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118344. /**
  118345. * What states influence this visual response
  118346. */
  118347. states: MotionControllerComponentStateType[];
  118348. /**
  118349. * Type of animation - movement or visibility
  118350. */
  118351. valueNodeProperty: "transform" | "visibility";
  118352. /**
  118353. * Base node name to move. Its position will be calculated according to the min and max nodes
  118354. */
  118355. valueNodeName?: string;
  118356. /**
  118357. * Minimum movement node
  118358. */
  118359. minNodeName?: string;
  118360. /**
  118361. * Max movement node
  118362. */
  118363. maxNodeName?: string;
  118364. };
  118365. };
  118366. /**
  118367. * If touch enabled, what is the name of node to display user feedback
  118368. */
  118369. touchPointNodeName?: string;
  118370. };
  118371. };
  118372. /**
  118373. * Is it xr standard mapping or not
  118374. */
  118375. gamepadMapping: "" | "xr-standard";
  118376. /**
  118377. * Base root node of this entire model
  118378. */
  118379. rootNodeName: string;
  118380. /**
  118381. * Defines the main button component id
  118382. */
  118383. selectComponentId: string;
  118384. }
  118385. /**
  118386. * A definition for the layout map in the input profile
  118387. */
  118388. export interface IMotionControllerLayoutMap {
  118389. /**
  118390. * Layouts with handness type as a key
  118391. */
  118392. [handness: string]: IMotionControllerLayout;
  118393. }
  118394. /**
  118395. * The XR Input profile schema
  118396. * Profiles can be found here:
  118397. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118398. */
  118399. export interface IMotionControllerProfile {
  118400. /**
  118401. * fallback profiles for this profileId
  118402. */
  118403. fallbackProfileIds: string[];
  118404. /**
  118405. * The layout map, with handness as key
  118406. */
  118407. layouts: IMotionControllerLayoutMap;
  118408. /**
  118409. * The id of this profile
  118410. * correlates to the profile(s) in the xrInput.profiles array
  118411. */
  118412. profileId: string;
  118413. }
  118414. /**
  118415. * A helper-interface for the 3 meshes needed for controller button animation
  118416. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118417. */
  118418. export interface IMotionControllerButtonMeshMap {
  118419. /**
  118420. * the mesh that defines the pressed value mesh position.
  118421. * This is used to find the max-position of this button
  118422. */
  118423. pressedMesh: AbstractMesh;
  118424. /**
  118425. * the mesh that defines the unpressed value mesh position.
  118426. * This is used to find the min (or initial) position of this button
  118427. */
  118428. unpressedMesh: AbstractMesh;
  118429. /**
  118430. * The mesh that will be changed when value changes
  118431. */
  118432. valueMesh: AbstractMesh;
  118433. }
  118434. /**
  118435. * A helper-interface for the 3 meshes needed for controller axis animation.
  118436. * This will be expanded when touchpad animations are fully supported
  118437. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118438. */
  118439. export interface IMotionControllerMeshMap {
  118440. /**
  118441. * the mesh that defines the maximum value mesh position.
  118442. */
  118443. maxMesh?: AbstractMesh;
  118444. /**
  118445. * the mesh that defines the minimum value mesh position.
  118446. */
  118447. minMesh?: AbstractMesh;
  118448. /**
  118449. * The mesh that will be changed when axis value changes
  118450. */
  118451. valueMesh: AbstractMesh;
  118452. }
  118453. /**
  118454. * The elements needed for change-detection of the gamepad objects in motion controllers
  118455. */
  118456. export interface IMinimalMotionControllerObject {
  118457. /**
  118458. * Available axes of this controller
  118459. */
  118460. axes: number[];
  118461. /**
  118462. * An array of available buttons
  118463. */
  118464. buttons: Array<{
  118465. /**
  118466. * Value of the button/trigger
  118467. */
  118468. value: number;
  118469. /**
  118470. * If the button/trigger is currently touched
  118471. */
  118472. touched: boolean;
  118473. /**
  118474. * If the button/trigger is currently pressed
  118475. */
  118476. pressed: boolean;
  118477. }>;
  118478. }
  118479. /**
  118480. * An Abstract Motion controller
  118481. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118482. * Each component has an observable to check for changes in value and state
  118483. */
  118484. export abstract class WebXRAbstractMotionController implements IDisposable {
  118485. protected scene: Scene;
  118486. protected layout: IMotionControllerLayout;
  118487. /**
  118488. * The gamepad object correlating to this controller
  118489. */
  118490. gamepadObject: IMinimalMotionControllerObject;
  118491. /**
  118492. * handness (left/right/none) of this controller
  118493. */
  118494. handness: MotionControllerHandness;
  118495. private _initComponent;
  118496. private _modelReady;
  118497. /**
  118498. * A map of components (WebXRControllerComponent) in this motion controller
  118499. * Components have a ComponentType and can also have both button and axis definitions
  118500. */
  118501. readonly components: {
  118502. [id: string]: WebXRControllerComponent;
  118503. };
  118504. /**
  118505. * Disable the model's animation. Can be set at any time.
  118506. */
  118507. disableAnimation: boolean;
  118508. /**
  118509. * Observers registered here will be triggered when the model of this controller is done loading
  118510. */
  118511. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118512. /**
  118513. * The profile id of this motion controller
  118514. */
  118515. abstract profileId: string;
  118516. /**
  118517. * The root mesh of the model. It is null if the model was not yet initialized
  118518. */
  118519. rootMesh: Nullable<AbstractMesh>;
  118520. /**
  118521. * constructs a new abstract motion controller
  118522. * @param scene the scene to which the model of the controller will be added
  118523. * @param layout The profile layout to load
  118524. * @param gamepadObject The gamepad object correlating to this controller
  118525. * @param handness handness (left/right/none) of this controller
  118526. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118527. */
  118528. constructor(scene: Scene, layout: IMotionControllerLayout,
  118529. /**
  118530. * The gamepad object correlating to this controller
  118531. */
  118532. gamepadObject: IMinimalMotionControllerObject,
  118533. /**
  118534. * handness (left/right/none) of this controller
  118535. */
  118536. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118537. /**
  118538. * Dispose this controller, the model mesh and all its components
  118539. */
  118540. dispose(): void;
  118541. /**
  118542. * Returns all components of specific type
  118543. * @param type the type to search for
  118544. * @return an array of components with this type
  118545. */
  118546. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118547. /**
  118548. * get a component based an its component id as defined in layout.components
  118549. * @param id the id of the component
  118550. * @returns the component correlates to the id or undefined if not found
  118551. */
  118552. getComponent(id: string): WebXRControllerComponent;
  118553. /**
  118554. * Get the list of components available in this motion controller
  118555. * @returns an array of strings correlating to available components
  118556. */
  118557. getComponentIds(): string[];
  118558. /**
  118559. * Get the first component of specific type
  118560. * @param type type of component to find
  118561. * @return a controller component or null if not found
  118562. */
  118563. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118564. /**
  118565. * Get the main (Select) component of this controller as defined in the layout
  118566. * @returns the main component of this controller
  118567. */
  118568. getMainComponent(): WebXRControllerComponent;
  118569. /**
  118570. * Loads the model correlating to this controller
  118571. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118572. * @returns A promise fulfilled with the result of the model loading
  118573. */
  118574. loadModel(): Promise<boolean>;
  118575. /**
  118576. * Update this model using the current XRFrame
  118577. * @param xrFrame the current xr frame to use and update the model
  118578. */
  118579. updateFromXRFrame(xrFrame: XRFrame): void;
  118580. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118581. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118582. /**
  118583. * Moves the axis on the controller mesh based on its current state
  118584. * @param axis the index of the axis
  118585. * @param axisValue the value of the axis which determines the meshes new position
  118586. * @hidden
  118587. */
  118588. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118589. /**
  118590. * Update the model itself with the current frame data
  118591. * @param xrFrame the frame to use for updating the model mesh
  118592. */
  118593. protected updateModel(xrFrame: XRFrame): void;
  118594. /**
  118595. * Get the filename and path for this controller's model
  118596. * @returns a map of filename and path
  118597. */
  118598. protected abstract _getFilenameAndPath(): {
  118599. filename: string;
  118600. path: string;
  118601. };
  118602. /**
  118603. * This function is called before the mesh is loaded. It checks for loading constraints.
  118604. * For example, this function can check if the GLB loader is available
  118605. * If this function returns false, the generic controller will be loaded instead
  118606. * @returns Is the client ready to load the mesh
  118607. */
  118608. protected abstract _getModelLoadingConstraints(): boolean;
  118609. /**
  118610. * This function will be called after the model was successfully loaded and can be used
  118611. * for mesh transformations before it is available for the user
  118612. * @param meshes the loaded meshes
  118613. */
  118614. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118615. /**
  118616. * Set the root mesh for this controller. Important for the WebXR controller class
  118617. * @param meshes the loaded meshes
  118618. */
  118619. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118620. /**
  118621. * A function executed each frame that updates the mesh (if needed)
  118622. * @param xrFrame the current xrFrame
  118623. */
  118624. protected abstract _updateModel(xrFrame: XRFrame): void;
  118625. private _getGenericFilenameAndPath;
  118626. private _getGenericParentMesh;
  118627. }
  118628. }
  118629. declare module BABYLON {
  118630. /**
  118631. * A generic trigger-only motion controller for WebXR
  118632. */
  118633. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118634. /**
  118635. * Static version of the profile id of this controller
  118636. */
  118637. static ProfileId: string;
  118638. profileId: string;
  118639. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118640. protected _getFilenameAndPath(): {
  118641. filename: string;
  118642. path: string;
  118643. };
  118644. protected _getModelLoadingConstraints(): boolean;
  118645. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118646. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118647. protected _updateModel(): void;
  118648. }
  118649. }
  118650. declare module BABYLON {
  118651. /**
  118652. * Class containing static functions to help procedurally build meshes
  118653. */
  118654. export class SphereBuilder {
  118655. /**
  118656. * Creates a sphere mesh
  118657. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118658. * * 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`)
  118659. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118660. * * 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
  118661. * * 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)
  118662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118665. * @param name defines the name of the mesh
  118666. * @param options defines the options used to create the mesh
  118667. * @param scene defines the hosting scene
  118668. * @returns the sphere mesh
  118669. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118670. */
  118671. static CreateSphere(name: string, options: {
  118672. segments?: number;
  118673. diameter?: number;
  118674. diameterX?: number;
  118675. diameterY?: number;
  118676. diameterZ?: number;
  118677. arc?: number;
  118678. slice?: number;
  118679. sideOrientation?: number;
  118680. frontUVs?: Vector4;
  118681. backUVs?: Vector4;
  118682. updatable?: boolean;
  118683. }, scene?: Nullable<Scene>): Mesh;
  118684. }
  118685. }
  118686. declare module BABYLON {
  118687. /**
  118688. * A profiled motion controller has its profile loaded from an online repository.
  118689. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118690. */
  118691. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118692. private _repositoryUrl;
  118693. private _buttonMeshMapping;
  118694. private _touchDots;
  118695. /**
  118696. * The profile ID of this controller. Will be populated when the controller initializes.
  118697. */
  118698. profileId: string;
  118699. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118700. dispose(): void;
  118701. protected _getFilenameAndPath(): {
  118702. filename: string;
  118703. path: string;
  118704. };
  118705. protected _getModelLoadingConstraints(): boolean;
  118706. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118707. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118708. protected _updateModel(_xrFrame: XRFrame): void;
  118709. }
  118710. }
  118711. declare module BABYLON {
  118712. /**
  118713. * A construction function type to create a new controller based on an xrInput object
  118714. */
  118715. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118716. /**
  118717. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118718. *
  118719. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118720. * it should be replaced with auto-loaded controllers.
  118721. *
  118722. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118723. */
  118724. export class WebXRMotionControllerManager {
  118725. private static _AvailableControllers;
  118726. private static _Fallbacks;
  118727. private static _ProfileLoadingPromises;
  118728. private static _ProfilesList;
  118729. /**
  118730. * The base URL of the online controller repository. Can be changed at any time.
  118731. */
  118732. static BaseRepositoryUrl: string;
  118733. /**
  118734. * Which repository gets priority - local or online
  118735. */
  118736. static PrioritizeOnlineRepository: boolean;
  118737. /**
  118738. * Use the online repository, or use only locally-defined controllers
  118739. */
  118740. static UseOnlineRepository: boolean;
  118741. /**
  118742. * Clear the cache used for profile loading and reload when requested again
  118743. */
  118744. static ClearProfilesCache(): void;
  118745. /**
  118746. * Register the default fallbacks.
  118747. * This function is called automatically when this file is imported.
  118748. */
  118749. static DefaultFallbacks(): void;
  118750. /**
  118751. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118752. * @param profileId the profile to which a fallback needs to be found
  118753. * @return an array with corresponding fallback profiles
  118754. */
  118755. static FindFallbackWithProfileId(profileId: string): string[];
  118756. /**
  118757. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118758. * The order of search:
  118759. *
  118760. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118761. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118762. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118763. * 4) return the generic trigger controller if none were found
  118764. *
  118765. * @param xrInput the xrInput to which a new controller is initialized
  118766. * @param scene the scene to which the model will be added
  118767. * @param forceProfile force a certain profile for this controller
  118768. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118769. */
  118770. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118771. /**
  118772. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118773. *
  118774. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118775. *
  118776. * @param type the profile type to register
  118777. * @param constructFunction the function to be called when loading this profile
  118778. */
  118779. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118780. /**
  118781. * Register a fallback to a specific profile.
  118782. * @param profileId the profileId that will receive the fallbacks
  118783. * @param fallbacks A list of fallback profiles
  118784. */
  118785. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118786. /**
  118787. * Will update the list of profiles available in the repository
  118788. * @return a promise that resolves to a map of profiles available online
  118789. */
  118790. static UpdateProfilesList(): Promise<{
  118791. [profile: string]: string;
  118792. }>;
  118793. private static _LoadProfileFromRepository;
  118794. private static _LoadProfilesFromAvailableControllers;
  118795. }
  118796. }
  118797. declare module BABYLON {
  118798. /**
  118799. * Configuration options for the WebXR controller creation
  118800. */
  118801. export interface IWebXRControllerOptions {
  118802. /**
  118803. * Should the controller mesh be animated when a user interacts with it
  118804. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118805. */
  118806. disableMotionControllerAnimation?: boolean;
  118807. /**
  118808. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118809. */
  118810. doNotLoadControllerMesh?: boolean;
  118811. /**
  118812. * Force a specific controller type for this controller.
  118813. * This can be used when creating your own profile or when testing different controllers
  118814. */
  118815. forceControllerProfile?: string;
  118816. }
  118817. /**
  118818. * Represents an XR controller
  118819. */
  118820. export class WebXRInputSource {
  118821. private _scene;
  118822. /** The underlying input source for the controller */
  118823. inputSource: XRInputSource;
  118824. private _options;
  118825. private _tmpQuaternion;
  118826. private _tmpVector;
  118827. private _uniqueId;
  118828. /**
  118829. * 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
  118830. */
  118831. grip?: AbstractMesh;
  118832. /**
  118833. * If available, this is the gamepad object related to this controller.
  118834. * Using this object it is possible to get click events and trackpad changes of the
  118835. * webxr controller that is currently being used.
  118836. */
  118837. motionController?: WebXRAbstractMotionController;
  118838. /**
  118839. * Event that fires when the controller is removed/disposed.
  118840. * The object provided as event data is this controller, after associated assets were disposed.
  118841. * uniqueId is still available.
  118842. */
  118843. onDisposeObservable: Observable<WebXRInputSource>;
  118844. /**
  118845. * Will be triggered when the mesh associated with the motion controller is done loading.
  118846. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118847. * A shortened version of controller -> motion controller -> on mesh loaded.
  118848. */
  118849. onMeshLoadedObservable: Observable<AbstractMesh>;
  118850. /**
  118851. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118852. */
  118853. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118854. /**
  118855. * Pointer which can be used to select objects or attach a visible laser to
  118856. */
  118857. pointer: AbstractMesh;
  118858. /**
  118859. * Creates the controller
  118860. * @see https://doc.babylonjs.com/how_to/webxr
  118861. * @param _scene the scene which the controller should be associated to
  118862. * @param inputSource the underlying input source for the controller
  118863. * @param _options options for this controller creation
  118864. */
  118865. constructor(_scene: Scene,
  118866. /** The underlying input source for the controller */
  118867. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118868. /**
  118869. * Get this controllers unique id
  118870. */
  118871. get uniqueId(): string;
  118872. /**
  118873. * Disposes of the object
  118874. */
  118875. dispose(): void;
  118876. /**
  118877. * Gets a world space ray coming from the pointer or grip
  118878. * @param result the resulting ray
  118879. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118880. */
  118881. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118882. /**
  118883. * Updates the controller pose based on the given XRFrame
  118884. * @param xrFrame xr frame to update the pose with
  118885. * @param referenceSpace reference space to use
  118886. */
  118887. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118888. }
  118889. }
  118890. declare module BABYLON {
  118891. /**
  118892. * The schema for initialization options of the XR Input class
  118893. */
  118894. export interface IWebXRInputOptions {
  118895. /**
  118896. * If set to true no model will be automatically loaded
  118897. */
  118898. doNotLoadControllerMeshes?: boolean;
  118899. /**
  118900. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118901. * If not found, the xr input profile data will be used.
  118902. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118903. */
  118904. forceInputProfile?: string;
  118905. /**
  118906. * Do not send a request to the controller repository to load the profile.
  118907. *
  118908. * Instead, use the controllers available in babylon itself.
  118909. */
  118910. disableOnlineControllerRepository?: boolean;
  118911. /**
  118912. * A custom URL for the controllers repository
  118913. */
  118914. customControllersRepositoryURL?: string;
  118915. /**
  118916. * Should the controller model's components not move according to the user input
  118917. */
  118918. disableControllerAnimation?: boolean;
  118919. }
  118920. /**
  118921. * XR input used to track XR inputs such as controllers/rays
  118922. */
  118923. export class WebXRInput implements IDisposable {
  118924. /**
  118925. * the xr session manager for this session
  118926. */
  118927. xrSessionManager: WebXRSessionManager;
  118928. /**
  118929. * the WebXR camera for this session. Mainly used for teleportation
  118930. */
  118931. xrCamera: WebXRCamera;
  118932. private readonly options;
  118933. /**
  118934. * XR controllers being tracked
  118935. */
  118936. controllers: Array<WebXRInputSource>;
  118937. private _frameObserver;
  118938. private _sessionEndedObserver;
  118939. private _sessionInitObserver;
  118940. /**
  118941. * Event when a controller has been connected/added
  118942. */
  118943. onControllerAddedObservable: Observable<WebXRInputSource>;
  118944. /**
  118945. * Event when a controller has been removed/disconnected
  118946. */
  118947. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118948. /**
  118949. * Initializes the WebXRInput
  118950. * @param xrSessionManager the xr session manager for this session
  118951. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118952. * @param options = initialization options for this xr input
  118953. */
  118954. constructor(
  118955. /**
  118956. * the xr session manager for this session
  118957. */
  118958. xrSessionManager: WebXRSessionManager,
  118959. /**
  118960. * the WebXR camera for this session. Mainly used for teleportation
  118961. */
  118962. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118963. private _onInputSourcesChange;
  118964. private _addAndRemoveControllers;
  118965. /**
  118966. * Disposes of the object
  118967. */
  118968. dispose(): void;
  118969. }
  118970. }
  118971. declare module BABYLON {
  118972. /**
  118973. * This is the base class for all WebXR features.
  118974. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118975. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118976. */
  118977. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118978. protected _xrSessionManager: WebXRSessionManager;
  118979. private _attached;
  118980. private _removeOnDetach;
  118981. /**
  118982. * Should auto-attach be disabled?
  118983. */
  118984. disableAutoAttach: boolean;
  118985. /**
  118986. * Construct a new (abstract) WebXR feature
  118987. * @param _xrSessionManager the xr session manager for this feature
  118988. */
  118989. constructor(_xrSessionManager: WebXRSessionManager);
  118990. /**
  118991. * Is this feature attached
  118992. */
  118993. get attached(): boolean;
  118994. /**
  118995. * attach this feature
  118996. *
  118997. * @param force should attachment be forced (even when already attached)
  118998. * @returns true if successful, false is failed or already attached
  118999. */
  119000. attach(force?: boolean): boolean;
  119001. /**
  119002. * detach this feature.
  119003. *
  119004. * @returns true if successful, false if failed or already detached
  119005. */
  119006. detach(): boolean;
  119007. /**
  119008. * Dispose this feature and all of the resources attached
  119009. */
  119010. dispose(): void;
  119011. /**
  119012. * This is used to register callbacks that will automatically be removed when detach is called.
  119013. * @param observable the observable to which the observer will be attached
  119014. * @param callback the callback to register
  119015. */
  119016. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  119017. /**
  119018. * Code in this function will be executed on each xrFrame received from the browser.
  119019. * This function will not execute after the feature is detached.
  119020. * @param _xrFrame the current frame
  119021. */
  119022. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  119023. }
  119024. }
  119025. declare module BABYLON {
  119026. /**
  119027. * Renders a layer on top of an existing scene
  119028. */
  119029. export class UtilityLayerRenderer implements IDisposable {
  119030. /** the original scene that will be rendered on top of */
  119031. originalScene: Scene;
  119032. private _pointerCaptures;
  119033. private _lastPointerEvents;
  119034. private static _DefaultUtilityLayer;
  119035. private static _DefaultKeepDepthUtilityLayer;
  119036. private _sharedGizmoLight;
  119037. private _renderCamera;
  119038. /**
  119039. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119040. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119041. * @returns the camera that is used when rendering the utility layer
  119042. */
  119043. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119044. /**
  119045. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119046. * @param cam the camera that should be used when rendering the utility layer
  119047. */
  119048. setRenderCamera(cam: Nullable<Camera>): void;
  119049. /**
  119050. * @hidden
  119051. * Light which used by gizmos to get light shading
  119052. */
  119053. _getSharedGizmoLight(): HemisphericLight;
  119054. /**
  119055. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119056. */
  119057. pickUtilitySceneFirst: boolean;
  119058. /**
  119059. * 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)
  119060. */
  119061. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119062. /**
  119063. * 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)
  119064. */
  119065. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119066. /**
  119067. * The scene that is rendered on top of the original scene
  119068. */
  119069. utilityLayerScene: Scene;
  119070. /**
  119071. * If the utility layer should automatically be rendered on top of existing scene
  119072. */
  119073. shouldRender: boolean;
  119074. /**
  119075. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119076. */
  119077. onlyCheckPointerDownEvents: boolean;
  119078. /**
  119079. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119080. */
  119081. processAllEvents: boolean;
  119082. /**
  119083. * Observable raised when the pointer move from the utility layer scene to the main scene
  119084. */
  119085. onPointerOutObservable: Observable<number>;
  119086. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119087. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119088. private _afterRenderObserver;
  119089. private _sceneDisposeObserver;
  119090. private _originalPointerObserver;
  119091. /**
  119092. * Instantiates a UtilityLayerRenderer
  119093. * @param originalScene the original scene that will be rendered on top of
  119094. * @param handleEvents boolean indicating if the utility layer should handle events
  119095. */
  119096. constructor(
  119097. /** the original scene that will be rendered on top of */
  119098. originalScene: Scene, handleEvents?: boolean);
  119099. private _notifyObservers;
  119100. /**
  119101. * Renders the utility layers scene on top of the original scene
  119102. */
  119103. render(): void;
  119104. /**
  119105. * Disposes of the renderer
  119106. */
  119107. dispose(): void;
  119108. private _updateCamera;
  119109. }
  119110. }
  119111. declare module BABYLON {
  119112. /**
  119113. * Options interface for the pointer selection module
  119114. */
  119115. export interface IWebXRControllerPointerSelectionOptions {
  119116. /**
  119117. * if provided, this scene will be used to render meshes.
  119118. */
  119119. customUtilityLayerScene?: Scene;
  119120. /**
  119121. * 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)
  119122. * If not disabled, the last picked point will be used to execute a pointer up event
  119123. * If disabled, pointer up event will be triggered right after the pointer down event.
  119124. * Used in screen and gaze target ray mode only
  119125. */
  119126. disablePointerUpOnTouchOut: boolean;
  119127. /**
  119128. * For gaze mode (time to select instead of press)
  119129. */
  119130. forceGazeMode: boolean;
  119131. /**
  119132. * 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
  119133. * to start a new countdown to the pointer down event.
  119134. * Defaults to 1.
  119135. */
  119136. gazeModePointerMovedFactor?: number;
  119137. /**
  119138. * Different button type to use instead of the main component
  119139. */
  119140. overrideButtonId?: string;
  119141. /**
  119142. * use this rendering group id for the meshes (optional)
  119143. */
  119144. renderingGroupId?: number;
  119145. /**
  119146. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119147. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119148. * 3000 means 3 seconds between pointing at something and selecting it
  119149. */
  119150. timeToSelect?: number;
  119151. /**
  119152. * Should meshes created here be added to a utility layer or the main scene
  119153. */
  119154. useUtilityLayer?: boolean;
  119155. /**
  119156. * the xr input to use with this pointer selection
  119157. */
  119158. xrInput: WebXRInput;
  119159. }
  119160. /**
  119161. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119162. */
  119163. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119164. private readonly _options;
  119165. private static _idCounter;
  119166. private _attachController;
  119167. private _controllers;
  119168. private _scene;
  119169. private _tmpVectorForPickCompare;
  119170. /**
  119171. * The module's name
  119172. */
  119173. static readonly Name: string;
  119174. /**
  119175. * The (Babylon) version of this module.
  119176. * This is an integer representing the implementation version.
  119177. * This number does not correspond to the WebXR specs version
  119178. */
  119179. static readonly Version: number;
  119180. /**
  119181. * Disable lighting on the laser pointer (so it will always be visible)
  119182. */
  119183. disablePointerLighting: boolean;
  119184. /**
  119185. * Disable lighting on the selection mesh (so it will always be visible)
  119186. */
  119187. disableSelectionMeshLighting: boolean;
  119188. /**
  119189. * Should the laser pointer be displayed
  119190. */
  119191. displayLaserPointer: boolean;
  119192. /**
  119193. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119194. */
  119195. displaySelectionMesh: boolean;
  119196. /**
  119197. * This color will be set to the laser pointer when selection is triggered
  119198. */
  119199. laserPointerPickedColor: Color3;
  119200. /**
  119201. * Default color of the laser pointer
  119202. */
  119203. lasterPointerDefaultColor: Color3;
  119204. /**
  119205. * default color of the selection ring
  119206. */
  119207. selectionMeshDefaultColor: Color3;
  119208. /**
  119209. * This color will be applied to the selection ring when selection is triggered
  119210. */
  119211. selectionMeshPickedColor: Color3;
  119212. /**
  119213. * Optional filter to be used for ray selection. This predicate shares behavior with
  119214. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119215. */
  119216. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119217. /**
  119218. * constructs a new background remover module
  119219. * @param _xrSessionManager the session manager for this module
  119220. * @param _options read-only options to be used in this module
  119221. */
  119222. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119223. /**
  119224. * attach this feature
  119225. * Will usually be called by the features manager
  119226. *
  119227. * @returns true if successful.
  119228. */
  119229. attach(): boolean;
  119230. /**
  119231. * detach this feature.
  119232. * Will usually be called by the features manager
  119233. *
  119234. * @returns true if successful.
  119235. */
  119236. detach(): boolean;
  119237. /**
  119238. * Will get the mesh under a specific pointer.
  119239. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119240. * @param controllerId the controllerId to check
  119241. * @returns The mesh under pointer or null if no mesh is under the pointer
  119242. */
  119243. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119244. /**
  119245. * Get the xr controller that correlates to the pointer id in the pointer event
  119246. *
  119247. * @param id the pointer id to search for
  119248. * @returns the controller that correlates to this id or null if not found
  119249. */
  119250. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119251. protected _onXRFrame(_xrFrame: XRFrame): void;
  119252. private _attachGazeMode;
  119253. private _attachScreenRayMode;
  119254. private _attachTrackedPointerRayMode;
  119255. private _convertNormalToDirectionOfRay;
  119256. private _detachController;
  119257. private _generateNewMeshPair;
  119258. private _pickingMoved;
  119259. private _updatePointerDistance;
  119260. }
  119261. }
  119262. declare module BABYLON {
  119263. /**
  119264. * Button which can be used to enter a different mode of XR
  119265. */
  119266. export class WebXREnterExitUIButton {
  119267. /** button element */
  119268. element: HTMLElement;
  119269. /** XR initialization options for the button */
  119270. sessionMode: XRSessionMode;
  119271. /** Reference space type */
  119272. referenceSpaceType: XRReferenceSpaceType;
  119273. /**
  119274. * Creates a WebXREnterExitUIButton
  119275. * @param element button element
  119276. * @param sessionMode XR initialization session mode
  119277. * @param referenceSpaceType the type of reference space to be used
  119278. */
  119279. constructor(
  119280. /** button element */
  119281. element: HTMLElement,
  119282. /** XR initialization options for the button */
  119283. sessionMode: XRSessionMode,
  119284. /** Reference space type */
  119285. referenceSpaceType: XRReferenceSpaceType);
  119286. /**
  119287. * Extendable function which can be used to update the button's visuals when the state changes
  119288. * @param activeButton the current active button in the UI
  119289. */
  119290. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119291. }
  119292. /**
  119293. * Options to create the webXR UI
  119294. */
  119295. export class WebXREnterExitUIOptions {
  119296. /**
  119297. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119298. */
  119299. customButtons?: Array<WebXREnterExitUIButton>;
  119300. /**
  119301. * A reference space type to use when creating the default button.
  119302. * Default is local-floor
  119303. */
  119304. referenceSpaceType?: XRReferenceSpaceType;
  119305. /**
  119306. * Context to enter xr with
  119307. */
  119308. renderTarget?: Nullable<WebXRRenderTarget>;
  119309. /**
  119310. * A session mode to use when creating the default button.
  119311. * Default is immersive-vr
  119312. */
  119313. sessionMode?: XRSessionMode;
  119314. }
  119315. /**
  119316. * UI to allow the user to enter/exit XR mode
  119317. */
  119318. export class WebXREnterExitUI implements IDisposable {
  119319. private scene;
  119320. /** version of the options passed to this UI */
  119321. options: WebXREnterExitUIOptions;
  119322. private _activeButton;
  119323. private _buttons;
  119324. private _overlay;
  119325. /**
  119326. * Fired every time the active button is changed.
  119327. *
  119328. * When xr is entered via a button that launches xr that button will be the callback parameter
  119329. *
  119330. * When exiting xr the callback parameter will be null)
  119331. */
  119332. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119333. /**
  119334. *
  119335. * @param scene babylon scene object to use
  119336. * @param options (read-only) version of the options passed to this UI
  119337. */
  119338. private constructor();
  119339. /**
  119340. * Creates UI to allow the user to enter/exit XR mode
  119341. * @param scene the scene to add the ui to
  119342. * @param helper the xr experience helper to enter/exit xr with
  119343. * @param options options to configure the UI
  119344. * @returns the created ui
  119345. */
  119346. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119347. /**
  119348. * Disposes of the XR UI component
  119349. */
  119350. dispose(): void;
  119351. private _updateButtons;
  119352. }
  119353. }
  119354. declare module BABYLON {
  119355. /**
  119356. * Class containing static functions to help procedurally build meshes
  119357. */
  119358. export class LinesBuilder {
  119359. /**
  119360. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119361. * * 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
  119362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119363. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119364. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119365. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119367. * * 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
  119368. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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#line-system
  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 system mesh
  119375. */
  119376. static CreateLineSystem(name: string, options: {
  119377. lines: Vector3[][];
  119378. updatable?: boolean;
  119379. instance?: Nullable<LinesMesh>;
  119380. colors?: Nullable<Color4[][]>;
  119381. useVertexAlpha?: boolean;
  119382. }, scene: Nullable<Scene>): LinesMesh;
  119383. /**
  119384. * Creates a line mesh
  119385. * 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
  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 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
  119389. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119391. * * When updating an instance, remember that only point positions can change, not the number of points
  119392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119394. * @param name defines the name of the new line system
  119395. * @param options defines the options used to create the line system
  119396. * @param scene defines the hosting scene
  119397. * @returns a new line mesh
  119398. */
  119399. static CreateLines(name: string, options: {
  119400. points: Vector3[];
  119401. updatable?: boolean;
  119402. instance?: Nullable<LinesMesh>;
  119403. colors?: Color4[];
  119404. useVertexAlpha?: boolean;
  119405. }, scene?: Nullable<Scene>): LinesMesh;
  119406. /**
  119407. * Creates a dashed line mesh
  119408. * * 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
  119409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119410. * * The parameter `points` is an array successive Vector3
  119411. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119412. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119413. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119414. * * 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
  119415. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119416. * * When updating an instance, remember that only point positions can change, not the number of points
  119417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119418. * @param name defines the name of the mesh
  119419. * @param options defines the options used to create the mesh
  119420. * @param scene defines the hosting scene
  119421. * @returns the dashed line mesh
  119422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119423. */
  119424. static CreateDashedLines(name: string, options: {
  119425. points: Vector3[];
  119426. dashSize?: number;
  119427. gapSize?: number;
  119428. dashNb?: number;
  119429. updatable?: boolean;
  119430. instance?: LinesMesh;
  119431. useVertexAlpha?: boolean;
  119432. }, scene?: Nullable<Scene>): LinesMesh;
  119433. }
  119434. }
  119435. declare module BABYLON {
  119436. /**
  119437. * The options container for the teleportation module
  119438. */
  119439. export interface IWebXRTeleportationOptions {
  119440. /**
  119441. * if provided, this scene will be used to render meshes.
  119442. */
  119443. customUtilityLayerScene?: Scene;
  119444. /**
  119445. * Values to configure the default target mesh
  119446. */
  119447. defaultTargetMeshOptions?: {
  119448. /**
  119449. * Fill color of the teleportation area
  119450. */
  119451. teleportationFillColor?: string;
  119452. /**
  119453. * Border color for the teleportation area
  119454. */
  119455. teleportationBorderColor?: string;
  119456. /**
  119457. * Disable the mesh's animation sequence
  119458. */
  119459. disableAnimation?: boolean;
  119460. /**
  119461. * Disable lighting on the material or the ring and arrow
  119462. */
  119463. disableLighting?: boolean;
  119464. /**
  119465. * Override the default material of the torus and arrow
  119466. */
  119467. torusArrowMaterial?: Material;
  119468. };
  119469. /**
  119470. * A list of meshes to use as floor meshes.
  119471. * Meshes can be added and removed after initializing the feature using the
  119472. * addFloorMesh and removeFloorMesh functions
  119473. * If empty, rotation will still work
  119474. */
  119475. floorMeshes?: AbstractMesh[];
  119476. /**
  119477. * use this rendering group id for the meshes (optional)
  119478. */
  119479. renderingGroupId?: number;
  119480. /**
  119481. * Should teleportation move only to snap points
  119482. */
  119483. snapPointsOnly?: boolean;
  119484. /**
  119485. * An array of points to which the teleportation will snap to.
  119486. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119487. */
  119488. snapPositions?: Vector3[];
  119489. /**
  119490. * How close should the teleportation ray be in order to snap to position.
  119491. * Default to 0.8 units (meters)
  119492. */
  119493. snapToPositionRadius?: number;
  119494. /**
  119495. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119496. * If you want to support rotation, make sure your mesh has a direction indicator.
  119497. *
  119498. * When left untouched, the default mesh will be initialized.
  119499. */
  119500. teleportationTargetMesh?: AbstractMesh;
  119501. /**
  119502. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119503. */
  119504. timeToTeleport?: number;
  119505. /**
  119506. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119507. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119508. */
  119509. useMainComponentOnly?: boolean;
  119510. /**
  119511. * Should meshes created here be added to a utility layer or the main scene
  119512. */
  119513. useUtilityLayer?: boolean;
  119514. /**
  119515. * Babylon XR Input class for controller
  119516. */
  119517. xrInput: WebXRInput;
  119518. }
  119519. /**
  119520. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119521. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119522. * the input of the attached controllers.
  119523. */
  119524. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119525. private _options;
  119526. private _controllers;
  119527. private _currentTeleportationControllerId;
  119528. private _floorMeshes;
  119529. private _quadraticBezierCurve;
  119530. private _selectionFeature;
  119531. private _snapToPositions;
  119532. private _snappedToPoint;
  119533. private _teleportationRingMaterial?;
  119534. private _tmpRay;
  119535. private _tmpVector;
  119536. /**
  119537. * The module's name
  119538. */
  119539. static readonly Name: string;
  119540. /**
  119541. * The (Babylon) version of this module.
  119542. * This is an integer representing the implementation version.
  119543. * This number does not correspond to the webxr specs version
  119544. */
  119545. static readonly Version: number;
  119546. /**
  119547. * Is movement backwards enabled
  119548. */
  119549. backwardsMovementEnabled: boolean;
  119550. /**
  119551. * Distance to travel when moving backwards
  119552. */
  119553. backwardsTeleportationDistance: number;
  119554. /**
  119555. * The distance from the user to the inspection point in the direction of the controller
  119556. * A higher number will allow the user to move further
  119557. * defaults to 5 (meters, in xr units)
  119558. */
  119559. parabolicCheckRadius: number;
  119560. /**
  119561. * Should the module support parabolic ray on top of direct ray
  119562. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119563. * Very helpful when moving between floors / different heights
  119564. */
  119565. parabolicRayEnabled: boolean;
  119566. /**
  119567. * How much rotation should be applied when rotating right and left
  119568. */
  119569. rotationAngle: number;
  119570. /**
  119571. * Is rotation enabled when moving forward?
  119572. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119573. */
  119574. rotationEnabled: boolean;
  119575. /**
  119576. * constructs a new anchor system
  119577. * @param _xrSessionManager an instance of WebXRSessionManager
  119578. * @param _options configuration object for this feature
  119579. */
  119580. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119581. /**
  119582. * Get the snapPointsOnly flag
  119583. */
  119584. get snapPointsOnly(): boolean;
  119585. /**
  119586. * Sets the snapPointsOnly flag
  119587. * @param snapToPoints should teleportation be exclusively to snap points
  119588. */
  119589. set snapPointsOnly(snapToPoints: boolean);
  119590. /**
  119591. * Add a new mesh to the floor meshes array
  119592. * @param mesh the mesh to use as floor mesh
  119593. */
  119594. addFloorMesh(mesh: AbstractMesh): void;
  119595. /**
  119596. * Add a new snap-to point to fix teleportation to this position
  119597. * @param newSnapPoint The new Snap-To point
  119598. */
  119599. addSnapPoint(newSnapPoint: Vector3): void;
  119600. attach(): boolean;
  119601. detach(): boolean;
  119602. dispose(): void;
  119603. /**
  119604. * Remove a mesh from the floor meshes array
  119605. * @param mesh the mesh to remove
  119606. */
  119607. removeFloorMesh(mesh: AbstractMesh): void;
  119608. /**
  119609. * Remove a mesh from the floor meshes array using its name
  119610. * @param name the mesh name to remove
  119611. */
  119612. removeFloorMeshByName(name: string): void;
  119613. /**
  119614. * 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
  119615. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119616. * @returns was the point found and removed or not
  119617. */
  119618. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119619. /**
  119620. * This function sets a selection feature that will be disabled when
  119621. * the forward ray is shown and will be reattached when hidden.
  119622. * This is used to remove the selection rays when moving.
  119623. * @param selectionFeature the feature to disable when forward movement is enabled
  119624. */
  119625. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119626. protected _onXRFrame(_xrFrame: XRFrame): void;
  119627. private _attachController;
  119628. private _createDefaultTargetMesh;
  119629. private _detachController;
  119630. private _findClosestSnapPointWithRadius;
  119631. private _setTargetMeshPosition;
  119632. private _setTargetMeshVisibility;
  119633. private _showParabolicPath;
  119634. private _teleportForward;
  119635. }
  119636. }
  119637. declare module BABYLON {
  119638. /**
  119639. * Options for the default xr helper
  119640. */
  119641. export class WebXRDefaultExperienceOptions {
  119642. /**
  119643. * Enable or disable default UI to enter XR
  119644. */
  119645. disableDefaultUI?: boolean;
  119646. /**
  119647. * Should teleportation not initialize. defaults to false.
  119648. */
  119649. disableTeleportation?: boolean;
  119650. /**
  119651. * Floor meshes that will be used for teleport
  119652. */
  119653. floorMeshes?: Array<AbstractMesh>;
  119654. /**
  119655. * If set to true, the first frame will not be used to reset position
  119656. * The first frame is mainly used when copying transformation from the old camera
  119657. * Mainly used in AR
  119658. */
  119659. ignoreNativeCameraTransformation?: boolean;
  119660. /**
  119661. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119662. */
  119663. inputOptions?: IWebXRInputOptions;
  119664. /**
  119665. * optional configuration for the output canvas
  119666. */
  119667. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119668. /**
  119669. * optional UI options. This can be used among other to change session mode and reference space type
  119670. */
  119671. uiOptions?: WebXREnterExitUIOptions;
  119672. /**
  119673. * When loading teleportation and pointer select, use stable versions instead of latest.
  119674. */
  119675. useStablePlugins?: boolean;
  119676. }
  119677. /**
  119678. * Default experience which provides a similar setup to the previous webVRExperience
  119679. */
  119680. export class WebXRDefaultExperience {
  119681. /**
  119682. * Base experience
  119683. */
  119684. baseExperience: WebXRExperienceHelper;
  119685. /**
  119686. * Enables ui for entering/exiting xr
  119687. */
  119688. enterExitUI: WebXREnterExitUI;
  119689. /**
  119690. * Input experience extension
  119691. */
  119692. input: WebXRInput;
  119693. /**
  119694. * Enables laser pointer and selection
  119695. */
  119696. pointerSelection: WebXRControllerPointerSelection;
  119697. /**
  119698. * Default target xr should render to
  119699. */
  119700. renderTarget: WebXRRenderTarget;
  119701. /**
  119702. * Enables teleportation
  119703. */
  119704. teleportation: WebXRMotionControllerTeleportation;
  119705. private constructor();
  119706. /**
  119707. * Creates the default xr experience
  119708. * @param scene scene
  119709. * @param options options for basic configuration
  119710. * @returns resulting WebXRDefaultExperience
  119711. */
  119712. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119713. /**
  119714. * DIsposes of the experience helper
  119715. */
  119716. dispose(): void;
  119717. }
  119718. }
  119719. declare module BABYLON {
  119720. /**
  119721. * Options to modify the vr teleportation behavior.
  119722. */
  119723. export interface VRTeleportationOptions {
  119724. /**
  119725. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119726. */
  119727. floorMeshName?: string;
  119728. /**
  119729. * A list of meshes to be used as the teleportation floor. (default: empty)
  119730. */
  119731. floorMeshes?: Mesh[];
  119732. /**
  119733. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119734. */
  119735. teleportationMode?: number;
  119736. /**
  119737. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119738. */
  119739. teleportationTime?: number;
  119740. /**
  119741. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119742. */
  119743. teleportationSpeed?: number;
  119744. /**
  119745. * The easing function used in the animation or null for Linear. (default CircleEase)
  119746. */
  119747. easingFunction?: EasingFunction;
  119748. }
  119749. /**
  119750. * Options to modify the vr experience helper's behavior.
  119751. */
  119752. export interface VRExperienceHelperOptions extends WebVROptions {
  119753. /**
  119754. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119755. */
  119756. createDeviceOrientationCamera?: boolean;
  119757. /**
  119758. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119759. */
  119760. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119761. /**
  119762. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119763. */
  119764. laserToggle?: boolean;
  119765. /**
  119766. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119767. */
  119768. floorMeshes?: Mesh[];
  119769. /**
  119770. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119771. */
  119772. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119773. /**
  119774. * Defines if WebXR should be used instead of WebVR (if available)
  119775. */
  119776. useXR?: boolean;
  119777. }
  119778. /**
  119779. * Event containing information after VR has been entered
  119780. */
  119781. export class OnAfterEnteringVRObservableEvent {
  119782. /**
  119783. * If entering vr was successful
  119784. */
  119785. success: boolean;
  119786. }
  119787. /**
  119788. * Helps to quickly add VR support to an existing scene.
  119789. * See http://doc.babylonjs.com/how_to/webvr_helper
  119790. */
  119791. export class VRExperienceHelper {
  119792. /** Options to modify the vr experience helper's behavior. */
  119793. webVROptions: VRExperienceHelperOptions;
  119794. private _scene;
  119795. private _position;
  119796. private _btnVR;
  119797. private _btnVRDisplayed;
  119798. private _webVRsupported;
  119799. private _webVRready;
  119800. private _webVRrequesting;
  119801. private _webVRpresenting;
  119802. private _hasEnteredVR;
  119803. private _fullscreenVRpresenting;
  119804. private _inputElement;
  119805. private _webVRCamera;
  119806. private _vrDeviceOrientationCamera;
  119807. private _deviceOrientationCamera;
  119808. private _existingCamera;
  119809. private _onKeyDown;
  119810. private _onVrDisplayPresentChange;
  119811. private _onVRDisplayChanged;
  119812. private _onVRRequestPresentStart;
  119813. private _onVRRequestPresentComplete;
  119814. /**
  119815. * 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)
  119816. */
  119817. enableGazeEvenWhenNoPointerLock: boolean;
  119818. /**
  119819. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119820. */
  119821. exitVROnDoubleTap: boolean;
  119822. /**
  119823. * Observable raised right before entering VR.
  119824. */
  119825. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119826. /**
  119827. * Observable raised when entering VR has completed.
  119828. */
  119829. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119830. /**
  119831. * Observable raised when exiting VR.
  119832. */
  119833. onExitingVRObservable: Observable<VRExperienceHelper>;
  119834. /**
  119835. * Observable raised when controller mesh is loaded.
  119836. */
  119837. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119838. /** Return this.onEnteringVRObservable
  119839. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119840. */
  119841. get onEnteringVR(): Observable<VRExperienceHelper>;
  119842. /** Return this.onExitingVRObservable
  119843. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119844. */
  119845. get onExitingVR(): Observable<VRExperienceHelper>;
  119846. /** Return this.onControllerMeshLoadedObservable
  119847. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119848. */
  119849. get onControllerMeshLoaded(): Observable<WebVRController>;
  119850. private _rayLength;
  119851. private _useCustomVRButton;
  119852. private _teleportationRequested;
  119853. private _teleportActive;
  119854. private _floorMeshName;
  119855. private _floorMeshesCollection;
  119856. private _teleportationMode;
  119857. private _teleportationTime;
  119858. private _teleportationSpeed;
  119859. private _teleportationEasing;
  119860. private _rotationAllowed;
  119861. private _teleportBackwardsVector;
  119862. private _teleportationTarget;
  119863. private _isDefaultTeleportationTarget;
  119864. private _postProcessMove;
  119865. private _teleportationFillColor;
  119866. private _teleportationBorderColor;
  119867. private _rotationAngle;
  119868. private _haloCenter;
  119869. private _cameraGazer;
  119870. private _padSensibilityUp;
  119871. private _padSensibilityDown;
  119872. private _leftController;
  119873. private _rightController;
  119874. private _gazeColor;
  119875. private _laserColor;
  119876. private _pickedLaserColor;
  119877. private _pickedGazeColor;
  119878. /**
  119879. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119880. */
  119881. onNewMeshSelected: Observable<AbstractMesh>;
  119882. /**
  119883. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119884. * This observable will provide the mesh and the controller used to select the mesh
  119885. */
  119886. onMeshSelectedWithController: Observable<{
  119887. mesh: AbstractMesh;
  119888. controller: WebVRController;
  119889. }>;
  119890. /**
  119891. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119892. */
  119893. onNewMeshPicked: Observable<PickingInfo>;
  119894. private _circleEase;
  119895. /**
  119896. * Observable raised before camera teleportation
  119897. */
  119898. onBeforeCameraTeleport: Observable<Vector3>;
  119899. /**
  119900. * Observable raised after camera teleportation
  119901. */
  119902. onAfterCameraTeleport: Observable<Vector3>;
  119903. /**
  119904. * Observable raised when current selected mesh gets unselected
  119905. */
  119906. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119907. private _raySelectionPredicate;
  119908. /**
  119909. * To be optionaly changed by user to define custom ray selection
  119910. */
  119911. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119912. /**
  119913. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119914. */
  119915. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119916. /**
  119917. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119918. */
  119919. teleportationEnabled: boolean;
  119920. private _defaultHeight;
  119921. private _teleportationInitialized;
  119922. private _interactionsEnabled;
  119923. private _interactionsRequested;
  119924. private _displayGaze;
  119925. private _displayLaserPointer;
  119926. /**
  119927. * The mesh used to display where the user is going to teleport.
  119928. */
  119929. get teleportationTarget(): Mesh;
  119930. /**
  119931. * Sets the mesh to be used to display where the user is going to teleport.
  119932. */
  119933. set teleportationTarget(value: Mesh);
  119934. /**
  119935. * 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
  119936. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119937. * See http://doc.babylonjs.com/resources/baking_transformations
  119938. */
  119939. get gazeTrackerMesh(): Mesh;
  119940. set gazeTrackerMesh(value: Mesh);
  119941. /**
  119942. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119943. */
  119944. updateGazeTrackerScale: boolean;
  119945. /**
  119946. * If the gaze trackers color should be updated when selecting meshes
  119947. */
  119948. updateGazeTrackerColor: boolean;
  119949. /**
  119950. * If the controller laser color should be updated when selecting meshes
  119951. */
  119952. updateControllerLaserColor: boolean;
  119953. /**
  119954. * The gaze tracking mesh corresponding to the left controller
  119955. */
  119956. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119957. /**
  119958. * The gaze tracking mesh corresponding to the right controller
  119959. */
  119960. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119961. /**
  119962. * If the ray of the gaze should be displayed.
  119963. */
  119964. get displayGaze(): boolean;
  119965. /**
  119966. * Sets if the ray of the gaze should be displayed.
  119967. */
  119968. set displayGaze(value: boolean);
  119969. /**
  119970. * If the ray of the LaserPointer should be displayed.
  119971. */
  119972. get displayLaserPointer(): boolean;
  119973. /**
  119974. * Sets if the ray of the LaserPointer should be displayed.
  119975. */
  119976. set displayLaserPointer(value: boolean);
  119977. /**
  119978. * The deviceOrientationCamera used as the camera when not in VR.
  119979. */
  119980. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119981. /**
  119982. * Based on the current WebVR support, returns the current VR camera used.
  119983. */
  119984. get currentVRCamera(): Nullable<Camera>;
  119985. /**
  119986. * The webVRCamera which is used when in VR.
  119987. */
  119988. get webVRCamera(): WebVRFreeCamera;
  119989. /**
  119990. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119991. */
  119992. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119993. /**
  119994. * The html button that is used to trigger entering into VR.
  119995. */
  119996. get vrButton(): Nullable<HTMLButtonElement>;
  119997. private get _teleportationRequestInitiated();
  119998. /**
  119999. * Defines whether or not Pointer lock should be requested when switching to
  120000. * full screen.
  120001. */
  120002. requestPointerLockOnFullScreen: boolean;
  120003. /**
  120004. * If asking to force XR, this will be populated with the default xr experience
  120005. */
  120006. xr: WebXRDefaultExperience;
  120007. /**
  120008. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  120009. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  120010. */
  120011. xrTestDone: boolean;
  120012. /**
  120013. * Instantiates a VRExperienceHelper.
  120014. * Helps to quickly add VR support to an existing scene.
  120015. * @param scene The scene the VRExperienceHelper belongs to.
  120016. * @param webVROptions Options to modify the vr experience helper's behavior.
  120017. */
  120018. constructor(scene: Scene,
  120019. /** Options to modify the vr experience helper's behavior. */
  120020. webVROptions?: VRExperienceHelperOptions);
  120021. private completeVRInit;
  120022. private _onDefaultMeshLoaded;
  120023. private _onResize;
  120024. private _onFullscreenChange;
  120025. /**
  120026. * Gets a value indicating if we are currently in VR mode.
  120027. */
  120028. get isInVRMode(): boolean;
  120029. private onVrDisplayPresentChange;
  120030. private onVRDisplayChanged;
  120031. private moveButtonToBottomRight;
  120032. private displayVRButton;
  120033. private updateButtonVisibility;
  120034. private _cachedAngularSensibility;
  120035. /**
  120036. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120037. * Otherwise, will use the fullscreen API.
  120038. */
  120039. enterVR(): void;
  120040. /**
  120041. * Attempt to exit VR, or fullscreen.
  120042. */
  120043. exitVR(): void;
  120044. /**
  120045. * The position of the vr experience helper.
  120046. */
  120047. get position(): Vector3;
  120048. /**
  120049. * Sets the position of the vr experience helper.
  120050. */
  120051. set position(value: Vector3);
  120052. /**
  120053. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120054. */
  120055. enableInteractions(): void;
  120056. private get _noControllerIsActive();
  120057. private beforeRender;
  120058. private _isTeleportationFloor;
  120059. /**
  120060. * Adds a floor mesh to be used for teleportation.
  120061. * @param floorMesh the mesh to be used for teleportation.
  120062. */
  120063. addFloorMesh(floorMesh: Mesh): void;
  120064. /**
  120065. * Removes a floor mesh from being used for teleportation.
  120066. * @param floorMesh the mesh to be removed.
  120067. */
  120068. removeFloorMesh(floorMesh: Mesh): void;
  120069. /**
  120070. * Enables interactions and teleportation using the VR controllers and gaze.
  120071. * @param vrTeleportationOptions options to modify teleportation behavior.
  120072. */
  120073. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120074. private _onNewGamepadConnected;
  120075. private _tryEnableInteractionOnController;
  120076. private _onNewGamepadDisconnected;
  120077. private _enableInteractionOnController;
  120078. private _checkTeleportWithRay;
  120079. private _checkRotate;
  120080. private _checkTeleportBackwards;
  120081. private _enableTeleportationOnController;
  120082. private _createTeleportationCircles;
  120083. private _displayTeleportationTarget;
  120084. private _hideTeleportationTarget;
  120085. private _rotateCamera;
  120086. private _moveTeleportationSelectorTo;
  120087. private _workingVector;
  120088. private _workingQuaternion;
  120089. private _workingMatrix;
  120090. /**
  120091. * Time Constant Teleportation Mode
  120092. */
  120093. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120094. /**
  120095. * Speed Constant Teleportation Mode
  120096. */
  120097. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120098. /**
  120099. * Teleports the users feet to the desired location
  120100. * @param location The location where the user's feet should be placed
  120101. */
  120102. teleportCamera(location: Vector3): void;
  120103. private _convertNormalToDirectionOfRay;
  120104. private _castRayAndSelectObject;
  120105. private _notifySelectedMeshUnselected;
  120106. /**
  120107. * Permanently set new colors for the laser pointer
  120108. * @param color the new laser color
  120109. * @param pickedColor the new laser color when picked mesh detected
  120110. */
  120111. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120112. /**
  120113. * Set lighting enabled / disabled on the laser pointer of both controllers
  120114. * @param enabled should the lighting be enabled on the laser pointer
  120115. */
  120116. setLaserLightingState(enabled?: boolean): void;
  120117. /**
  120118. * Permanently set new colors for the gaze pointer
  120119. * @param color the new gaze color
  120120. * @param pickedColor the new gaze color when picked mesh detected
  120121. */
  120122. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120123. /**
  120124. * Sets the color of the laser ray from the vr controllers.
  120125. * @param color new color for the ray.
  120126. */
  120127. changeLaserColor(color: Color3): void;
  120128. /**
  120129. * Sets the color of the ray from the vr headsets gaze.
  120130. * @param color new color for the ray.
  120131. */
  120132. changeGazeColor(color: Color3): void;
  120133. /**
  120134. * Exits VR and disposes of the vr experience helper
  120135. */
  120136. dispose(): void;
  120137. /**
  120138. * Gets the name of the VRExperienceHelper class
  120139. * @returns "VRExperienceHelper"
  120140. */
  120141. getClassName(): string;
  120142. }
  120143. }
  120144. declare module BABYLON {
  120145. /**
  120146. * Contains an array of blocks representing the octree
  120147. */
  120148. export interface IOctreeContainer<T> {
  120149. /**
  120150. * Blocks within the octree
  120151. */
  120152. blocks: Array<OctreeBlock<T>>;
  120153. }
  120154. /**
  120155. * Class used to store a cell in an octree
  120156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120157. */
  120158. export class OctreeBlock<T> {
  120159. /**
  120160. * Gets the content of the current block
  120161. */
  120162. entries: T[];
  120163. /**
  120164. * Gets the list of block children
  120165. */
  120166. blocks: Array<OctreeBlock<T>>;
  120167. private _depth;
  120168. private _maxDepth;
  120169. private _capacity;
  120170. private _minPoint;
  120171. private _maxPoint;
  120172. private _boundingVectors;
  120173. private _creationFunc;
  120174. /**
  120175. * Creates a new block
  120176. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120177. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120178. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120179. * @param depth defines the current depth of this block in the octree
  120180. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120181. * @param creationFunc defines a callback to call when an element is added to the block
  120182. */
  120183. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120184. /**
  120185. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120186. */
  120187. get capacity(): number;
  120188. /**
  120189. * Gets the minimum vector (in world space) of the block's bounding box
  120190. */
  120191. get minPoint(): Vector3;
  120192. /**
  120193. * Gets the maximum vector (in world space) of the block's bounding box
  120194. */
  120195. get maxPoint(): Vector3;
  120196. /**
  120197. * Add a new element to this block
  120198. * @param entry defines the element to add
  120199. */
  120200. addEntry(entry: T): void;
  120201. /**
  120202. * Remove an element from this block
  120203. * @param entry defines the element to remove
  120204. */
  120205. removeEntry(entry: T): void;
  120206. /**
  120207. * Add an array of elements to this block
  120208. * @param entries defines the array of elements to add
  120209. */
  120210. addEntries(entries: T[]): void;
  120211. /**
  120212. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120213. * @param frustumPlanes defines the frustum planes to test
  120214. * @param selection defines the array to store current content if selection is positive
  120215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120216. */
  120217. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120218. /**
  120219. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120220. * @param sphereCenter defines the bounding sphere center
  120221. * @param sphereRadius defines the bounding sphere radius
  120222. * @param selection defines the array to store current content if selection is positive
  120223. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120224. */
  120225. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120226. /**
  120227. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120228. * @param ray defines the ray to test with
  120229. * @param selection defines the array to store current content if selection is positive
  120230. */
  120231. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120232. /**
  120233. * Subdivide the content into child blocks (this block will then be empty)
  120234. */
  120235. createInnerBlocks(): void;
  120236. /**
  120237. * @hidden
  120238. */
  120239. 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;
  120240. }
  120241. }
  120242. declare module BABYLON {
  120243. /**
  120244. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120246. */
  120247. export class Octree<T> {
  120248. /** 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.) */
  120249. maxDepth: number;
  120250. /**
  120251. * Blocks within the octree containing objects
  120252. */
  120253. blocks: Array<OctreeBlock<T>>;
  120254. /**
  120255. * Content stored in the octree
  120256. */
  120257. dynamicContent: T[];
  120258. private _maxBlockCapacity;
  120259. private _selectionContent;
  120260. private _creationFunc;
  120261. /**
  120262. * Creates a octree
  120263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120264. * @param creationFunc function to be used to instatiate the octree
  120265. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120266. * @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.)
  120267. */
  120268. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120269. /** 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.) */
  120270. maxDepth?: number);
  120271. /**
  120272. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120273. * @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);
  120274. * @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);
  120275. * @param entries meshes to be added to the octree blocks
  120276. */
  120277. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120278. /**
  120279. * Adds a mesh to the octree
  120280. * @param entry Mesh to add to the octree
  120281. */
  120282. addMesh(entry: T): void;
  120283. /**
  120284. * Remove an element from the octree
  120285. * @param entry defines the element to remove
  120286. */
  120287. removeMesh(entry: T): void;
  120288. /**
  120289. * Selects an array of meshes within the frustum
  120290. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120291. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120292. * @returns array of meshes within the frustum
  120293. */
  120294. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120295. /**
  120296. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120297. * @param sphereCenter defines the bounding sphere center
  120298. * @param sphereRadius defines the bounding sphere radius
  120299. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120300. * @returns an array of objects that intersect the sphere
  120301. */
  120302. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120303. /**
  120304. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120305. * @param ray defines the ray to test with
  120306. * @returns array of intersected objects
  120307. */
  120308. intersectsRay(ray: Ray): SmartArray<T>;
  120309. /**
  120310. * Adds a mesh into the octree block if it intersects the block
  120311. */
  120312. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120313. /**
  120314. * Adds a submesh into the octree block if it intersects the block
  120315. */
  120316. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120317. }
  120318. }
  120319. declare module BABYLON {
  120320. interface Scene {
  120321. /**
  120322. * @hidden
  120323. * Backing Filed
  120324. */
  120325. _selectionOctree: Octree<AbstractMesh>;
  120326. /**
  120327. * Gets the octree used to boost mesh selection (picking)
  120328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120329. */
  120330. selectionOctree: Octree<AbstractMesh>;
  120331. /**
  120332. * Creates or updates the octree used to boost selection (picking)
  120333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120334. * @param maxCapacity defines the maximum capacity per leaf
  120335. * @param maxDepth defines the maximum depth of the octree
  120336. * @returns an octree of AbstractMesh
  120337. */
  120338. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120339. }
  120340. interface AbstractMesh {
  120341. /**
  120342. * @hidden
  120343. * Backing Field
  120344. */
  120345. _submeshesOctree: Octree<SubMesh>;
  120346. /**
  120347. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120348. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120349. * @param maxCapacity defines the maximum size of each block (64 by default)
  120350. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120351. * @returns the new octree
  120352. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120354. */
  120355. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120356. }
  120357. /**
  120358. * Defines the octree scene component responsible to manage any octrees
  120359. * in a given scene.
  120360. */
  120361. export class OctreeSceneComponent {
  120362. /**
  120363. * The component name help to identify the component in the list of scene components.
  120364. */
  120365. readonly name: string;
  120366. /**
  120367. * The scene the component belongs to.
  120368. */
  120369. scene: Scene;
  120370. /**
  120371. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120372. */
  120373. readonly checksIsEnabled: boolean;
  120374. /**
  120375. * Creates a new instance of the component for the given scene
  120376. * @param scene Defines the scene to register the component in
  120377. */
  120378. constructor(scene: Scene);
  120379. /**
  120380. * Registers the component in a given scene
  120381. */
  120382. register(): void;
  120383. /**
  120384. * Return the list of active meshes
  120385. * @returns the list of active meshes
  120386. */
  120387. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120388. /**
  120389. * Return the list of active sub meshes
  120390. * @param mesh The mesh to get the candidates sub meshes from
  120391. * @returns the list of active sub meshes
  120392. */
  120393. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120394. private _tempRay;
  120395. /**
  120396. * Return the list of sub meshes intersecting with a given local ray
  120397. * @param mesh defines the mesh to find the submesh for
  120398. * @param localRay defines the ray in local space
  120399. * @returns the list of intersecting sub meshes
  120400. */
  120401. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120402. /**
  120403. * Return the list of sub meshes colliding with a collider
  120404. * @param mesh defines the mesh to find the submesh for
  120405. * @param collider defines the collider to evaluate the collision against
  120406. * @returns the list of colliding sub meshes
  120407. */
  120408. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120409. /**
  120410. * Rebuilds the elements related to this component in case of
  120411. * context lost for instance.
  120412. */
  120413. rebuild(): void;
  120414. /**
  120415. * Disposes the component and the associated ressources.
  120416. */
  120417. dispose(): void;
  120418. }
  120419. }
  120420. declare module BABYLON {
  120421. /**
  120422. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120423. */
  120424. export class Gizmo implements IDisposable {
  120425. /** The utility layer the gizmo will be added to */
  120426. gizmoLayer: UtilityLayerRenderer;
  120427. /**
  120428. * The root mesh of the gizmo
  120429. */
  120430. _rootMesh: Mesh;
  120431. private _attachedMesh;
  120432. /**
  120433. * Ratio for the scale of the gizmo (Default: 1)
  120434. */
  120435. scaleRatio: number;
  120436. /**
  120437. * If a custom mesh has been set (Default: false)
  120438. */
  120439. protected _customMeshSet: boolean;
  120440. /**
  120441. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120442. * * When set, interactions will be enabled
  120443. */
  120444. get attachedMesh(): Nullable<AbstractMesh>;
  120445. set attachedMesh(value: Nullable<AbstractMesh>);
  120446. /**
  120447. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120448. * @param mesh The mesh to replace the default mesh of the gizmo
  120449. */
  120450. setCustomMesh(mesh: Mesh): void;
  120451. /**
  120452. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120453. */
  120454. updateGizmoRotationToMatchAttachedMesh: boolean;
  120455. /**
  120456. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120457. */
  120458. updateGizmoPositionToMatchAttachedMesh: boolean;
  120459. /**
  120460. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120461. */
  120462. updateScale: boolean;
  120463. protected _interactionsEnabled: boolean;
  120464. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120465. private _beforeRenderObserver;
  120466. private _tempVector;
  120467. /**
  120468. * Creates a gizmo
  120469. * @param gizmoLayer The utility layer the gizmo will be added to
  120470. */
  120471. constructor(
  120472. /** The utility layer the gizmo will be added to */
  120473. gizmoLayer?: UtilityLayerRenderer);
  120474. /**
  120475. * Updates the gizmo to match the attached mesh's position/rotation
  120476. */
  120477. protected _update(): void;
  120478. /**
  120479. * Disposes of the gizmo
  120480. */
  120481. dispose(): void;
  120482. }
  120483. }
  120484. declare module BABYLON {
  120485. /**
  120486. * Single plane drag gizmo
  120487. */
  120488. export class PlaneDragGizmo extends Gizmo {
  120489. /**
  120490. * Drag behavior responsible for the gizmos dragging interactions
  120491. */
  120492. dragBehavior: PointerDragBehavior;
  120493. private _pointerObserver;
  120494. /**
  120495. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120496. */
  120497. snapDistance: number;
  120498. /**
  120499. * Event that fires each time the gizmo snaps to a new location.
  120500. * * snapDistance is the the change in distance
  120501. */
  120502. onSnapObservable: Observable<{
  120503. snapDistance: number;
  120504. }>;
  120505. private _plane;
  120506. private _coloredMaterial;
  120507. private _hoverMaterial;
  120508. private _isEnabled;
  120509. private _parent;
  120510. /** @hidden */
  120511. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120512. /** @hidden */
  120513. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120514. /**
  120515. * Creates a PlaneDragGizmo
  120516. * @param gizmoLayer The utility layer the gizmo will be added to
  120517. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120518. * @param color The color of the gizmo
  120519. */
  120520. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120521. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120522. /**
  120523. * If the gizmo is enabled
  120524. */
  120525. set isEnabled(value: boolean);
  120526. get isEnabled(): boolean;
  120527. /**
  120528. * Disposes of the gizmo
  120529. */
  120530. dispose(): void;
  120531. }
  120532. }
  120533. declare module BABYLON {
  120534. /**
  120535. * Gizmo that enables dragging a mesh along 3 axis
  120536. */
  120537. export class PositionGizmo extends Gizmo {
  120538. /**
  120539. * Internal gizmo used for interactions on the x axis
  120540. */
  120541. xGizmo: AxisDragGizmo;
  120542. /**
  120543. * Internal gizmo used for interactions on the y axis
  120544. */
  120545. yGizmo: AxisDragGizmo;
  120546. /**
  120547. * Internal gizmo used for interactions on the z axis
  120548. */
  120549. zGizmo: AxisDragGizmo;
  120550. /**
  120551. * Internal gizmo used for interactions on the yz plane
  120552. */
  120553. xPlaneGizmo: PlaneDragGizmo;
  120554. /**
  120555. * Internal gizmo used for interactions on the xz plane
  120556. */
  120557. yPlaneGizmo: PlaneDragGizmo;
  120558. /**
  120559. * Internal gizmo used for interactions on the xy plane
  120560. */
  120561. zPlaneGizmo: PlaneDragGizmo;
  120562. /**
  120563. * private variables
  120564. */
  120565. private _meshAttached;
  120566. private _updateGizmoRotationToMatchAttachedMesh;
  120567. private _snapDistance;
  120568. private _scaleRatio;
  120569. /** Fires an event when any of it's sub gizmos are dragged */
  120570. onDragStartObservable: Observable<unknown>;
  120571. /** Fires an event when any of it's sub gizmos are released from dragging */
  120572. onDragEndObservable: Observable<unknown>;
  120573. /**
  120574. * If set to true, planar drag is enabled
  120575. */
  120576. private _planarGizmoEnabled;
  120577. get attachedMesh(): Nullable<AbstractMesh>;
  120578. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120579. /**
  120580. * Creates a PositionGizmo
  120581. * @param gizmoLayer The utility layer the gizmo will be added to
  120582. */
  120583. constructor(gizmoLayer?: UtilityLayerRenderer);
  120584. /**
  120585. * If the planar drag gizmo is enabled
  120586. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120587. */
  120588. set planarGizmoEnabled(value: boolean);
  120589. get planarGizmoEnabled(): boolean;
  120590. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120591. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120592. /**
  120593. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120594. */
  120595. set snapDistance(value: number);
  120596. get snapDistance(): number;
  120597. /**
  120598. * Ratio for the scale of the gizmo (Default: 1)
  120599. */
  120600. set scaleRatio(value: number);
  120601. get scaleRatio(): number;
  120602. /**
  120603. * Disposes of the gizmo
  120604. */
  120605. dispose(): void;
  120606. /**
  120607. * CustomMeshes are not supported by this gizmo
  120608. * @param mesh The mesh to replace the default mesh of the gizmo
  120609. */
  120610. setCustomMesh(mesh: Mesh): void;
  120611. }
  120612. }
  120613. declare module BABYLON {
  120614. /**
  120615. * Single axis drag gizmo
  120616. */
  120617. export class AxisDragGizmo extends Gizmo {
  120618. /**
  120619. * Drag behavior responsible for the gizmos dragging interactions
  120620. */
  120621. dragBehavior: PointerDragBehavior;
  120622. private _pointerObserver;
  120623. /**
  120624. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120625. */
  120626. snapDistance: number;
  120627. /**
  120628. * Event that fires each time the gizmo snaps to a new location.
  120629. * * snapDistance is the the change in distance
  120630. */
  120631. onSnapObservable: Observable<{
  120632. snapDistance: number;
  120633. }>;
  120634. private _isEnabled;
  120635. private _parent;
  120636. private _arrow;
  120637. private _coloredMaterial;
  120638. private _hoverMaterial;
  120639. /** @hidden */
  120640. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120641. /** @hidden */
  120642. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120643. /**
  120644. * Creates an AxisDragGizmo
  120645. * @param gizmoLayer The utility layer the gizmo will be added to
  120646. * @param dragAxis The axis which the gizmo will be able to drag on
  120647. * @param color The color of the gizmo
  120648. */
  120649. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120650. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120651. /**
  120652. * If the gizmo is enabled
  120653. */
  120654. set isEnabled(value: boolean);
  120655. get isEnabled(): boolean;
  120656. /**
  120657. * Disposes of the gizmo
  120658. */
  120659. dispose(): void;
  120660. }
  120661. }
  120662. declare module BABYLON.Debug {
  120663. /**
  120664. * The Axes viewer will show 3 axes in a specific point in space
  120665. */
  120666. export class AxesViewer {
  120667. private _xAxis;
  120668. private _yAxis;
  120669. private _zAxis;
  120670. private _scaleLinesFactor;
  120671. private _instanced;
  120672. /**
  120673. * Gets the hosting scene
  120674. */
  120675. scene: Scene;
  120676. /**
  120677. * Gets or sets a number used to scale line length
  120678. */
  120679. scaleLines: number;
  120680. /** Gets the node hierarchy used to render x-axis */
  120681. get xAxis(): TransformNode;
  120682. /** Gets the node hierarchy used to render y-axis */
  120683. get yAxis(): TransformNode;
  120684. /** Gets the node hierarchy used to render z-axis */
  120685. get zAxis(): TransformNode;
  120686. /**
  120687. * Creates a new AxesViewer
  120688. * @param scene defines the hosting scene
  120689. * @param scaleLines defines a number used to scale line length (1 by default)
  120690. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120691. * @param xAxis defines the node hierarchy used to render the x-axis
  120692. * @param yAxis defines the node hierarchy used to render the y-axis
  120693. * @param zAxis defines the node hierarchy used to render the z-axis
  120694. */
  120695. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120696. /**
  120697. * Force the viewer to update
  120698. * @param position defines the position of the viewer
  120699. * @param xaxis defines the x axis of the viewer
  120700. * @param yaxis defines the y axis of the viewer
  120701. * @param zaxis defines the z axis of the viewer
  120702. */
  120703. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120704. /**
  120705. * Creates an instance of this axes viewer.
  120706. * @returns a new axes viewer with instanced meshes
  120707. */
  120708. createInstance(): AxesViewer;
  120709. /** Releases resources */
  120710. dispose(): void;
  120711. private static _SetRenderingGroupId;
  120712. }
  120713. }
  120714. declare module BABYLON.Debug {
  120715. /**
  120716. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120717. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120718. */
  120719. export class BoneAxesViewer extends AxesViewer {
  120720. /**
  120721. * Gets or sets the target mesh where to display the axes viewer
  120722. */
  120723. mesh: Nullable<Mesh>;
  120724. /**
  120725. * Gets or sets the target bone where to display the axes viewer
  120726. */
  120727. bone: Nullable<Bone>;
  120728. /** Gets current position */
  120729. pos: Vector3;
  120730. /** Gets direction of X axis */
  120731. xaxis: Vector3;
  120732. /** Gets direction of Y axis */
  120733. yaxis: Vector3;
  120734. /** Gets direction of Z axis */
  120735. zaxis: Vector3;
  120736. /**
  120737. * Creates a new BoneAxesViewer
  120738. * @param scene defines the hosting scene
  120739. * @param bone defines the target bone
  120740. * @param mesh defines the target mesh
  120741. * @param scaleLines defines a scaling factor for line length (1 by default)
  120742. */
  120743. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120744. /**
  120745. * Force the viewer to update
  120746. */
  120747. update(): void;
  120748. /** Releases resources */
  120749. dispose(): void;
  120750. }
  120751. }
  120752. declare module BABYLON {
  120753. /**
  120754. * Interface used to define scene explorer extensibility option
  120755. */
  120756. export interface IExplorerExtensibilityOption {
  120757. /**
  120758. * Define the option label
  120759. */
  120760. label: string;
  120761. /**
  120762. * Defines the action to execute on click
  120763. */
  120764. action: (entity: any) => void;
  120765. }
  120766. /**
  120767. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120768. */
  120769. export interface IExplorerExtensibilityGroup {
  120770. /**
  120771. * Defines a predicate to test if a given type mut be extended
  120772. */
  120773. predicate: (entity: any) => boolean;
  120774. /**
  120775. * Gets the list of options added to a type
  120776. */
  120777. entries: IExplorerExtensibilityOption[];
  120778. }
  120779. /**
  120780. * Interface used to define the options to use to create the Inspector
  120781. */
  120782. export interface IInspectorOptions {
  120783. /**
  120784. * Display in overlay mode (default: false)
  120785. */
  120786. overlay?: boolean;
  120787. /**
  120788. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120789. */
  120790. globalRoot?: HTMLElement;
  120791. /**
  120792. * Display the Scene explorer
  120793. */
  120794. showExplorer?: boolean;
  120795. /**
  120796. * Display the property inspector
  120797. */
  120798. showInspector?: boolean;
  120799. /**
  120800. * Display in embed mode (both panes on the right)
  120801. */
  120802. embedMode?: boolean;
  120803. /**
  120804. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120805. */
  120806. handleResize?: boolean;
  120807. /**
  120808. * Allow the panes to popup (default: true)
  120809. */
  120810. enablePopup?: boolean;
  120811. /**
  120812. * Allow the panes to be closed by users (default: true)
  120813. */
  120814. enableClose?: boolean;
  120815. /**
  120816. * Optional list of extensibility entries
  120817. */
  120818. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120819. /**
  120820. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120821. */
  120822. inspectorURL?: string;
  120823. /**
  120824. * Optional initial tab (default to DebugLayerTab.Properties)
  120825. */
  120826. initialTab?: DebugLayerTab;
  120827. }
  120828. interface Scene {
  120829. /**
  120830. * @hidden
  120831. * Backing field
  120832. */
  120833. _debugLayer: DebugLayer;
  120834. /**
  120835. * Gets the debug layer (aka Inspector) associated with the scene
  120836. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120837. */
  120838. debugLayer: DebugLayer;
  120839. }
  120840. /**
  120841. * Enum of inspector action tab
  120842. */
  120843. export enum DebugLayerTab {
  120844. /**
  120845. * Properties tag (default)
  120846. */
  120847. Properties = 0,
  120848. /**
  120849. * Debug tab
  120850. */
  120851. Debug = 1,
  120852. /**
  120853. * Statistics tab
  120854. */
  120855. Statistics = 2,
  120856. /**
  120857. * Tools tab
  120858. */
  120859. Tools = 3,
  120860. /**
  120861. * Settings tab
  120862. */
  120863. Settings = 4
  120864. }
  120865. /**
  120866. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120867. * what is happening in your scene
  120868. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120869. */
  120870. export class DebugLayer {
  120871. /**
  120872. * Define the url to get the inspector script from.
  120873. * By default it uses the babylonjs CDN.
  120874. * @ignoreNaming
  120875. */
  120876. static InspectorURL: string;
  120877. private _scene;
  120878. private BJSINSPECTOR;
  120879. private _onPropertyChangedObservable?;
  120880. /**
  120881. * Observable triggered when a property is changed through the inspector.
  120882. */
  120883. get onPropertyChangedObservable(): any;
  120884. /**
  120885. * Instantiates a new debug layer.
  120886. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120887. * what is happening in your scene
  120888. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120889. * @param scene Defines the scene to inspect
  120890. */
  120891. constructor(scene: Scene);
  120892. /** Creates the inspector window. */
  120893. private _createInspector;
  120894. /**
  120895. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120896. * @param entity defines the entity to select
  120897. * @param lineContainerTitle defines the specific block to highlight
  120898. */
  120899. select(entity: any, lineContainerTitle?: string): void;
  120900. /** Get the inspector from bundle or global */
  120901. private _getGlobalInspector;
  120902. /**
  120903. * Get if the inspector is visible or not.
  120904. * @returns true if visible otherwise, false
  120905. */
  120906. isVisible(): boolean;
  120907. /**
  120908. * Hide the inspector and close its window.
  120909. */
  120910. hide(): void;
  120911. /**
  120912. * Launch the debugLayer.
  120913. * @param config Define the configuration of the inspector
  120914. * @return a promise fulfilled when the debug layer is visible
  120915. */
  120916. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120917. }
  120918. }
  120919. declare module BABYLON {
  120920. /**
  120921. * Class containing static functions to help procedurally build meshes
  120922. */
  120923. export class BoxBuilder {
  120924. /**
  120925. * Creates a box mesh
  120926. * * The parameter `size` sets the size (float) of each box side (default 1)
  120927. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120928. * * 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)
  120929. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120933. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120934. * @param name defines the name of the mesh
  120935. * @param options defines the options used to create the mesh
  120936. * @param scene defines the hosting scene
  120937. * @returns the box mesh
  120938. */
  120939. static CreateBox(name: string, options: {
  120940. size?: number;
  120941. width?: number;
  120942. height?: number;
  120943. depth?: number;
  120944. faceUV?: Vector4[];
  120945. faceColors?: Color4[];
  120946. sideOrientation?: number;
  120947. frontUVs?: Vector4;
  120948. backUVs?: Vector4;
  120949. wrap?: boolean;
  120950. topBaseAt?: number;
  120951. bottomBaseAt?: number;
  120952. updatable?: boolean;
  120953. }, scene?: Nullable<Scene>): Mesh;
  120954. }
  120955. }
  120956. declare module BABYLON.Debug {
  120957. /**
  120958. * Used to show the physics impostor around the specific mesh
  120959. */
  120960. export class PhysicsViewer {
  120961. /** @hidden */
  120962. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120963. /** @hidden */
  120964. protected _meshes: Array<Nullable<AbstractMesh>>;
  120965. /** @hidden */
  120966. protected _scene: Nullable<Scene>;
  120967. /** @hidden */
  120968. protected _numMeshes: number;
  120969. /** @hidden */
  120970. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120971. private _renderFunction;
  120972. private _utilityLayer;
  120973. private _debugBoxMesh;
  120974. private _debugSphereMesh;
  120975. private _debugCylinderMesh;
  120976. private _debugMaterial;
  120977. private _debugMeshMeshes;
  120978. /**
  120979. * Creates a new PhysicsViewer
  120980. * @param scene defines the hosting scene
  120981. */
  120982. constructor(scene: Scene);
  120983. /** @hidden */
  120984. protected _updateDebugMeshes(): void;
  120985. /**
  120986. * Renders a specified physic impostor
  120987. * @param impostor defines the impostor to render
  120988. * @param targetMesh defines the mesh represented by the impostor
  120989. * @returns the new debug mesh used to render the impostor
  120990. */
  120991. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120992. /**
  120993. * Hides a specified physic impostor
  120994. * @param impostor defines the impostor to hide
  120995. */
  120996. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120997. private _getDebugMaterial;
  120998. private _getDebugBoxMesh;
  120999. private _getDebugSphereMesh;
  121000. private _getDebugCylinderMesh;
  121001. private _getDebugMeshMesh;
  121002. private _getDebugMesh;
  121003. /** Releases all resources */
  121004. dispose(): void;
  121005. }
  121006. }
  121007. declare module BABYLON {
  121008. /**
  121009. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121010. * in order to better appreciate the issue one might have.
  121011. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121012. */
  121013. export class RayHelper {
  121014. /**
  121015. * Defines the ray we are currently tryin to visualize.
  121016. */
  121017. ray: Nullable<Ray>;
  121018. private _renderPoints;
  121019. private _renderLine;
  121020. private _renderFunction;
  121021. private _scene;
  121022. private _updateToMeshFunction;
  121023. private _attachedToMesh;
  121024. private _meshSpaceDirection;
  121025. private _meshSpaceOrigin;
  121026. /**
  121027. * Helper function to create a colored helper in a scene in one line.
  121028. * @param ray Defines the ray we are currently tryin to visualize
  121029. * @param scene Defines the scene the ray is used in
  121030. * @param color Defines the color we want to see the ray in
  121031. * @returns The newly created ray helper.
  121032. */
  121033. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121034. /**
  121035. * Instantiate a new ray helper.
  121036. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121037. * in order to better appreciate the issue one might have.
  121038. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121039. * @param ray Defines the ray we are currently tryin to visualize
  121040. */
  121041. constructor(ray: Ray);
  121042. /**
  121043. * Shows the ray we are willing to debug.
  121044. * @param scene Defines the scene the ray needs to be rendered in
  121045. * @param color Defines the color the ray needs to be rendered in
  121046. */
  121047. show(scene: Scene, color?: Color3): void;
  121048. /**
  121049. * Hides the ray we are debugging.
  121050. */
  121051. hide(): void;
  121052. private _render;
  121053. /**
  121054. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121055. * @param mesh Defines the mesh we want the helper attached to
  121056. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121057. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121058. * @param length Defines the length of the ray
  121059. */
  121060. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121061. /**
  121062. * Detach the ray helper from the mesh it has previously been attached to.
  121063. */
  121064. detachFromMesh(): void;
  121065. private _updateToMesh;
  121066. /**
  121067. * Dispose the helper and release its associated resources.
  121068. */
  121069. dispose(): void;
  121070. }
  121071. }
  121072. declare module BABYLON.Debug {
  121073. /**
  121074. * Class used to render a debug view of a given skeleton
  121075. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121076. */
  121077. export class SkeletonViewer {
  121078. /** defines the skeleton to render */
  121079. skeleton: Skeleton;
  121080. /** defines the mesh attached to the skeleton */
  121081. mesh: AbstractMesh;
  121082. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121083. autoUpdateBonesMatrices: boolean;
  121084. /** defines the rendering group id to use with the viewer */
  121085. renderingGroupId: number;
  121086. /** Gets or sets the color used to render the skeleton */
  121087. color: Color3;
  121088. private _scene;
  121089. private _debugLines;
  121090. private _debugMesh;
  121091. private _isEnabled;
  121092. private _renderFunction;
  121093. private _utilityLayer;
  121094. /**
  121095. * Returns the mesh used to render the bones
  121096. */
  121097. get debugMesh(): Nullable<LinesMesh>;
  121098. /**
  121099. * Creates a new SkeletonViewer
  121100. * @param skeleton defines the skeleton to render
  121101. * @param mesh defines the mesh attached to the skeleton
  121102. * @param scene defines the hosting scene
  121103. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121104. * @param renderingGroupId defines the rendering group id to use with the viewer
  121105. */
  121106. constructor(
  121107. /** defines the skeleton to render */
  121108. skeleton: Skeleton,
  121109. /** defines the mesh attached to the skeleton */
  121110. mesh: AbstractMesh, scene: Scene,
  121111. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121112. autoUpdateBonesMatrices?: boolean,
  121113. /** defines the rendering group id to use with the viewer */
  121114. renderingGroupId?: number);
  121115. /** Gets or sets a boolean indicating if the viewer is enabled */
  121116. set isEnabled(value: boolean);
  121117. get isEnabled(): boolean;
  121118. private _getBonePosition;
  121119. private _getLinesForBonesWithLength;
  121120. private _getLinesForBonesNoLength;
  121121. /** Update the viewer to sync with current skeleton state */
  121122. update(): void;
  121123. /** Release associated resources */
  121124. dispose(): void;
  121125. }
  121126. }
  121127. declare module BABYLON {
  121128. /**
  121129. * Options to create the null engine
  121130. */
  121131. export class NullEngineOptions {
  121132. /**
  121133. * Render width (Default: 512)
  121134. */
  121135. renderWidth: number;
  121136. /**
  121137. * Render height (Default: 256)
  121138. */
  121139. renderHeight: number;
  121140. /**
  121141. * Texture size (Default: 512)
  121142. */
  121143. textureSize: number;
  121144. /**
  121145. * If delta time between frames should be constant
  121146. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121147. */
  121148. deterministicLockstep: boolean;
  121149. /**
  121150. * Maximum about of steps between frames (Default: 4)
  121151. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121152. */
  121153. lockstepMaxSteps: number;
  121154. }
  121155. /**
  121156. * The null engine class provides support for headless version of babylon.js.
  121157. * This can be used in server side scenario or for testing purposes
  121158. */
  121159. export class NullEngine extends Engine {
  121160. private _options;
  121161. /**
  121162. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121164. * @returns true if engine is in deterministic lock step mode
  121165. */
  121166. isDeterministicLockStep(): boolean;
  121167. /**
  121168. * Gets the max steps when engine is running in deterministic lock step
  121169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121170. * @returns the max steps
  121171. */
  121172. getLockstepMaxSteps(): number;
  121173. /**
  121174. * Gets the current hardware scaling level.
  121175. * By default the hardware scaling level is computed from the window device ratio.
  121176. * 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.
  121177. * @returns a number indicating the current hardware scaling level
  121178. */
  121179. getHardwareScalingLevel(): number;
  121180. constructor(options?: NullEngineOptions);
  121181. /**
  121182. * Creates a vertex buffer
  121183. * @param vertices the data for the vertex buffer
  121184. * @returns the new WebGL static buffer
  121185. */
  121186. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121187. /**
  121188. * Creates a new index buffer
  121189. * @param indices defines the content of the index buffer
  121190. * @param updatable defines if the index buffer must be updatable
  121191. * @returns a new webGL buffer
  121192. */
  121193. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121194. /**
  121195. * Clear the current render buffer or the current render target (if any is set up)
  121196. * @param color defines the color to use
  121197. * @param backBuffer defines if the back buffer must be cleared
  121198. * @param depth defines if the depth buffer must be cleared
  121199. * @param stencil defines if the stencil buffer must be cleared
  121200. */
  121201. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121202. /**
  121203. * Gets the current render width
  121204. * @param useScreen defines if screen size must be used (or the current render target if any)
  121205. * @returns a number defining the current render width
  121206. */
  121207. getRenderWidth(useScreen?: boolean): number;
  121208. /**
  121209. * Gets the current render height
  121210. * @param useScreen defines if screen size must be used (or the current render target if any)
  121211. * @returns a number defining the current render height
  121212. */
  121213. getRenderHeight(useScreen?: boolean): number;
  121214. /**
  121215. * Set the WebGL's viewport
  121216. * @param viewport defines the viewport element to be used
  121217. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121218. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121219. */
  121220. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121221. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121222. /**
  121223. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121224. * @param pipelineContext defines the pipeline context to use
  121225. * @param uniformsNames defines the list of uniform names
  121226. * @returns an array of webGL uniform locations
  121227. */
  121228. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121229. /**
  121230. * Gets the lsit of active attributes for a given webGL program
  121231. * @param pipelineContext defines the pipeline context to use
  121232. * @param attributesNames defines the list of attribute names to get
  121233. * @returns an array of indices indicating the offset of each attribute
  121234. */
  121235. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121236. /**
  121237. * Binds an effect to the webGL context
  121238. * @param effect defines the effect to bind
  121239. */
  121240. bindSamplers(effect: Effect): void;
  121241. /**
  121242. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121243. * @param effect defines the effect to activate
  121244. */
  121245. enableEffect(effect: Effect): void;
  121246. /**
  121247. * Set various states to the webGL context
  121248. * @param culling defines backface culling state
  121249. * @param zOffset defines the value to apply to zOffset (0 by default)
  121250. * @param force defines if states must be applied even if cache is up to date
  121251. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121252. */
  121253. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121254. /**
  121255. * Set the value of an uniform to an array of int32
  121256. * @param uniform defines the webGL uniform location where to store the value
  121257. * @param array defines the array of int32 to store
  121258. */
  121259. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121260. /**
  121261. * Set the value of an uniform to an array of int32 (stored as vec2)
  121262. * @param uniform defines the webGL uniform location where to store the value
  121263. * @param array defines the array of int32 to store
  121264. */
  121265. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121266. /**
  121267. * Set the value of an uniform to an array of int32 (stored as vec3)
  121268. * @param uniform defines the webGL uniform location where to store the value
  121269. * @param array defines the array of int32 to store
  121270. */
  121271. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121272. /**
  121273. * Set the value of an uniform to an array of int32 (stored as vec4)
  121274. * @param uniform defines the webGL uniform location where to store the value
  121275. * @param array defines the array of int32 to store
  121276. */
  121277. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121278. /**
  121279. * Set the value of an uniform to an array of float32
  121280. * @param uniform defines the webGL uniform location where to store the value
  121281. * @param array defines the array of float32 to store
  121282. */
  121283. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121284. /**
  121285. * Set the value of an uniform to an array of float32 (stored as vec2)
  121286. * @param uniform defines the webGL uniform location where to store the value
  121287. * @param array defines the array of float32 to store
  121288. */
  121289. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121290. /**
  121291. * Set the value of an uniform to an array of float32 (stored as vec3)
  121292. * @param uniform defines the webGL uniform location where to store the value
  121293. * @param array defines the array of float32 to store
  121294. */
  121295. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121296. /**
  121297. * Set the value of an uniform to an array of float32 (stored as vec4)
  121298. * @param uniform defines the webGL uniform location where to store the value
  121299. * @param array defines the array of float32 to store
  121300. */
  121301. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121302. /**
  121303. * Set the value of an uniform to an array of number
  121304. * @param uniform defines the webGL uniform location where to store the value
  121305. * @param array defines the array of number to store
  121306. */
  121307. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121308. /**
  121309. * Set the value of an uniform to an array of number (stored as vec2)
  121310. * @param uniform defines the webGL uniform location where to store the value
  121311. * @param array defines the array of number to store
  121312. */
  121313. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121314. /**
  121315. * Set the value of an uniform to an array of number (stored as vec3)
  121316. * @param uniform defines the webGL uniform location where to store the value
  121317. * @param array defines the array of number to store
  121318. */
  121319. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121320. /**
  121321. * Set the value of an uniform to an array of number (stored as vec4)
  121322. * @param uniform defines the webGL uniform location where to store the value
  121323. * @param array defines the array of number to store
  121324. */
  121325. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121326. /**
  121327. * Set the value of an uniform to an array of float32 (stored as matrices)
  121328. * @param uniform defines the webGL uniform location where to store the value
  121329. * @param matrices defines the array of float32 to store
  121330. */
  121331. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121332. /**
  121333. * Set the value of an uniform to a matrix (3x3)
  121334. * @param uniform defines the webGL uniform location where to store the value
  121335. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121336. */
  121337. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121338. /**
  121339. * Set the value of an uniform to a matrix (2x2)
  121340. * @param uniform defines the webGL uniform location where to store the value
  121341. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121342. */
  121343. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121344. /**
  121345. * Set the value of an uniform to a number (float)
  121346. * @param uniform defines the webGL uniform location where to store the value
  121347. * @param value defines the float number to store
  121348. */
  121349. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121350. /**
  121351. * Set the value of an uniform to a vec2
  121352. * @param uniform defines the webGL uniform location where to store the value
  121353. * @param x defines the 1st component of the value
  121354. * @param y defines the 2nd component of the value
  121355. */
  121356. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121357. /**
  121358. * Set the value of an uniform to a vec3
  121359. * @param uniform defines the webGL uniform location where to store the value
  121360. * @param x defines the 1st component of the value
  121361. * @param y defines the 2nd component of the value
  121362. * @param z defines the 3rd component of the value
  121363. */
  121364. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121365. /**
  121366. * Set the value of an uniform to a boolean
  121367. * @param uniform defines the webGL uniform location where to store the value
  121368. * @param bool defines the boolean to store
  121369. */
  121370. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121371. /**
  121372. * Set the value of an uniform to a vec4
  121373. * @param uniform defines the webGL uniform location where to store the value
  121374. * @param x defines the 1st component of the value
  121375. * @param y defines the 2nd component of the value
  121376. * @param z defines the 3rd component of the value
  121377. * @param w defines the 4th component of the value
  121378. */
  121379. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121380. /**
  121381. * Sets the current alpha mode
  121382. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121383. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121384. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121385. */
  121386. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121387. /**
  121388. * Bind webGl buffers directly to the webGL context
  121389. * @param vertexBuffers defines the vertex buffer to bind
  121390. * @param indexBuffer defines the index buffer to bind
  121391. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121392. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121393. * @param effect defines the effect associated with the vertex buffer
  121394. */
  121395. bindBuffers(vertexBuffers: {
  121396. [key: string]: VertexBuffer;
  121397. }, indexBuffer: DataBuffer, effect: Effect): void;
  121398. /**
  121399. * Force the entire cache to be cleared
  121400. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121401. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121402. */
  121403. wipeCaches(bruteForce?: boolean): void;
  121404. /**
  121405. * Send a draw order
  121406. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121407. * @param indexStart defines the starting index
  121408. * @param indexCount defines the number of index to draw
  121409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121410. */
  121411. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121412. /**
  121413. * Draw a list of indexed primitives
  121414. * @param fillMode defines the primitive to use
  121415. * @param indexStart defines the starting index
  121416. * @param indexCount defines the number of index to draw
  121417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121418. */
  121419. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121420. /**
  121421. * Draw a list of unindexed primitives
  121422. * @param fillMode defines the primitive to use
  121423. * @param verticesStart defines the index of first vertex to draw
  121424. * @param verticesCount defines the count of vertices to draw
  121425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121426. */
  121427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121428. /** @hidden */
  121429. _createTexture(): WebGLTexture;
  121430. /** @hidden */
  121431. _releaseTexture(texture: InternalTexture): void;
  121432. /**
  121433. * Usually called from Texture.ts.
  121434. * Passed information to create a WebGLTexture
  121435. * @param urlArg defines a value which contains one of the following:
  121436. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121437. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121438. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121439. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121440. * @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)
  121441. * @param scene needed for loading to the correct scene
  121442. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121443. * @param onLoad optional callback to be called upon successful completion
  121444. * @param onError optional callback to be called upon failure
  121445. * @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
  121446. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121447. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121448. * @param forcedExtension defines the extension to use to pick the right loader
  121449. * @param mimeType defines an optional mime type
  121450. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121451. */
  121452. 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;
  121453. /**
  121454. * Creates a new render target texture
  121455. * @param size defines the size of the texture
  121456. * @param options defines the options used to create the texture
  121457. * @returns a new render target texture stored in an InternalTexture
  121458. */
  121459. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121460. /**
  121461. * Update the sampling mode of a given texture
  121462. * @param samplingMode defines the required sampling mode
  121463. * @param texture defines the texture to update
  121464. */
  121465. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121466. /**
  121467. * Binds the frame buffer to the specified texture.
  121468. * @param texture The texture to render to or null for the default canvas
  121469. * @param faceIndex The face of the texture to render to in case of cube texture
  121470. * @param requiredWidth The width of the target to render to
  121471. * @param requiredHeight The height of the target to render to
  121472. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121473. * @param lodLevel defines le lod level to bind to the frame buffer
  121474. */
  121475. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121476. /**
  121477. * Unbind the current render target texture from the webGL context
  121478. * @param texture defines the render target texture to unbind
  121479. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121480. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121481. */
  121482. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121483. /**
  121484. * Creates a dynamic vertex buffer
  121485. * @param vertices the data for the dynamic vertex buffer
  121486. * @returns the new WebGL dynamic buffer
  121487. */
  121488. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121489. /**
  121490. * Update the content of a dynamic texture
  121491. * @param texture defines the texture to update
  121492. * @param canvas defines the canvas containing the source
  121493. * @param invertY defines if data must be stored with Y axis inverted
  121494. * @param premulAlpha defines if alpha is stored as premultiplied
  121495. * @param format defines the format of the data
  121496. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121497. */
  121498. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121499. /**
  121500. * Gets a boolean indicating if all created effects are ready
  121501. * @returns true if all effects are ready
  121502. */
  121503. areAllEffectsReady(): boolean;
  121504. /**
  121505. * @hidden
  121506. * Get the current error code of the webGL context
  121507. * @returns the error code
  121508. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121509. */
  121510. getError(): number;
  121511. /** @hidden */
  121512. _getUnpackAlignement(): number;
  121513. /** @hidden */
  121514. _unpackFlipY(value: boolean): void;
  121515. /**
  121516. * Update a dynamic index buffer
  121517. * @param indexBuffer defines the target index buffer
  121518. * @param indices defines the data to update
  121519. * @param offset defines the offset in the target index buffer where update should start
  121520. */
  121521. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121522. /**
  121523. * Updates a dynamic vertex buffer.
  121524. * @param vertexBuffer the vertex buffer to update
  121525. * @param vertices the data used to update the vertex buffer
  121526. * @param byteOffset the byte offset of the data (optional)
  121527. * @param byteLength the byte length of the data (optional)
  121528. */
  121529. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121530. /** @hidden */
  121531. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121532. /** @hidden */
  121533. _bindTexture(channel: number, texture: InternalTexture): void;
  121534. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121535. /**
  121536. * 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
  121537. */
  121538. releaseEffects(): void;
  121539. displayLoadingUI(): void;
  121540. hideLoadingUI(): void;
  121541. /** @hidden */
  121542. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121543. /** @hidden */
  121544. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121545. /** @hidden */
  121546. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121547. /** @hidden */
  121548. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121549. }
  121550. }
  121551. declare module BABYLON {
  121552. /**
  121553. * @hidden
  121554. **/
  121555. export class _TimeToken {
  121556. _startTimeQuery: Nullable<WebGLQuery>;
  121557. _endTimeQuery: Nullable<WebGLQuery>;
  121558. _timeElapsedQuery: Nullable<WebGLQuery>;
  121559. _timeElapsedQueryEnded: boolean;
  121560. }
  121561. }
  121562. declare module BABYLON {
  121563. /** @hidden */
  121564. export class _OcclusionDataStorage {
  121565. /** @hidden */
  121566. occlusionInternalRetryCounter: number;
  121567. /** @hidden */
  121568. isOcclusionQueryInProgress: boolean;
  121569. /** @hidden */
  121570. isOccluded: boolean;
  121571. /** @hidden */
  121572. occlusionRetryCount: number;
  121573. /** @hidden */
  121574. occlusionType: number;
  121575. /** @hidden */
  121576. occlusionQueryAlgorithmType: number;
  121577. }
  121578. interface Engine {
  121579. /**
  121580. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121581. * @return the new query
  121582. */
  121583. createQuery(): WebGLQuery;
  121584. /**
  121585. * Delete and release a webGL query
  121586. * @param query defines the query to delete
  121587. * @return the current engine
  121588. */
  121589. deleteQuery(query: WebGLQuery): Engine;
  121590. /**
  121591. * Check if a given query has resolved and got its value
  121592. * @param query defines the query to check
  121593. * @returns true if the query got its value
  121594. */
  121595. isQueryResultAvailable(query: WebGLQuery): boolean;
  121596. /**
  121597. * Gets the value of a given query
  121598. * @param query defines the query to check
  121599. * @returns the value of the query
  121600. */
  121601. getQueryResult(query: WebGLQuery): number;
  121602. /**
  121603. * Initiates an occlusion query
  121604. * @param algorithmType defines the algorithm to use
  121605. * @param query defines the query to use
  121606. * @returns the current engine
  121607. * @see http://doc.babylonjs.com/features/occlusionquery
  121608. */
  121609. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121610. /**
  121611. * Ends an occlusion query
  121612. * @see http://doc.babylonjs.com/features/occlusionquery
  121613. * @param algorithmType defines the algorithm to use
  121614. * @returns the current engine
  121615. */
  121616. endOcclusionQuery(algorithmType: number): Engine;
  121617. /**
  121618. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121619. * Please note that only one query can be issued at a time
  121620. * @returns a time token used to track the time span
  121621. */
  121622. startTimeQuery(): Nullable<_TimeToken>;
  121623. /**
  121624. * Ends a time query
  121625. * @param token defines the token used to measure the time span
  121626. * @returns the time spent (in ns)
  121627. */
  121628. endTimeQuery(token: _TimeToken): int;
  121629. /** @hidden */
  121630. _currentNonTimestampToken: Nullable<_TimeToken>;
  121631. /** @hidden */
  121632. _createTimeQuery(): WebGLQuery;
  121633. /** @hidden */
  121634. _deleteTimeQuery(query: WebGLQuery): void;
  121635. /** @hidden */
  121636. _getGlAlgorithmType(algorithmType: number): number;
  121637. /** @hidden */
  121638. _getTimeQueryResult(query: WebGLQuery): any;
  121639. /** @hidden */
  121640. _getTimeQueryAvailability(query: WebGLQuery): any;
  121641. }
  121642. interface AbstractMesh {
  121643. /**
  121644. * Backing filed
  121645. * @hidden
  121646. */
  121647. __occlusionDataStorage: _OcclusionDataStorage;
  121648. /**
  121649. * Access property
  121650. * @hidden
  121651. */
  121652. _occlusionDataStorage: _OcclusionDataStorage;
  121653. /**
  121654. * 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.
  121655. * The default value is -1 which means don't break the query and wait till the result
  121656. * @see http://doc.babylonjs.com/features/occlusionquery
  121657. */
  121658. occlusionRetryCount: number;
  121659. /**
  121660. * 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:
  121661. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121662. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121663. * * 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.
  121664. * @see http://doc.babylonjs.com/features/occlusionquery
  121665. */
  121666. occlusionType: number;
  121667. /**
  121668. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121669. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121670. * * 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.
  121671. * @see http://doc.babylonjs.com/features/occlusionquery
  121672. */
  121673. occlusionQueryAlgorithmType: number;
  121674. /**
  121675. * 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
  121676. * @see http://doc.babylonjs.com/features/occlusionquery
  121677. */
  121678. isOccluded: boolean;
  121679. /**
  121680. * Flag to check the progress status of the query
  121681. * @see http://doc.babylonjs.com/features/occlusionquery
  121682. */
  121683. isOcclusionQueryInProgress: boolean;
  121684. }
  121685. }
  121686. declare module BABYLON {
  121687. /** @hidden */
  121688. export var _forceTransformFeedbackToBundle: boolean;
  121689. interface Engine {
  121690. /**
  121691. * Creates a webGL transform feedback object
  121692. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121693. * @returns the webGL transform feedback object
  121694. */
  121695. createTransformFeedback(): WebGLTransformFeedback;
  121696. /**
  121697. * Delete a webGL transform feedback object
  121698. * @param value defines the webGL transform feedback object to delete
  121699. */
  121700. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121701. /**
  121702. * Bind a webGL transform feedback object to the webgl context
  121703. * @param value defines the webGL transform feedback object to bind
  121704. */
  121705. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121706. /**
  121707. * Begins a transform feedback operation
  121708. * @param usePoints defines if points or triangles must be used
  121709. */
  121710. beginTransformFeedback(usePoints: boolean): void;
  121711. /**
  121712. * Ends a transform feedback operation
  121713. */
  121714. endTransformFeedback(): void;
  121715. /**
  121716. * Specify the varyings to use with transform feedback
  121717. * @param program defines the associated webGL program
  121718. * @param value defines the list of strings representing the varying names
  121719. */
  121720. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121721. /**
  121722. * Bind a webGL buffer for a transform feedback operation
  121723. * @param value defines the webGL buffer to bind
  121724. */
  121725. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121726. }
  121727. }
  121728. declare module BABYLON {
  121729. /**
  121730. * Creation options of the multi render target texture.
  121731. */
  121732. export interface IMultiRenderTargetOptions {
  121733. /**
  121734. * Define if the texture needs to create mip maps after render.
  121735. */
  121736. generateMipMaps?: boolean;
  121737. /**
  121738. * Define the types of all the draw buffers we want to create
  121739. */
  121740. types?: number[];
  121741. /**
  121742. * Define the sampling modes of all the draw buffers we want to create
  121743. */
  121744. samplingModes?: number[];
  121745. /**
  121746. * Define if a depth buffer is required
  121747. */
  121748. generateDepthBuffer?: boolean;
  121749. /**
  121750. * Define if a stencil buffer is required
  121751. */
  121752. generateStencilBuffer?: boolean;
  121753. /**
  121754. * Define if a depth texture is required instead of a depth buffer
  121755. */
  121756. generateDepthTexture?: boolean;
  121757. /**
  121758. * Define the number of desired draw buffers
  121759. */
  121760. textureCount?: number;
  121761. /**
  121762. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121763. */
  121764. doNotChangeAspectRatio?: boolean;
  121765. /**
  121766. * Define the default type of the buffers we are creating
  121767. */
  121768. defaultType?: number;
  121769. }
  121770. /**
  121771. * A multi render target, like a render target provides the ability to render to a texture.
  121772. * Unlike the render target, it can render to several draw buffers in one draw.
  121773. * This is specially interesting in deferred rendering or for any effects requiring more than
  121774. * just one color from a single pass.
  121775. */
  121776. export class MultiRenderTarget extends RenderTargetTexture {
  121777. private _internalTextures;
  121778. private _textures;
  121779. private _multiRenderTargetOptions;
  121780. /**
  121781. * Get if draw buffers are currently supported by the used hardware and browser.
  121782. */
  121783. get isSupported(): boolean;
  121784. /**
  121785. * Get the list of textures generated by the multi render target.
  121786. */
  121787. get textures(): Texture[];
  121788. /**
  121789. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121790. */
  121791. get depthTexture(): Texture;
  121792. /**
  121793. * Set the wrapping mode on U of all the textures we are rendering to.
  121794. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121795. */
  121796. set wrapU(wrap: number);
  121797. /**
  121798. * Set the wrapping mode on V of all the textures we are rendering to.
  121799. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121800. */
  121801. set wrapV(wrap: number);
  121802. /**
  121803. * Instantiate a new multi render target texture.
  121804. * A multi render target, like a render target provides the ability to render to a texture.
  121805. * Unlike the render target, it can render to several draw buffers in one draw.
  121806. * This is specially interesting in deferred rendering or for any effects requiring more than
  121807. * just one color from a single pass.
  121808. * @param name Define the name of the texture
  121809. * @param size Define the size of the buffers to render to
  121810. * @param count Define the number of target we are rendering into
  121811. * @param scene Define the scene the texture belongs to
  121812. * @param options Define the options used to create the multi render target
  121813. */
  121814. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121815. /** @hidden */
  121816. _rebuild(): void;
  121817. private _createInternalTextures;
  121818. private _createTextures;
  121819. /**
  121820. * Define the number of samples used if MSAA is enabled.
  121821. */
  121822. get samples(): number;
  121823. set samples(value: number);
  121824. /**
  121825. * Resize all the textures in the multi render target.
  121826. * Be carrefull as it will recreate all the data in the new texture.
  121827. * @param size Define the new size
  121828. */
  121829. resize(size: any): void;
  121830. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121831. /**
  121832. * Dispose the render targets and their associated resources
  121833. */
  121834. dispose(): void;
  121835. /**
  121836. * Release all the underlying texture used as draw buffers.
  121837. */
  121838. releaseInternalTextures(): void;
  121839. }
  121840. }
  121841. declare module BABYLON {
  121842. interface ThinEngine {
  121843. /**
  121844. * Unbind a list of render target textures from the webGL context
  121845. * This is used only when drawBuffer extension or webGL2 are active
  121846. * @param textures defines the render target textures to unbind
  121847. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121848. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121849. */
  121850. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121851. /**
  121852. * Create a multi render target texture
  121853. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121854. * @param size defines the size of the texture
  121855. * @param options defines the creation options
  121856. * @returns the cube texture as an InternalTexture
  121857. */
  121858. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121859. /**
  121860. * Update the sample count for a given multiple render target texture
  121861. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121862. * @param textures defines the textures to update
  121863. * @param samples defines the sample count to set
  121864. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121865. */
  121866. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121867. }
  121868. }
  121869. declare module BABYLON {
  121870. /**
  121871. * Class used to define an additional view for the engine
  121872. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121873. */
  121874. export class EngineView {
  121875. /** Defines the canvas where to render the view */
  121876. target: HTMLCanvasElement;
  121877. /** Defines an optional camera used to render the view (will use active camera else) */
  121878. camera?: Camera;
  121879. }
  121880. interface Engine {
  121881. /**
  121882. * Gets or sets the HTML element to use for attaching events
  121883. */
  121884. inputElement: Nullable<HTMLElement>;
  121885. /**
  121886. * Gets the current engine view
  121887. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121888. */
  121889. activeView: Nullable<EngineView>;
  121890. /** Gets or sets the list of views */
  121891. views: EngineView[];
  121892. /**
  121893. * Register a new child canvas
  121894. * @param canvas defines the canvas to register
  121895. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121896. * @returns the associated view
  121897. */
  121898. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121899. /**
  121900. * Remove a registered child canvas
  121901. * @param canvas defines the canvas to remove
  121902. * @returns the current engine
  121903. */
  121904. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121905. }
  121906. }
  121907. declare module BABYLON {
  121908. interface Engine {
  121909. /** @hidden */
  121910. _excludedCompressedTextures: string[];
  121911. /** @hidden */
  121912. _textureFormatInUse: string;
  121913. /**
  121914. * Gets the list of texture formats supported
  121915. */
  121916. readonly texturesSupported: Array<string>;
  121917. /**
  121918. * Gets the texture format in use
  121919. */
  121920. readonly textureFormatInUse: Nullable<string>;
  121921. /**
  121922. * Set the compressed texture extensions or file names to skip.
  121923. *
  121924. * @param skippedFiles defines the list of those texture files you want to skip
  121925. * Example: [".dds", ".env", "myfile.png"]
  121926. */
  121927. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121928. /**
  121929. * Set the compressed texture format to use, based on the formats you have, and the formats
  121930. * supported by the hardware / browser.
  121931. *
  121932. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121933. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121934. * to API arguments needed to compressed textures. This puts the burden on the container
  121935. * generator to house the arcane code for determining these for current & future formats.
  121936. *
  121937. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121938. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121939. *
  121940. * Note: The result of this call is not taken into account when a texture is base64.
  121941. *
  121942. * @param formatsAvailable defines the list of those format families you have created
  121943. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121944. *
  121945. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121946. * @returns The extension selected.
  121947. */
  121948. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121949. }
  121950. }
  121951. declare module BABYLON {
  121952. /**
  121953. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121954. */
  121955. export interface CubeMapInfo {
  121956. /**
  121957. * The pixel array for the front face.
  121958. * This is stored in format, left to right, up to down format.
  121959. */
  121960. front: Nullable<ArrayBufferView>;
  121961. /**
  121962. * The pixel array for the back face.
  121963. * This is stored in format, left to right, up to down format.
  121964. */
  121965. back: Nullable<ArrayBufferView>;
  121966. /**
  121967. * The pixel array for the left face.
  121968. * This is stored in format, left to right, up to down format.
  121969. */
  121970. left: Nullable<ArrayBufferView>;
  121971. /**
  121972. * The pixel array for the right face.
  121973. * This is stored in format, left to right, up to down format.
  121974. */
  121975. right: Nullable<ArrayBufferView>;
  121976. /**
  121977. * The pixel array for the up face.
  121978. * This is stored in format, left to right, up to down format.
  121979. */
  121980. up: Nullable<ArrayBufferView>;
  121981. /**
  121982. * The pixel array for the down face.
  121983. * This is stored in format, left to right, up to down format.
  121984. */
  121985. down: Nullable<ArrayBufferView>;
  121986. /**
  121987. * The size of the cubemap stored.
  121988. *
  121989. * Each faces will be size * size pixels.
  121990. */
  121991. size: number;
  121992. /**
  121993. * The format of the texture.
  121994. *
  121995. * RGBA, RGB.
  121996. */
  121997. format: number;
  121998. /**
  121999. * The type of the texture data.
  122000. *
  122001. * UNSIGNED_INT, FLOAT.
  122002. */
  122003. type: number;
  122004. /**
  122005. * Specifies whether the texture is in gamma space.
  122006. */
  122007. gammaSpace: boolean;
  122008. }
  122009. /**
  122010. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  122011. */
  122012. export class PanoramaToCubeMapTools {
  122013. private static FACE_FRONT;
  122014. private static FACE_BACK;
  122015. private static FACE_RIGHT;
  122016. private static FACE_LEFT;
  122017. private static FACE_DOWN;
  122018. private static FACE_UP;
  122019. /**
  122020. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  122021. *
  122022. * @param float32Array The source data.
  122023. * @param inputWidth The width of the input panorama.
  122024. * @param inputHeight The height of the input panorama.
  122025. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  122026. * @return The cubemap data
  122027. */
  122028. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122029. private static CreateCubemapTexture;
  122030. private static CalcProjectionSpherical;
  122031. }
  122032. }
  122033. declare module BABYLON {
  122034. /**
  122035. * Helper class dealing with the extraction of spherical polynomial dataArray
  122036. * from a cube map.
  122037. */
  122038. export class CubeMapToSphericalPolynomialTools {
  122039. private static FileFaces;
  122040. /**
  122041. * Converts a texture to the according Spherical Polynomial data.
  122042. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122043. *
  122044. * @param texture The texture to extract the information from.
  122045. * @return The Spherical Polynomial data.
  122046. */
  122047. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122048. /**
  122049. * Converts a cubemap to the according Spherical Polynomial data.
  122050. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122051. *
  122052. * @param cubeInfo The Cube map to extract the information from.
  122053. * @return The Spherical Polynomial data.
  122054. */
  122055. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122056. }
  122057. }
  122058. declare module BABYLON {
  122059. interface BaseTexture {
  122060. /**
  122061. * Get the polynomial representation of the texture data.
  122062. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122063. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122064. */
  122065. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122066. }
  122067. }
  122068. declare module BABYLON {
  122069. /** @hidden */
  122070. export var rgbdEncodePixelShader: {
  122071. name: string;
  122072. shader: string;
  122073. };
  122074. }
  122075. declare module BABYLON {
  122076. /** @hidden */
  122077. export var rgbdDecodePixelShader: {
  122078. name: string;
  122079. shader: string;
  122080. };
  122081. }
  122082. declare module BABYLON {
  122083. /**
  122084. * Raw texture data and descriptor sufficient for WebGL texture upload
  122085. */
  122086. export interface EnvironmentTextureInfo {
  122087. /**
  122088. * Version of the environment map
  122089. */
  122090. version: number;
  122091. /**
  122092. * Width of image
  122093. */
  122094. width: number;
  122095. /**
  122096. * Irradiance information stored in the file.
  122097. */
  122098. irradiance: any;
  122099. /**
  122100. * Specular information stored in the file.
  122101. */
  122102. specular: any;
  122103. }
  122104. /**
  122105. * Defines One Image in the file. It requires only the position in the file
  122106. * as well as the length.
  122107. */
  122108. interface BufferImageData {
  122109. /**
  122110. * Length of the image data.
  122111. */
  122112. length: number;
  122113. /**
  122114. * Position of the data from the null terminator delimiting the end of the JSON.
  122115. */
  122116. position: number;
  122117. }
  122118. /**
  122119. * Defines the specular data enclosed in the file.
  122120. * This corresponds to the version 1 of the data.
  122121. */
  122122. export interface EnvironmentTextureSpecularInfoV1 {
  122123. /**
  122124. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122125. */
  122126. specularDataPosition?: number;
  122127. /**
  122128. * This contains all the images data needed to reconstruct the cubemap.
  122129. */
  122130. mipmaps: Array<BufferImageData>;
  122131. /**
  122132. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122133. */
  122134. lodGenerationScale: number;
  122135. }
  122136. /**
  122137. * Sets of helpers addressing the serialization and deserialization of environment texture
  122138. * stored in a BabylonJS env file.
  122139. * Those files are usually stored as .env files.
  122140. */
  122141. export class EnvironmentTextureTools {
  122142. /**
  122143. * Magic number identifying the env file.
  122144. */
  122145. private static _MagicBytes;
  122146. /**
  122147. * Gets the environment info from an env file.
  122148. * @param data The array buffer containing the .env bytes.
  122149. * @returns the environment file info (the json header) if successfully parsed.
  122150. */
  122151. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122152. /**
  122153. * Creates an environment texture from a loaded cube texture.
  122154. * @param texture defines the cube texture to convert in env file
  122155. * @return a promise containing the environment data if succesfull.
  122156. */
  122157. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122158. /**
  122159. * Creates a JSON representation of the spherical data.
  122160. * @param texture defines the texture containing the polynomials
  122161. * @return the JSON representation of the spherical info
  122162. */
  122163. private static _CreateEnvTextureIrradiance;
  122164. /**
  122165. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122166. * @param data the image data
  122167. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122168. * @return the views described by info providing access to the underlying buffer
  122169. */
  122170. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122171. /**
  122172. * Uploads the texture info contained in the env file to the GPU.
  122173. * @param texture defines the internal texture to upload to
  122174. * @param data defines the data to load
  122175. * @param info defines the texture info retrieved through the GetEnvInfo method
  122176. * @returns a promise
  122177. */
  122178. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122179. private static _OnImageReadyAsync;
  122180. /**
  122181. * Uploads the levels of image data to the GPU.
  122182. * @param texture defines the internal texture to upload to
  122183. * @param imageData defines the array buffer views of image data [mipmap][face]
  122184. * @returns a promise
  122185. */
  122186. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122187. /**
  122188. * Uploads spherical polynomials information to the texture.
  122189. * @param texture defines the texture we are trying to upload the information to
  122190. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122191. */
  122192. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122193. /** @hidden */
  122194. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122195. }
  122196. }
  122197. declare module BABYLON {
  122198. /**
  122199. * Contains position and normal vectors for a vertex
  122200. */
  122201. export class PositionNormalVertex {
  122202. /** the position of the vertex (defaut: 0,0,0) */
  122203. position: Vector3;
  122204. /** the normal of the vertex (defaut: 0,1,0) */
  122205. normal: Vector3;
  122206. /**
  122207. * Creates a PositionNormalVertex
  122208. * @param position the position of the vertex (defaut: 0,0,0)
  122209. * @param normal the normal of the vertex (defaut: 0,1,0)
  122210. */
  122211. constructor(
  122212. /** the position of the vertex (defaut: 0,0,0) */
  122213. position?: Vector3,
  122214. /** the normal of the vertex (defaut: 0,1,0) */
  122215. normal?: Vector3);
  122216. /**
  122217. * Clones the PositionNormalVertex
  122218. * @returns the cloned PositionNormalVertex
  122219. */
  122220. clone(): PositionNormalVertex;
  122221. }
  122222. /**
  122223. * Contains position, normal and uv vectors for a vertex
  122224. */
  122225. export class PositionNormalTextureVertex {
  122226. /** the position of the vertex (defaut: 0,0,0) */
  122227. position: Vector3;
  122228. /** the normal of the vertex (defaut: 0,1,0) */
  122229. normal: Vector3;
  122230. /** the uv of the vertex (default: 0,0) */
  122231. uv: Vector2;
  122232. /**
  122233. * Creates a PositionNormalTextureVertex
  122234. * @param position the position of the vertex (defaut: 0,0,0)
  122235. * @param normal the normal of the vertex (defaut: 0,1,0)
  122236. * @param uv the uv of the vertex (default: 0,0)
  122237. */
  122238. constructor(
  122239. /** the position of the vertex (defaut: 0,0,0) */
  122240. position?: Vector3,
  122241. /** the normal of the vertex (defaut: 0,1,0) */
  122242. normal?: Vector3,
  122243. /** the uv of the vertex (default: 0,0) */
  122244. uv?: Vector2);
  122245. /**
  122246. * Clones the PositionNormalTextureVertex
  122247. * @returns the cloned PositionNormalTextureVertex
  122248. */
  122249. clone(): PositionNormalTextureVertex;
  122250. }
  122251. }
  122252. declare module BABYLON {
  122253. /** @hidden */
  122254. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122255. private _genericAttributeLocation;
  122256. private _varyingLocationCount;
  122257. private _varyingLocationMap;
  122258. private _replacements;
  122259. private _textureCount;
  122260. private _uniforms;
  122261. lineProcessor(line: string): string;
  122262. attributeProcessor(attribute: string): string;
  122263. varyingProcessor(varying: string, isFragment: boolean): string;
  122264. uniformProcessor(uniform: string): string;
  122265. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122266. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122267. }
  122268. }
  122269. declare module BABYLON {
  122270. /**
  122271. * Container for accessors for natively-stored mesh data buffers.
  122272. */
  122273. class NativeDataBuffer extends DataBuffer {
  122274. /**
  122275. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122276. */
  122277. nativeIndexBuffer?: any;
  122278. /**
  122279. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122280. */
  122281. nativeVertexBuffer?: any;
  122282. }
  122283. /** @hidden */
  122284. class NativeTexture extends InternalTexture {
  122285. getInternalTexture(): InternalTexture;
  122286. getViewCount(): number;
  122287. }
  122288. /** @hidden */
  122289. export class NativeEngine extends Engine {
  122290. private readonly _native;
  122291. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122292. private readonly INVALID_HANDLE;
  122293. getHardwareScalingLevel(): number;
  122294. constructor();
  122295. /**
  122296. * Can be used to override the current requestAnimationFrame requester.
  122297. * @hidden
  122298. */
  122299. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122300. /**
  122301. * Override default engine behavior.
  122302. * @param color
  122303. * @param backBuffer
  122304. * @param depth
  122305. * @param stencil
  122306. */
  122307. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122308. /**
  122309. * Gets host document
  122310. * @returns the host document object
  122311. */
  122312. getHostDocument(): Nullable<Document>;
  122313. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122314. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122315. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122316. recordVertexArrayObject(vertexBuffers: {
  122317. [key: string]: VertexBuffer;
  122318. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122319. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122320. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122321. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122322. /**
  122323. * Draw a list of indexed primitives
  122324. * @param fillMode defines the primitive to use
  122325. * @param indexStart defines the starting index
  122326. * @param indexCount defines the number of index to draw
  122327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122328. */
  122329. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122330. /**
  122331. * Draw a list of unindexed primitives
  122332. * @param fillMode defines the primitive to use
  122333. * @param verticesStart defines the index of first vertex to draw
  122334. * @param verticesCount defines the count of vertices to draw
  122335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122336. */
  122337. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122338. createPipelineContext(): IPipelineContext;
  122339. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122340. /** @hidden */
  122341. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122342. /** @hidden */
  122343. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122344. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122345. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122346. protected _setProgram(program: WebGLProgram): void;
  122347. _releaseEffect(effect: Effect): void;
  122348. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122349. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122350. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122351. bindSamplers(effect: Effect): void;
  122352. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122353. getRenderWidth(useScreen?: boolean): number;
  122354. getRenderHeight(useScreen?: boolean): number;
  122355. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122356. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122357. /**
  122358. * Set the z offset to apply to current rendering
  122359. * @param value defines the offset to apply
  122360. */
  122361. setZOffset(value: number): void;
  122362. /**
  122363. * Gets the current value of the zOffset
  122364. * @returns the current zOffset state
  122365. */
  122366. getZOffset(): number;
  122367. /**
  122368. * Enable or disable depth buffering
  122369. * @param enable defines the state to set
  122370. */
  122371. setDepthBuffer(enable: boolean): void;
  122372. /**
  122373. * Gets a boolean indicating if depth writing is enabled
  122374. * @returns the current depth writing state
  122375. */
  122376. getDepthWrite(): boolean;
  122377. /**
  122378. * Enable or disable depth writing
  122379. * @param enable defines the state to set
  122380. */
  122381. setDepthWrite(enable: boolean): void;
  122382. /**
  122383. * Enable or disable color writing
  122384. * @param enable defines the state to set
  122385. */
  122386. setColorWrite(enable: boolean): void;
  122387. /**
  122388. * Gets a boolean indicating if color writing is enabled
  122389. * @returns the current color writing state
  122390. */
  122391. getColorWrite(): boolean;
  122392. /**
  122393. * Sets alpha constants used by some alpha blending modes
  122394. * @param r defines the red component
  122395. * @param g defines the green component
  122396. * @param b defines the blue component
  122397. * @param a defines the alpha component
  122398. */
  122399. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122400. /**
  122401. * Sets the current alpha mode
  122402. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122403. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122405. */
  122406. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122407. /**
  122408. * Gets the current alpha mode
  122409. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122410. * @returns the current alpha mode
  122411. */
  122412. getAlphaMode(): number;
  122413. setInt(uniform: WebGLUniformLocation, int: number): void;
  122414. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122415. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122416. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122417. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122418. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122419. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122420. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122421. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122422. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122423. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122424. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122425. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122426. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122427. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122428. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122429. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122430. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122431. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122432. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122433. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122434. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122435. wipeCaches(bruteForce?: boolean): void;
  122436. _createTexture(): WebGLTexture;
  122437. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122438. /**
  122439. * Usually called from Texture.ts.
  122440. * Passed information to create a WebGLTexture
  122441. * @param urlArg defines a value which contains one of the following:
  122442. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122443. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122444. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122445. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122446. * @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)
  122447. * @param scene needed for loading to the correct scene
  122448. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122449. * @param onLoad optional callback to be called upon successful completion
  122450. * @param onError optional callback to be called upon failure
  122451. * @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
  122452. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122453. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122454. * @param forcedExtension defines the extension to use to pick the right loader
  122455. * @param mimeType defines an optional mime type
  122456. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122457. */
  122458. 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;
  122459. /**
  122460. * Creates a cube texture
  122461. * @param rootUrl defines the url where the files to load is located
  122462. * @param scene defines the current scene
  122463. * @param files defines the list of files to load (1 per face)
  122464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122465. * @param onLoad defines an optional callback raised when the texture is loaded
  122466. * @param onError defines an optional callback raised if there is an issue to load the texture
  122467. * @param format defines the format of the data
  122468. * @param forcedExtension defines the extension to use to pick the right loader
  122469. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122470. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122471. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122472. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122473. * @returns the cube texture as an InternalTexture
  122474. */
  122475. 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;
  122476. private _getSamplingFilter;
  122477. private static _GetNativeTextureFormat;
  122478. createRenderTargetTexture(size: number | {
  122479. width: number;
  122480. height: number;
  122481. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122485. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122486. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122487. /**
  122488. * Updates a dynamic vertex buffer.
  122489. * @param vertexBuffer the vertex buffer to update
  122490. * @param data the data used to update the vertex buffer
  122491. * @param byteOffset the byte offset of the data (optional)
  122492. * @param byteLength the byte length of the data (optional)
  122493. */
  122494. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122495. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122496. private _updateAnisotropicLevel;
  122497. private _getAddressMode;
  122498. /** @hidden */
  122499. _bindTexture(channel: number, texture: InternalTexture): void;
  122500. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122501. releaseEffects(): void;
  122502. /** @hidden */
  122503. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122504. /** @hidden */
  122505. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122506. /** @hidden */
  122507. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122508. /** @hidden */
  122509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122510. }
  122511. }
  122512. declare module BABYLON {
  122513. /**
  122514. * Gather the list of clipboard event types as constants.
  122515. */
  122516. export class ClipboardEventTypes {
  122517. /**
  122518. * The clipboard event is fired when a copy command is active (pressed).
  122519. */
  122520. static readonly COPY: number;
  122521. /**
  122522. * The clipboard event is fired when a cut command is active (pressed).
  122523. */
  122524. static readonly CUT: number;
  122525. /**
  122526. * The clipboard event is fired when a paste command is active (pressed).
  122527. */
  122528. static readonly PASTE: number;
  122529. }
  122530. /**
  122531. * This class is used to store clipboard related info for the onClipboardObservable event.
  122532. */
  122533. export class ClipboardInfo {
  122534. /**
  122535. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122536. */
  122537. type: number;
  122538. /**
  122539. * Defines the related dom event
  122540. */
  122541. event: ClipboardEvent;
  122542. /**
  122543. *Creates an instance of ClipboardInfo.
  122544. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122545. * @param event Defines the related dom event
  122546. */
  122547. constructor(
  122548. /**
  122549. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122550. */
  122551. type: number,
  122552. /**
  122553. * Defines the related dom event
  122554. */
  122555. event: ClipboardEvent);
  122556. /**
  122557. * Get the clipboard event's type from the keycode.
  122558. * @param keyCode Defines the keyCode for the current keyboard event.
  122559. * @return {number}
  122560. */
  122561. static GetTypeFromCharacter(keyCode: number): number;
  122562. }
  122563. }
  122564. declare module BABYLON {
  122565. /**
  122566. * Google Daydream controller
  122567. */
  122568. export class DaydreamController extends WebVRController {
  122569. /**
  122570. * Base Url for the controller model.
  122571. */
  122572. static MODEL_BASE_URL: string;
  122573. /**
  122574. * File name for the controller model.
  122575. */
  122576. static MODEL_FILENAME: string;
  122577. /**
  122578. * Gamepad Id prefix used to identify Daydream Controller.
  122579. */
  122580. static readonly GAMEPAD_ID_PREFIX: string;
  122581. /**
  122582. * Creates a new DaydreamController from a gamepad
  122583. * @param vrGamepad the gamepad that the controller should be created from
  122584. */
  122585. constructor(vrGamepad: any);
  122586. /**
  122587. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122588. * @param scene scene in which to add meshes
  122589. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122590. */
  122591. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122592. /**
  122593. * Called once for each button that changed state since the last frame
  122594. * @param buttonIdx Which button index changed
  122595. * @param state New state of the button
  122596. * @param changes Which properties on the state changed since last frame
  122597. */
  122598. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122599. }
  122600. }
  122601. declare module BABYLON {
  122602. /**
  122603. * Gear VR Controller
  122604. */
  122605. export class GearVRController extends WebVRController {
  122606. /**
  122607. * Base Url for the controller model.
  122608. */
  122609. static MODEL_BASE_URL: string;
  122610. /**
  122611. * File name for the controller model.
  122612. */
  122613. static MODEL_FILENAME: string;
  122614. /**
  122615. * Gamepad Id prefix used to identify this controller.
  122616. */
  122617. static readonly GAMEPAD_ID_PREFIX: string;
  122618. private readonly _buttonIndexToObservableNameMap;
  122619. /**
  122620. * Creates a new GearVRController from a gamepad
  122621. * @param vrGamepad the gamepad that the controller should be created from
  122622. */
  122623. constructor(vrGamepad: any);
  122624. /**
  122625. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122626. * @param scene scene in which to add meshes
  122627. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122628. */
  122629. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122630. /**
  122631. * Called once for each button that changed state since the last frame
  122632. * @param buttonIdx Which button index changed
  122633. * @param state New state of the button
  122634. * @param changes Which properties on the state changed since last frame
  122635. */
  122636. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122637. }
  122638. }
  122639. declare module BABYLON {
  122640. /**
  122641. * Generic Controller
  122642. */
  122643. export class GenericController extends WebVRController {
  122644. /**
  122645. * Base Url for the controller model.
  122646. */
  122647. static readonly MODEL_BASE_URL: string;
  122648. /**
  122649. * File name for the controller model.
  122650. */
  122651. static readonly MODEL_FILENAME: string;
  122652. /**
  122653. * Creates a new GenericController from a gamepad
  122654. * @param vrGamepad the gamepad that the controller should be created from
  122655. */
  122656. constructor(vrGamepad: any);
  122657. /**
  122658. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122659. * @param scene scene in which to add meshes
  122660. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122661. */
  122662. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122663. /**
  122664. * Called once for each button that changed state since the last frame
  122665. * @param buttonIdx Which button index changed
  122666. * @param state New state of the button
  122667. * @param changes Which properties on the state changed since last frame
  122668. */
  122669. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122670. }
  122671. }
  122672. declare module BABYLON {
  122673. /**
  122674. * Oculus Touch Controller
  122675. */
  122676. export class OculusTouchController extends WebVRController {
  122677. /**
  122678. * Base Url for the controller model.
  122679. */
  122680. static MODEL_BASE_URL: string;
  122681. /**
  122682. * File name for the left controller model.
  122683. */
  122684. static MODEL_LEFT_FILENAME: string;
  122685. /**
  122686. * File name for the right controller model.
  122687. */
  122688. static MODEL_RIGHT_FILENAME: string;
  122689. /**
  122690. * Base Url for the Quest controller model.
  122691. */
  122692. static QUEST_MODEL_BASE_URL: string;
  122693. /**
  122694. * @hidden
  122695. * If the controllers are running on a device that needs the updated Quest controller models
  122696. */
  122697. static _IsQuest: boolean;
  122698. /**
  122699. * Fired when the secondary trigger on this controller is modified
  122700. */
  122701. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122702. /**
  122703. * Fired when the thumb rest on this controller is modified
  122704. */
  122705. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122706. /**
  122707. * Creates a new OculusTouchController from a gamepad
  122708. * @param vrGamepad the gamepad that the controller should be created from
  122709. */
  122710. constructor(vrGamepad: any);
  122711. /**
  122712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122713. * @param scene scene in which to add meshes
  122714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122715. */
  122716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122717. /**
  122718. * Fired when the A button on this controller is modified
  122719. */
  122720. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122721. /**
  122722. * Fired when the B button on this controller is modified
  122723. */
  122724. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122725. /**
  122726. * Fired when the X button on this controller is modified
  122727. */
  122728. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122729. /**
  122730. * Fired when the Y button on this controller is modified
  122731. */
  122732. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122733. /**
  122734. * Called once for each button that changed state since the last frame
  122735. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122736. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122737. * 2) secondary trigger (same)
  122738. * 3) A (right) X (left), touch, pressed = value
  122739. * 4) B / Y
  122740. * 5) thumb rest
  122741. * @param buttonIdx Which button index changed
  122742. * @param state New state of the button
  122743. * @param changes Which properties on the state changed since last frame
  122744. */
  122745. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122746. }
  122747. }
  122748. declare module BABYLON {
  122749. /**
  122750. * Vive Controller
  122751. */
  122752. export class ViveController extends WebVRController {
  122753. /**
  122754. * Base Url for the controller model.
  122755. */
  122756. static MODEL_BASE_URL: string;
  122757. /**
  122758. * File name for the controller model.
  122759. */
  122760. static MODEL_FILENAME: string;
  122761. /**
  122762. * Creates a new ViveController from a gamepad
  122763. * @param vrGamepad the gamepad that the controller should be created from
  122764. */
  122765. constructor(vrGamepad: any);
  122766. /**
  122767. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122768. * @param scene scene in which to add meshes
  122769. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122770. */
  122771. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122772. /**
  122773. * Fired when the left button on this controller is modified
  122774. */
  122775. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122776. /**
  122777. * Fired when the right button on this controller is modified
  122778. */
  122779. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122780. /**
  122781. * Fired when the menu button on this controller is modified
  122782. */
  122783. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122784. /**
  122785. * Called once for each button that changed state since the last frame
  122786. * Vive mapping:
  122787. * 0: touchpad
  122788. * 1: trigger
  122789. * 2: left AND right buttons
  122790. * 3: menu button
  122791. * @param buttonIdx Which button index changed
  122792. * @param state New state of the button
  122793. * @param changes Which properties on the state changed since last frame
  122794. */
  122795. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122796. }
  122797. }
  122798. declare module BABYLON {
  122799. /**
  122800. * Defines the WindowsMotionController object that the state of the windows motion controller
  122801. */
  122802. export class WindowsMotionController extends WebVRController {
  122803. /**
  122804. * The base url used to load the left and right controller models
  122805. */
  122806. static MODEL_BASE_URL: string;
  122807. /**
  122808. * The name of the left controller model file
  122809. */
  122810. static MODEL_LEFT_FILENAME: string;
  122811. /**
  122812. * The name of the right controller model file
  122813. */
  122814. static MODEL_RIGHT_FILENAME: string;
  122815. /**
  122816. * The controller name prefix for this controller type
  122817. */
  122818. static readonly GAMEPAD_ID_PREFIX: string;
  122819. /**
  122820. * The controller id pattern for this controller type
  122821. */
  122822. private static readonly GAMEPAD_ID_PATTERN;
  122823. private _loadedMeshInfo;
  122824. protected readonly _mapping: {
  122825. buttons: string[];
  122826. buttonMeshNames: {
  122827. trigger: string;
  122828. menu: string;
  122829. grip: string;
  122830. thumbstick: string;
  122831. trackpad: string;
  122832. };
  122833. buttonObservableNames: {
  122834. trigger: string;
  122835. menu: string;
  122836. grip: string;
  122837. thumbstick: string;
  122838. trackpad: string;
  122839. };
  122840. axisMeshNames: string[];
  122841. pointingPoseMeshName: string;
  122842. };
  122843. /**
  122844. * Fired when the trackpad on this controller is clicked
  122845. */
  122846. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122847. /**
  122848. * Fired when the trackpad on this controller is modified
  122849. */
  122850. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122851. /**
  122852. * The current x and y values of this controller's trackpad
  122853. */
  122854. trackpad: StickValues;
  122855. /**
  122856. * Creates a new WindowsMotionController from a gamepad
  122857. * @param vrGamepad the gamepad that the controller should be created from
  122858. */
  122859. constructor(vrGamepad: any);
  122860. /**
  122861. * Fired when the trigger on this controller is modified
  122862. */
  122863. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122864. /**
  122865. * Fired when the menu button on this controller is modified
  122866. */
  122867. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122868. /**
  122869. * Fired when the grip button on this controller is modified
  122870. */
  122871. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122872. /**
  122873. * Fired when the thumbstick button on this controller is modified
  122874. */
  122875. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122876. /**
  122877. * Fired when the touchpad button on this controller is modified
  122878. */
  122879. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122880. /**
  122881. * Fired when the touchpad values on this controller are modified
  122882. */
  122883. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122884. protected _updateTrackpad(): void;
  122885. /**
  122886. * Called once per frame by the engine.
  122887. */
  122888. update(): void;
  122889. /**
  122890. * Called once for each button that changed state since the last frame
  122891. * @param buttonIdx Which button index changed
  122892. * @param state New state of the button
  122893. * @param changes Which properties on the state changed since last frame
  122894. */
  122895. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122896. /**
  122897. * Moves the buttons on the controller mesh based on their current state
  122898. * @param buttonName the name of the button to move
  122899. * @param buttonValue the value of the button which determines the buttons new position
  122900. */
  122901. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122902. /**
  122903. * Moves the axis on the controller mesh based on its current state
  122904. * @param axis the index of the axis
  122905. * @param axisValue the value of the axis which determines the meshes new position
  122906. * @hidden
  122907. */
  122908. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122909. /**
  122910. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122911. * @param scene scene in which to add meshes
  122912. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122913. */
  122914. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122915. /**
  122916. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122917. * can be transformed by button presses and axes values, based on this._mapping.
  122918. *
  122919. * @param scene scene in which the meshes exist
  122920. * @param meshes list of meshes that make up the controller model to process
  122921. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122922. */
  122923. private processModel;
  122924. private createMeshInfo;
  122925. /**
  122926. * Gets the ray of the controller in the direction the controller is pointing
  122927. * @param length the length the resulting ray should be
  122928. * @returns a ray in the direction the controller is pointing
  122929. */
  122930. getForwardRay(length?: number): Ray;
  122931. /**
  122932. * Disposes of the controller
  122933. */
  122934. dispose(): void;
  122935. }
  122936. /**
  122937. * This class represents a new windows motion controller in XR.
  122938. */
  122939. export class XRWindowsMotionController extends WindowsMotionController {
  122940. /**
  122941. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122942. */
  122943. protected readonly _mapping: {
  122944. buttons: string[];
  122945. buttonMeshNames: {
  122946. trigger: string;
  122947. menu: string;
  122948. grip: string;
  122949. thumbstick: string;
  122950. trackpad: string;
  122951. };
  122952. buttonObservableNames: {
  122953. trigger: string;
  122954. menu: string;
  122955. grip: string;
  122956. thumbstick: string;
  122957. trackpad: string;
  122958. };
  122959. axisMeshNames: string[];
  122960. pointingPoseMeshName: string;
  122961. };
  122962. /**
  122963. * Construct a new XR-Based windows motion controller
  122964. *
  122965. * @param gamepadInfo the gamepad object from the browser
  122966. */
  122967. constructor(gamepadInfo: any);
  122968. /**
  122969. * holds the thumbstick values (X,Y)
  122970. */
  122971. thumbstickValues: StickValues;
  122972. /**
  122973. * Fired when the thumbstick on this controller is clicked
  122974. */
  122975. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122976. /**
  122977. * Fired when the thumbstick on this controller is modified
  122978. */
  122979. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122980. /**
  122981. * Fired when the touchpad button on this controller is modified
  122982. */
  122983. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122984. /**
  122985. * Fired when the touchpad values on this controller are modified
  122986. */
  122987. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122988. /**
  122989. * Fired when the thumbstick button on this controller is modified
  122990. * here to prevent breaking changes
  122991. */
  122992. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122993. /**
  122994. * updating the thumbstick(!) and not the trackpad.
  122995. * This is named this way due to the difference between WebVR and XR and to avoid
  122996. * changing the parent class.
  122997. */
  122998. protected _updateTrackpad(): void;
  122999. /**
  123000. * Disposes the class with joy
  123001. */
  123002. dispose(): void;
  123003. }
  123004. }
  123005. declare module BABYLON {
  123006. /**
  123007. * Class containing static functions to help procedurally build meshes
  123008. */
  123009. export class PolyhedronBuilder {
  123010. /**
  123011. * Creates a polyhedron mesh
  123012. * * 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
  123013. * * The parameter `size` (positive float, default 1) sets the polygon size
  123014. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123015. * * 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`
  123016. * * 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
  123017. * * 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)`)
  123018. * * 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
  123019. * * 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
  123020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123023. * @param name defines the name of the mesh
  123024. * @param options defines the options used to create the mesh
  123025. * @param scene defines the hosting scene
  123026. * @returns the polyhedron mesh
  123027. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123028. */
  123029. static CreatePolyhedron(name: string, options: {
  123030. type?: number;
  123031. size?: number;
  123032. sizeX?: number;
  123033. sizeY?: number;
  123034. sizeZ?: number;
  123035. custom?: any;
  123036. faceUV?: Vector4[];
  123037. faceColors?: Color4[];
  123038. flat?: boolean;
  123039. updatable?: boolean;
  123040. sideOrientation?: number;
  123041. frontUVs?: Vector4;
  123042. backUVs?: Vector4;
  123043. }, scene?: Nullable<Scene>): Mesh;
  123044. }
  123045. }
  123046. declare module BABYLON {
  123047. /**
  123048. * Gizmo that enables scaling a mesh along 3 axis
  123049. */
  123050. export class ScaleGizmo extends Gizmo {
  123051. /**
  123052. * Internal gizmo used for interactions on the x axis
  123053. */
  123054. xGizmo: AxisScaleGizmo;
  123055. /**
  123056. * Internal gizmo used for interactions on the y axis
  123057. */
  123058. yGizmo: AxisScaleGizmo;
  123059. /**
  123060. * Internal gizmo used for interactions on the z axis
  123061. */
  123062. zGizmo: AxisScaleGizmo;
  123063. /**
  123064. * Internal gizmo used to scale all axis equally
  123065. */
  123066. uniformScaleGizmo: AxisScaleGizmo;
  123067. private _meshAttached;
  123068. private _updateGizmoRotationToMatchAttachedMesh;
  123069. private _snapDistance;
  123070. private _scaleRatio;
  123071. private _uniformScalingMesh;
  123072. private _octahedron;
  123073. private _sensitivity;
  123074. /** Fires an event when any of it's sub gizmos are dragged */
  123075. onDragStartObservable: Observable<unknown>;
  123076. /** Fires an event when any of it's sub gizmos are released from dragging */
  123077. onDragEndObservable: Observable<unknown>;
  123078. get attachedMesh(): Nullable<AbstractMesh>;
  123079. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123080. /**
  123081. * Creates a ScaleGizmo
  123082. * @param gizmoLayer The utility layer the gizmo will be added to
  123083. */
  123084. constructor(gizmoLayer?: UtilityLayerRenderer);
  123085. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123086. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123087. /**
  123088. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123089. */
  123090. set snapDistance(value: number);
  123091. get snapDistance(): number;
  123092. /**
  123093. * Ratio for the scale of the gizmo (Default: 1)
  123094. */
  123095. set scaleRatio(value: number);
  123096. get scaleRatio(): number;
  123097. /**
  123098. * Sensitivity factor for dragging (Default: 1)
  123099. */
  123100. set sensitivity(value: number);
  123101. get sensitivity(): number;
  123102. /**
  123103. * Disposes of the gizmo
  123104. */
  123105. dispose(): void;
  123106. }
  123107. }
  123108. declare module BABYLON {
  123109. /**
  123110. * Single axis scale gizmo
  123111. */
  123112. export class AxisScaleGizmo extends Gizmo {
  123113. /**
  123114. * Drag behavior responsible for the gizmos dragging interactions
  123115. */
  123116. dragBehavior: PointerDragBehavior;
  123117. private _pointerObserver;
  123118. /**
  123119. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123120. */
  123121. snapDistance: number;
  123122. /**
  123123. * Event that fires each time the gizmo snaps to a new location.
  123124. * * snapDistance is the the change in distance
  123125. */
  123126. onSnapObservable: Observable<{
  123127. snapDistance: number;
  123128. }>;
  123129. /**
  123130. * If the scaling operation should be done on all axis (default: false)
  123131. */
  123132. uniformScaling: boolean;
  123133. /**
  123134. * Custom sensitivity value for the drag strength
  123135. */
  123136. sensitivity: number;
  123137. private _isEnabled;
  123138. private _parent;
  123139. private _arrow;
  123140. private _coloredMaterial;
  123141. private _hoverMaterial;
  123142. /**
  123143. * Creates an AxisScaleGizmo
  123144. * @param gizmoLayer The utility layer the gizmo will be added to
  123145. * @param dragAxis The axis which the gizmo will be able to scale on
  123146. * @param color The color of the gizmo
  123147. */
  123148. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123149. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123150. /**
  123151. * If the gizmo is enabled
  123152. */
  123153. set isEnabled(value: boolean);
  123154. get isEnabled(): boolean;
  123155. /**
  123156. * Disposes of the gizmo
  123157. */
  123158. dispose(): void;
  123159. /**
  123160. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123161. * @param mesh The mesh to replace the default mesh of the gizmo
  123162. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123163. */
  123164. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123165. }
  123166. }
  123167. declare module BABYLON {
  123168. /**
  123169. * Bounding box gizmo
  123170. */
  123171. export class BoundingBoxGizmo extends Gizmo {
  123172. private _lineBoundingBox;
  123173. private _rotateSpheresParent;
  123174. private _scaleBoxesParent;
  123175. private _boundingDimensions;
  123176. private _renderObserver;
  123177. private _pointerObserver;
  123178. private _scaleDragSpeed;
  123179. private _tmpQuaternion;
  123180. private _tmpVector;
  123181. private _tmpRotationMatrix;
  123182. /**
  123183. * 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)
  123184. */
  123185. ignoreChildren: boolean;
  123186. /**
  123187. * 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)
  123188. */
  123189. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123190. /**
  123191. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123192. */
  123193. rotationSphereSize: number;
  123194. /**
  123195. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123196. */
  123197. scaleBoxSize: number;
  123198. /**
  123199. * 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)
  123200. */
  123201. fixedDragMeshScreenSize: boolean;
  123202. /**
  123203. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123204. */
  123205. fixedDragMeshScreenSizeDistanceFactor: number;
  123206. /**
  123207. * Fired when a rotation sphere or scale box is dragged
  123208. */
  123209. onDragStartObservable: Observable<{}>;
  123210. /**
  123211. * Fired when a scale box is dragged
  123212. */
  123213. onScaleBoxDragObservable: Observable<{}>;
  123214. /**
  123215. * Fired when a scale box drag is ended
  123216. */
  123217. onScaleBoxDragEndObservable: Observable<{}>;
  123218. /**
  123219. * Fired when a rotation sphere is dragged
  123220. */
  123221. onRotationSphereDragObservable: Observable<{}>;
  123222. /**
  123223. * Fired when a rotation sphere drag is ended
  123224. */
  123225. onRotationSphereDragEndObservable: Observable<{}>;
  123226. /**
  123227. * 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)
  123228. */
  123229. scalePivot: Nullable<Vector3>;
  123230. /**
  123231. * Mesh used as a pivot to rotate the attached mesh
  123232. */
  123233. private _anchorMesh;
  123234. private _existingMeshScale;
  123235. private _dragMesh;
  123236. private pointerDragBehavior;
  123237. private coloredMaterial;
  123238. private hoverColoredMaterial;
  123239. /**
  123240. * Sets the color of the bounding box gizmo
  123241. * @param color the color to set
  123242. */
  123243. setColor(color: Color3): void;
  123244. /**
  123245. * Creates an BoundingBoxGizmo
  123246. * @param gizmoLayer The utility layer the gizmo will be added to
  123247. * @param color The color of the gizmo
  123248. */
  123249. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123250. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123251. private _selectNode;
  123252. /**
  123253. * Updates the bounding box information for the Gizmo
  123254. */
  123255. updateBoundingBox(): void;
  123256. private _updateRotationSpheres;
  123257. private _updateScaleBoxes;
  123258. /**
  123259. * Enables rotation on the specified axis and disables rotation on the others
  123260. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123261. */
  123262. setEnabledRotationAxis(axis: string): void;
  123263. /**
  123264. * Enables/disables scaling
  123265. * @param enable if scaling should be enabled
  123266. * @param homogeneousScaling defines if scaling should only be homogeneous
  123267. */
  123268. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123269. private _updateDummy;
  123270. /**
  123271. * Enables a pointer drag behavior on the bounding box of the gizmo
  123272. */
  123273. enableDragBehavior(): void;
  123274. /**
  123275. * Disposes of the gizmo
  123276. */
  123277. dispose(): void;
  123278. /**
  123279. * 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)
  123280. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123281. * @returns the bounding box mesh with the passed in mesh as a child
  123282. */
  123283. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123284. /**
  123285. * CustomMeshes are not supported by this gizmo
  123286. * @param mesh The mesh to replace the default mesh of the gizmo
  123287. */
  123288. setCustomMesh(mesh: Mesh): void;
  123289. }
  123290. }
  123291. declare module BABYLON {
  123292. /**
  123293. * Single plane rotation gizmo
  123294. */
  123295. export class PlaneRotationGizmo extends Gizmo {
  123296. /**
  123297. * Drag behavior responsible for the gizmos dragging interactions
  123298. */
  123299. dragBehavior: PointerDragBehavior;
  123300. private _pointerObserver;
  123301. /**
  123302. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123303. */
  123304. snapDistance: number;
  123305. /**
  123306. * Event that fires each time the gizmo snaps to a new location.
  123307. * * snapDistance is the the change in distance
  123308. */
  123309. onSnapObservable: Observable<{
  123310. snapDistance: number;
  123311. }>;
  123312. private _isEnabled;
  123313. private _parent;
  123314. /**
  123315. * Creates a PlaneRotationGizmo
  123316. * @param gizmoLayer The utility layer the gizmo will be added to
  123317. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123318. * @param color The color of the gizmo
  123319. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123320. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123321. */
  123322. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123323. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123324. /**
  123325. * If the gizmo is enabled
  123326. */
  123327. set isEnabled(value: boolean);
  123328. get isEnabled(): boolean;
  123329. /**
  123330. * Disposes of the gizmo
  123331. */
  123332. dispose(): void;
  123333. }
  123334. }
  123335. declare module BABYLON {
  123336. /**
  123337. * Gizmo that enables rotating a mesh along 3 axis
  123338. */
  123339. export class RotationGizmo extends Gizmo {
  123340. /**
  123341. * Internal gizmo used for interactions on the x axis
  123342. */
  123343. xGizmo: PlaneRotationGizmo;
  123344. /**
  123345. * Internal gizmo used for interactions on the y axis
  123346. */
  123347. yGizmo: PlaneRotationGizmo;
  123348. /**
  123349. * Internal gizmo used for interactions on the z axis
  123350. */
  123351. zGizmo: PlaneRotationGizmo;
  123352. /** Fires an event when any of it's sub gizmos are dragged */
  123353. onDragStartObservable: Observable<unknown>;
  123354. /** Fires an event when any of it's sub gizmos are released from dragging */
  123355. onDragEndObservable: Observable<unknown>;
  123356. private _meshAttached;
  123357. get attachedMesh(): Nullable<AbstractMesh>;
  123358. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123359. /**
  123360. * Creates a RotationGizmo
  123361. * @param gizmoLayer The utility layer the gizmo will be added to
  123362. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123363. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123364. */
  123365. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123366. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123367. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123368. /**
  123369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123370. */
  123371. set snapDistance(value: number);
  123372. get snapDistance(): number;
  123373. /**
  123374. * Ratio for the scale of the gizmo (Default: 1)
  123375. */
  123376. set scaleRatio(value: number);
  123377. get scaleRatio(): number;
  123378. /**
  123379. * Disposes of the gizmo
  123380. */
  123381. dispose(): void;
  123382. /**
  123383. * CustomMeshes are not supported by this gizmo
  123384. * @param mesh The mesh to replace the default mesh of the gizmo
  123385. */
  123386. setCustomMesh(mesh: Mesh): void;
  123387. }
  123388. }
  123389. declare module BABYLON {
  123390. /**
  123391. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123392. */
  123393. export class GizmoManager implements IDisposable {
  123394. private scene;
  123395. /**
  123396. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123397. */
  123398. gizmos: {
  123399. positionGizmo: Nullable<PositionGizmo>;
  123400. rotationGizmo: Nullable<RotationGizmo>;
  123401. scaleGizmo: Nullable<ScaleGizmo>;
  123402. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123403. };
  123404. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123405. clearGizmoOnEmptyPointerEvent: boolean;
  123406. /** Fires an event when the manager is attached to a mesh */
  123407. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123408. private _gizmosEnabled;
  123409. private _pointerObserver;
  123410. private _attachedMesh;
  123411. private _boundingBoxColor;
  123412. private _defaultUtilityLayer;
  123413. private _defaultKeepDepthUtilityLayer;
  123414. /**
  123415. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123416. */
  123417. boundingBoxDragBehavior: SixDofDragBehavior;
  123418. /**
  123419. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123420. */
  123421. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123422. /**
  123423. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123424. */
  123425. usePointerToAttachGizmos: boolean;
  123426. /**
  123427. * Utility layer that the bounding box gizmo belongs to
  123428. */
  123429. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123430. /**
  123431. * Utility layer that all gizmos besides bounding box belong to
  123432. */
  123433. get utilityLayer(): UtilityLayerRenderer;
  123434. /**
  123435. * Instatiates a gizmo manager
  123436. * @param scene the scene to overlay the gizmos on top of
  123437. */
  123438. constructor(scene: Scene);
  123439. /**
  123440. * Attaches a set of gizmos to the specified mesh
  123441. * @param mesh The mesh the gizmo's should be attached to
  123442. */
  123443. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123444. /**
  123445. * If the position gizmo is enabled
  123446. */
  123447. set positionGizmoEnabled(value: boolean);
  123448. get positionGizmoEnabled(): boolean;
  123449. /**
  123450. * If the rotation gizmo is enabled
  123451. */
  123452. set rotationGizmoEnabled(value: boolean);
  123453. get rotationGizmoEnabled(): boolean;
  123454. /**
  123455. * If the scale gizmo is enabled
  123456. */
  123457. set scaleGizmoEnabled(value: boolean);
  123458. get scaleGizmoEnabled(): boolean;
  123459. /**
  123460. * If the boundingBox gizmo is enabled
  123461. */
  123462. set boundingBoxGizmoEnabled(value: boolean);
  123463. get boundingBoxGizmoEnabled(): boolean;
  123464. /**
  123465. * Disposes of the gizmo manager
  123466. */
  123467. dispose(): void;
  123468. }
  123469. }
  123470. declare module BABYLON {
  123471. /**
  123472. * A directional light is defined by a direction (what a surprise!).
  123473. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123474. * 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.
  123475. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123476. */
  123477. export class DirectionalLight extends ShadowLight {
  123478. private _shadowFrustumSize;
  123479. /**
  123480. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123481. */
  123482. get shadowFrustumSize(): number;
  123483. /**
  123484. * Specifies a fix frustum size for the shadow generation.
  123485. */
  123486. set shadowFrustumSize(value: number);
  123487. private _shadowOrthoScale;
  123488. /**
  123489. * Gets the shadow projection scale against the optimal computed one.
  123490. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123491. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123492. */
  123493. get shadowOrthoScale(): number;
  123494. /**
  123495. * Sets the shadow projection scale against the optimal computed one.
  123496. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123497. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123498. */
  123499. set shadowOrthoScale(value: number);
  123500. /**
  123501. * Automatically compute the projection matrix to best fit (including all the casters)
  123502. * on each frame.
  123503. */
  123504. autoUpdateExtends: boolean;
  123505. /**
  123506. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123507. * on each frame. autoUpdateExtends must be set to true for this to work
  123508. */
  123509. autoCalcShadowZBounds: boolean;
  123510. private _orthoLeft;
  123511. private _orthoRight;
  123512. private _orthoTop;
  123513. private _orthoBottom;
  123514. /**
  123515. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123516. * The directional light is emitted from everywhere in the given direction.
  123517. * It can cast shadows.
  123518. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123519. * @param name The friendly name of the light
  123520. * @param direction The direction of the light
  123521. * @param scene The scene the light belongs to
  123522. */
  123523. constructor(name: string, direction: Vector3, scene: Scene);
  123524. /**
  123525. * Returns the string "DirectionalLight".
  123526. * @return The class name
  123527. */
  123528. getClassName(): string;
  123529. /**
  123530. * Returns the integer 1.
  123531. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123532. */
  123533. getTypeID(): number;
  123534. /**
  123535. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123536. * Returns the DirectionalLight Shadow projection matrix.
  123537. */
  123538. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123539. /**
  123540. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123541. * Returns the DirectionalLight Shadow projection matrix.
  123542. */
  123543. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123544. /**
  123545. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123546. * Returns the DirectionalLight Shadow projection matrix.
  123547. */
  123548. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123549. protected _buildUniformLayout(): void;
  123550. /**
  123551. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123552. * @param effect The effect to update
  123553. * @param lightIndex The index of the light in the effect to update
  123554. * @returns The directional light
  123555. */
  123556. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123557. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123558. /**
  123559. * Gets the minZ used for shadow according to both the scene and the light.
  123560. *
  123561. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123562. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123563. * @param activeCamera The camera we are returning the min for
  123564. * @returns the depth min z
  123565. */
  123566. getDepthMinZ(activeCamera: Camera): number;
  123567. /**
  123568. * Gets the maxZ used for shadow according to both the scene and the light.
  123569. *
  123570. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123571. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123572. * @param activeCamera The camera we are returning the max for
  123573. * @returns the depth max z
  123574. */
  123575. getDepthMaxZ(activeCamera: Camera): number;
  123576. /**
  123577. * Prepares the list of defines specific to the light type.
  123578. * @param defines the list of defines
  123579. * @param lightIndex defines the index of the light for the effect
  123580. */
  123581. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123582. }
  123583. }
  123584. declare module BABYLON {
  123585. /**
  123586. * Class containing static functions to help procedurally build meshes
  123587. */
  123588. export class HemisphereBuilder {
  123589. /**
  123590. * Creates a hemisphere mesh
  123591. * @param name defines the name of the mesh
  123592. * @param options defines the options used to create the mesh
  123593. * @param scene defines the hosting scene
  123594. * @returns the hemisphere mesh
  123595. */
  123596. static CreateHemisphere(name: string, options: {
  123597. segments?: number;
  123598. diameter?: number;
  123599. sideOrientation?: number;
  123600. }, scene: any): Mesh;
  123601. }
  123602. }
  123603. declare module BABYLON {
  123604. /**
  123605. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123606. * These values define a cone of light starting from the position, emitting toward the direction.
  123607. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123608. * and the exponent defines the speed of the decay of the light with distance (reach).
  123609. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123610. */
  123611. export class SpotLight extends ShadowLight {
  123612. private _angle;
  123613. private _innerAngle;
  123614. private _cosHalfAngle;
  123615. private _lightAngleScale;
  123616. private _lightAngleOffset;
  123617. /**
  123618. * Gets the cone angle of the spot light in Radians.
  123619. */
  123620. get angle(): number;
  123621. /**
  123622. * Sets the cone angle of the spot light in Radians.
  123623. */
  123624. set angle(value: number);
  123625. /**
  123626. * Only used in gltf falloff mode, this defines the angle where
  123627. * the directional falloff will start before cutting at angle which could be seen
  123628. * as outer angle.
  123629. */
  123630. get innerAngle(): number;
  123631. /**
  123632. * Only used in gltf falloff mode, this defines the angle where
  123633. * the directional falloff will start before cutting at angle which could be seen
  123634. * as outer angle.
  123635. */
  123636. set innerAngle(value: number);
  123637. private _shadowAngleScale;
  123638. /**
  123639. * Allows scaling the angle of the light for shadow generation only.
  123640. */
  123641. get shadowAngleScale(): number;
  123642. /**
  123643. * Allows scaling the angle of the light for shadow generation only.
  123644. */
  123645. set shadowAngleScale(value: number);
  123646. /**
  123647. * The light decay speed with the distance from the emission spot.
  123648. */
  123649. exponent: number;
  123650. private _projectionTextureMatrix;
  123651. /**
  123652. * Allows reading the projecton texture
  123653. */
  123654. get projectionTextureMatrix(): Matrix;
  123655. protected _projectionTextureLightNear: number;
  123656. /**
  123657. * Gets the near clip of the Spotlight for texture projection.
  123658. */
  123659. get projectionTextureLightNear(): number;
  123660. /**
  123661. * Sets the near clip of the Spotlight for texture projection.
  123662. */
  123663. set projectionTextureLightNear(value: number);
  123664. protected _projectionTextureLightFar: number;
  123665. /**
  123666. * Gets the far clip of the Spotlight for texture projection.
  123667. */
  123668. get projectionTextureLightFar(): number;
  123669. /**
  123670. * Sets the far clip of the Spotlight for texture projection.
  123671. */
  123672. set projectionTextureLightFar(value: number);
  123673. protected _projectionTextureUpDirection: Vector3;
  123674. /**
  123675. * Gets the Up vector of the Spotlight for texture projection.
  123676. */
  123677. get projectionTextureUpDirection(): Vector3;
  123678. /**
  123679. * Sets the Up vector of the Spotlight for texture projection.
  123680. */
  123681. set projectionTextureUpDirection(value: Vector3);
  123682. private _projectionTexture;
  123683. /**
  123684. * Gets the projection texture of the light.
  123685. */
  123686. get projectionTexture(): Nullable<BaseTexture>;
  123687. /**
  123688. * Sets the projection texture of the light.
  123689. */
  123690. set projectionTexture(value: Nullable<BaseTexture>);
  123691. private _projectionTextureViewLightDirty;
  123692. private _projectionTextureProjectionLightDirty;
  123693. private _projectionTextureDirty;
  123694. private _projectionTextureViewTargetVector;
  123695. private _projectionTextureViewLightMatrix;
  123696. private _projectionTextureProjectionLightMatrix;
  123697. private _projectionTextureScalingMatrix;
  123698. /**
  123699. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123700. * It can cast shadows.
  123701. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123702. * @param name The light friendly name
  123703. * @param position The position of the spot light in the scene
  123704. * @param direction The direction of the light in the scene
  123705. * @param angle The cone angle of the light in Radians
  123706. * @param exponent The light decay speed with the distance from the emission spot
  123707. * @param scene The scene the lights belongs to
  123708. */
  123709. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123710. /**
  123711. * Returns the string "SpotLight".
  123712. * @returns the class name
  123713. */
  123714. getClassName(): string;
  123715. /**
  123716. * Returns the integer 2.
  123717. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123718. */
  123719. getTypeID(): number;
  123720. /**
  123721. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123722. */
  123723. protected _setDirection(value: Vector3): void;
  123724. /**
  123725. * Overrides the position setter to recompute the projection texture view light Matrix.
  123726. */
  123727. protected _setPosition(value: Vector3): void;
  123728. /**
  123729. * 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.
  123730. * Returns the SpotLight.
  123731. */
  123732. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123733. protected _computeProjectionTextureViewLightMatrix(): void;
  123734. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123735. /**
  123736. * Main function for light texture projection matrix computing.
  123737. */
  123738. protected _computeProjectionTextureMatrix(): void;
  123739. protected _buildUniformLayout(): void;
  123740. private _computeAngleValues;
  123741. /**
  123742. * Sets the passed Effect "effect" with the Light textures.
  123743. * @param effect The effect to update
  123744. * @param lightIndex The index of the light in the effect to update
  123745. * @returns The light
  123746. */
  123747. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123748. /**
  123749. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123750. * @param effect The effect to update
  123751. * @param lightIndex The index of the light in the effect to update
  123752. * @returns The spot light
  123753. */
  123754. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123755. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123756. /**
  123757. * Disposes the light and the associated resources.
  123758. */
  123759. dispose(): void;
  123760. /**
  123761. * Prepares the list of defines specific to the light type.
  123762. * @param defines the list of defines
  123763. * @param lightIndex defines the index of the light for the effect
  123764. */
  123765. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123766. }
  123767. }
  123768. declare module BABYLON {
  123769. /**
  123770. * Gizmo that enables viewing a light
  123771. */
  123772. export class LightGizmo extends Gizmo {
  123773. private _lightMesh;
  123774. private _material;
  123775. private _cachedPosition;
  123776. private _cachedForward;
  123777. private _attachedMeshParent;
  123778. /**
  123779. * Creates a LightGizmo
  123780. * @param gizmoLayer The utility layer the gizmo will be added to
  123781. */
  123782. constructor(gizmoLayer?: UtilityLayerRenderer);
  123783. private _light;
  123784. /**
  123785. * The light that the gizmo is attached to
  123786. */
  123787. set light(light: Nullable<Light>);
  123788. get light(): Nullable<Light>;
  123789. /**
  123790. * Gets the material used to render the light gizmo
  123791. */
  123792. get material(): StandardMaterial;
  123793. /**
  123794. * @hidden
  123795. * Updates the gizmo to match the attached mesh's position/rotation
  123796. */
  123797. protected _update(): void;
  123798. private static _Scale;
  123799. /**
  123800. * Creates the lines for a light mesh
  123801. */
  123802. private static _CreateLightLines;
  123803. /**
  123804. * Disposes of the light gizmo
  123805. */
  123806. dispose(): void;
  123807. private static _CreateHemisphericLightMesh;
  123808. private static _CreatePointLightMesh;
  123809. private static _CreateSpotLightMesh;
  123810. private static _CreateDirectionalLightMesh;
  123811. }
  123812. }
  123813. declare module BABYLON {
  123814. /** @hidden */
  123815. export var backgroundFragmentDeclaration: {
  123816. name: string;
  123817. shader: string;
  123818. };
  123819. }
  123820. declare module BABYLON {
  123821. /** @hidden */
  123822. export var backgroundUboDeclaration: {
  123823. name: string;
  123824. shader: string;
  123825. };
  123826. }
  123827. declare module BABYLON {
  123828. /** @hidden */
  123829. export var backgroundPixelShader: {
  123830. name: string;
  123831. shader: string;
  123832. };
  123833. }
  123834. declare module BABYLON {
  123835. /** @hidden */
  123836. export var backgroundVertexDeclaration: {
  123837. name: string;
  123838. shader: string;
  123839. };
  123840. }
  123841. declare module BABYLON {
  123842. /** @hidden */
  123843. export var backgroundVertexShader: {
  123844. name: string;
  123845. shader: string;
  123846. };
  123847. }
  123848. declare module BABYLON {
  123849. /**
  123850. * Background material used to create an efficient environement around your scene.
  123851. */
  123852. export class BackgroundMaterial extends PushMaterial {
  123853. /**
  123854. * Standard reflectance value at parallel view angle.
  123855. */
  123856. static StandardReflectance0: number;
  123857. /**
  123858. * Standard reflectance value at grazing angle.
  123859. */
  123860. static StandardReflectance90: number;
  123861. protected _primaryColor: Color3;
  123862. /**
  123863. * Key light Color (multiply against the environement texture)
  123864. */
  123865. primaryColor: Color3;
  123866. protected __perceptualColor: Nullable<Color3>;
  123867. /**
  123868. * Experimental Internal Use Only.
  123869. *
  123870. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123871. * This acts as a helper to set the primary color to a more "human friendly" value.
  123872. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123873. * output color as close as possible from the chosen value.
  123874. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123875. * part of lighting setup.)
  123876. */
  123877. get _perceptualColor(): Nullable<Color3>;
  123878. set _perceptualColor(value: Nullable<Color3>);
  123879. protected _primaryColorShadowLevel: float;
  123880. /**
  123881. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123882. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123883. */
  123884. get primaryColorShadowLevel(): float;
  123885. set primaryColorShadowLevel(value: float);
  123886. protected _primaryColorHighlightLevel: float;
  123887. /**
  123888. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123889. * The primary color is used at the level chosen to define what the white area would look.
  123890. */
  123891. get primaryColorHighlightLevel(): float;
  123892. set primaryColorHighlightLevel(value: float);
  123893. protected _reflectionTexture: Nullable<BaseTexture>;
  123894. /**
  123895. * Reflection Texture used in the material.
  123896. * Should be author in a specific way for the best result (refer to the documentation).
  123897. */
  123898. reflectionTexture: Nullable<BaseTexture>;
  123899. protected _reflectionBlur: float;
  123900. /**
  123901. * Reflection Texture level of blur.
  123902. *
  123903. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123904. * texture twice.
  123905. */
  123906. reflectionBlur: float;
  123907. protected _diffuseTexture: Nullable<BaseTexture>;
  123908. /**
  123909. * Diffuse Texture used in the material.
  123910. * Should be author in a specific way for the best result (refer to the documentation).
  123911. */
  123912. diffuseTexture: Nullable<BaseTexture>;
  123913. protected _shadowLights: Nullable<IShadowLight[]>;
  123914. /**
  123915. * Specify the list of lights casting shadow on the material.
  123916. * All scene shadow lights will be included if null.
  123917. */
  123918. shadowLights: Nullable<IShadowLight[]>;
  123919. protected _shadowLevel: float;
  123920. /**
  123921. * Helps adjusting the shadow to a softer level if required.
  123922. * 0 means black shadows and 1 means no shadows.
  123923. */
  123924. shadowLevel: float;
  123925. protected _sceneCenter: Vector3;
  123926. /**
  123927. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123928. * It is usually zero but might be interesting to modify according to your setup.
  123929. */
  123930. sceneCenter: Vector3;
  123931. protected _opacityFresnel: boolean;
  123932. /**
  123933. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123934. * This helps ensuring a nice transition when the camera goes under the ground.
  123935. */
  123936. opacityFresnel: boolean;
  123937. protected _reflectionFresnel: boolean;
  123938. /**
  123939. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123940. * This helps adding a mirror texture on the ground.
  123941. */
  123942. reflectionFresnel: boolean;
  123943. protected _reflectionFalloffDistance: number;
  123944. /**
  123945. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123946. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123947. */
  123948. reflectionFalloffDistance: number;
  123949. protected _reflectionAmount: number;
  123950. /**
  123951. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123952. */
  123953. reflectionAmount: number;
  123954. protected _reflectionReflectance0: number;
  123955. /**
  123956. * This specifies the weight of the reflection at grazing angle.
  123957. */
  123958. reflectionReflectance0: number;
  123959. protected _reflectionReflectance90: number;
  123960. /**
  123961. * This specifies the weight of the reflection at a perpendicular point of view.
  123962. */
  123963. reflectionReflectance90: number;
  123964. /**
  123965. * Sets the reflection reflectance fresnel values according to the default standard
  123966. * empirically know to work well :-)
  123967. */
  123968. set reflectionStandardFresnelWeight(value: number);
  123969. protected _useRGBColor: boolean;
  123970. /**
  123971. * Helps to directly use the maps channels instead of their level.
  123972. */
  123973. useRGBColor: boolean;
  123974. protected _enableNoise: boolean;
  123975. /**
  123976. * This helps reducing the banding effect that could occur on the background.
  123977. */
  123978. enableNoise: boolean;
  123979. /**
  123980. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123981. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123982. * Recommended to be keep at 1.0 except for special cases.
  123983. */
  123984. get fovMultiplier(): number;
  123985. set fovMultiplier(value: number);
  123986. private _fovMultiplier;
  123987. /**
  123988. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123989. */
  123990. useEquirectangularFOV: boolean;
  123991. private _maxSimultaneousLights;
  123992. /**
  123993. * Number of Simultaneous lights allowed on the material.
  123994. */
  123995. maxSimultaneousLights: int;
  123996. /**
  123997. * Default configuration related to image processing available in the Background Material.
  123998. */
  123999. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124000. /**
  124001. * Keep track of the image processing observer to allow dispose and replace.
  124002. */
  124003. private _imageProcessingObserver;
  124004. /**
  124005. * Attaches a new image processing configuration to the PBR Material.
  124006. * @param configuration (if null the scene configuration will be use)
  124007. */
  124008. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124009. /**
  124010. * Gets the image processing configuration used either in this material.
  124011. */
  124012. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  124013. /**
  124014. * Sets the Default image processing configuration used either in the this material.
  124015. *
  124016. * If sets to null, the scene one is in use.
  124017. */
  124018. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  124019. /**
  124020. * Gets wether the color curves effect is enabled.
  124021. */
  124022. get cameraColorCurvesEnabled(): boolean;
  124023. /**
  124024. * Sets wether the color curves effect is enabled.
  124025. */
  124026. set cameraColorCurvesEnabled(value: boolean);
  124027. /**
  124028. * Gets wether the color grading effect is enabled.
  124029. */
  124030. get cameraColorGradingEnabled(): boolean;
  124031. /**
  124032. * Gets wether the color grading effect is enabled.
  124033. */
  124034. set cameraColorGradingEnabled(value: boolean);
  124035. /**
  124036. * Gets wether tonemapping is enabled or not.
  124037. */
  124038. get cameraToneMappingEnabled(): boolean;
  124039. /**
  124040. * Sets wether tonemapping is enabled or not
  124041. */
  124042. set cameraToneMappingEnabled(value: boolean);
  124043. /**
  124044. * The camera exposure used on this material.
  124045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124046. * This corresponds to a photographic exposure.
  124047. */
  124048. get cameraExposure(): float;
  124049. /**
  124050. * The camera exposure used on this material.
  124051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124052. * This corresponds to a photographic exposure.
  124053. */
  124054. set cameraExposure(value: float);
  124055. /**
  124056. * Gets The camera contrast used on this material.
  124057. */
  124058. get cameraContrast(): float;
  124059. /**
  124060. * Sets The camera contrast used on this material.
  124061. */
  124062. set cameraContrast(value: float);
  124063. /**
  124064. * Gets the Color Grading 2D Lookup Texture.
  124065. */
  124066. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124067. /**
  124068. * Sets the Color Grading 2D Lookup Texture.
  124069. */
  124070. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124071. /**
  124072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124074. * 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;
  124075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124076. */
  124077. get cameraColorCurves(): Nullable<ColorCurves>;
  124078. /**
  124079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124081. * 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;
  124082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124083. */
  124084. set cameraColorCurves(value: Nullable<ColorCurves>);
  124085. /**
  124086. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124087. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124088. */
  124089. switchToBGR: boolean;
  124090. private _renderTargets;
  124091. private _reflectionControls;
  124092. private _white;
  124093. private _primaryShadowColor;
  124094. private _primaryHighlightColor;
  124095. /**
  124096. * Instantiates a Background Material in the given scene
  124097. * @param name The friendly name of the material
  124098. * @param scene The scene to add the material to
  124099. */
  124100. constructor(name: string, scene: Scene);
  124101. /**
  124102. * Gets a boolean indicating that current material needs to register RTT
  124103. */
  124104. get hasRenderTargetTextures(): boolean;
  124105. /**
  124106. * The entire material has been created in order to prevent overdraw.
  124107. * @returns false
  124108. */
  124109. needAlphaTesting(): boolean;
  124110. /**
  124111. * The entire material has been created in order to prevent overdraw.
  124112. * @returns true if blending is enable
  124113. */
  124114. needAlphaBlending(): boolean;
  124115. /**
  124116. * Checks wether the material is ready to be rendered for a given mesh.
  124117. * @param mesh The mesh to render
  124118. * @param subMesh The submesh to check against
  124119. * @param useInstances Specify wether or not the material is used with instances
  124120. * @returns true if all the dependencies are ready (Textures, Effects...)
  124121. */
  124122. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124123. /**
  124124. * Compute the primary color according to the chosen perceptual color.
  124125. */
  124126. private _computePrimaryColorFromPerceptualColor;
  124127. /**
  124128. * Compute the highlights and shadow colors according to their chosen levels.
  124129. */
  124130. private _computePrimaryColors;
  124131. /**
  124132. * Build the uniform buffer used in the material.
  124133. */
  124134. buildUniformLayout(): void;
  124135. /**
  124136. * Unbind the material.
  124137. */
  124138. unbind(): void;
  124139. /**
  124140. * Bind only the world matrix to the material.
  124141. * @param world The world matrix to bind.
  124142. */
  124143. bindOnlyWorldMatrix(world: Matrix): void;
  124144. /**
  124145. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124146. * @param world The world matrix to bind.
  124147. * @param subMesh The submesh to bind for.
  124148. */
  124149. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124150. /**
  124151. * Checks to see if a texture is used in the material.
  124152. * @param texture - Base texture to use.
  124153. * @returns - Boolean specifying if a texture is used in the material.
  124154. */
  124155. hasTexture(texture: BaseTexture): boolean;
  124156. /**
  124157. * Dispose the material.
  124158. * @param forceDisposeEffect Force disposal of the associated effect.
  124159. * @param forceDisposeTextures Force disposal of the associated textures.
  124160. */
  124161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124162. /**
  124163. * Clones the material.
  124164. * @param name The cloned name.
  124165. * @returns The cloned material.
  124166. */
  124167. clone(name: string): BackgroundMaterial;
  124168. /**
  124169. * Serializes the current material to its JSON representation.
  124170. * @returns The JSON representation.
  124171. */
  124172. serialize(): any;
  124173. /**
  124174. * Gets the class name of the material
  124175. * @returns "BackgroundMaterial"
  124176. */
  124177. getClassName(): string;
  124178. /**
  124179. * Parse a JSON input to create back a background material.
  124180. * @param source The JSON data to parse
  124181. * @param scene The scene to create the parsed material in
  124182. * @param rootUrl The root url of the assets the material depends upon
  124183. * @returns the instantiated BackgroundMaterial.
  124184. */
  124185. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124186. }
  124187. }
  124188. declare module BABYLON {
  124189. /**
  124190. * Represents the different options available during the creation of
  124191. * a Environment helper.
  124192. *
  124193. * This can control the default ground, skybox and image processing setup of your scene.
  124194. */
  124195. export interface IEnvironmentHelperOptions {
  124196. /**
  124197. * Specifies whether or not to create a ground.
  124198. * True by default.
  124199. */
  124200. createGround: boolean;
  124201. /**
  124202. * Specifies the ground size.
  124203. * 15 by default.
  124204. */
  124205. groundSize: number;
  124206. /**
  124207. * The texture used on the ground for the main color.
  124208. * Comes from the BabylonJS CDN by default.
  124209. *
  124210. * Remarks: Can be either a texture or a url.
  124211. */
  124212. groundTexture: string | BaseTexture;
  124213. /**
  124214. * The color mixed in the ground texture by default.
  124215. * BabylonJS clearColor by default.
  124216. */
  124217. groundColor: Color3;
  124218. /**
  124219. * Specifies the ground opacity.
  124220. * 1 by default.
  124221. */
  124222. groundOpacity: number;
  124223. /**
  124224. * Enables the ground to receive shadows.
  124225. * True by default.
  124226. */
  124227. enableGroundShadow: boolean;
  124228. /**
  124229. * Helps preventing the shadow to be fully black on the ground.
  124230. * 0.5 by default.
  124231. */
  124232. groundShadowLevel: number;
  124233. /**
  124234. * Creates a mirror texture attach to the ground.
  124235. * false by default.
  124236. */
  124237. enableGroundMirror: boolean;
  124238. /**
  124239. * Specifies the ground mirror size ratio.
  124240. * 0.3 by default as the default kernel is 64.
  124241. */
  124242. groundMirrorSizeRatio: number;
  124243. /**
  124244. * Specifies the ground mirror blur kernel size.
  124245. * 64 by default.
  124246. */
  124247. groundMirrorBlurKernel: number;
  124248. /**
  124249. * Specifies the ground mirror visibility amount.
  124250. * 1 by default
  124251. */
  124252. groundMirrorAmount: number;
  124253. /**
  124254. * Specifies the ground mirror reflectance weight.
  124255. * This uses the standard weight of the background material to setup the fresnel effect
  124256. * of the mirror.
  124257. * 1 by default.
  124258. */
  124259. groundMirrorFresnelWeight: number;
  124260. /**
  124261. * Specifies the ground mirror Falloff distance.
  124262. * This can helps reducing the size of the reflection.
  124263. * 0 by Default.
  124264. */
  124265. groundMirrorFallOffDistance: number;
  124266. /**
  124267. * Specifies the ground mirror texture type.
  124268. * Unsigned Int by Default.
  124269. */
  124270. groundMirrorTextureType: number;
  124271. /**
  124272. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124273. * the shown objects.
  124274. */
  124275. groundYBias: number;
  124276. /**
  124277. * Specifies whether or not to create a skybox.
  124278. * True by default.
  124279. */
  124280. createSkybox: boolean;
  124281. /**
  124282. * Specifies the skybox size.
  124283. * 20 by default.
  124284. */
  124285. skyboxSize: number;
  124286. /**
  124287. * The texture used on the skybox for the main color.
  124288. * Comes from the BabylonJS CDN by default.
  124289. *
  124290. * Remarks: Can be either a texture or a url.
  124291. */
  124292. skyboxTexture: string | BaseTexture;
  124293. /**
  124294. * The color mixed in the skybox texture by default.
  124295. * BabylonJS clearColor by default.
  124296. */
  124297. skyboxColor: Color3;
  124298. /**
  124299. * The background rotation around the Y axis of the scene.
  124300. * This helps aligning the key lights of your scene with the background.
  124301. * 0 by default.
  124302. */
  124303. backgroundYRotation: number;
  124304. /**
  124305. * Compute automatically the size of the elements to best fit with the scene.
  124306. */
  124307. sizeAuto: boolean;
  124308. /**
  124309. * Default position of the rootMesh if autoSize is not true.
  124310. */
  124311. rootPosition: Vector3;
  124312. /**
  124313. * Sets up the image processing in the scene.
  124314. * true by default.
  124315. */
  124316. setupImageProcessing: boolean;
  124317. /**
  124318. * The texture used as your environment texture in the scene.
  124319. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124320. *
  124321. * Remarks: Can be either a texture or a url.
  124322. */
  124323. environmentTexture: string | BaseTexture;
  124324. /**
  124325. * The value of the exposure to apply to the scene.
  124326. * 0.6 by default if setupImageProcessing is true.
  124327. */
  124328. cameraExposure: number;
  124329. /**
  124330. * The value of the contrast to apply to the scene.
  124331. * 1.6 by default if setupImageProcessing is true.
  124332. */
  124333. cameraContrast: number;
  124334. /**
  124335. * Specifies whether or not tonemapping should be enabled in the scene.
  124336. * true by default if setupImageProcessing is true.
  124337. */
  124338. toneMappingEnabled: boolean;
  124339. }
  124340. /**
  124341. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124342. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124343. * It also helps with the default setup of your imageProcessing configuration.
  124344. */
  124345. export class EnvironmentHelper {
  124346. /**
  124347. * Default ground texture URL.
  124348. */
  124349. private static _groundTextureCDNUrl;
  124350. /**
  124351. * Default skybox texture URL.
  124352. */
  124353. private static _skyboxTextureCDNUrl;
  124354. /**
  124355. * Default environment texture URL.
  124356. */
  124357. private static _environmentTextureCDNUrl;
  124358. /**
  124359. * Creates the default options for the helper.
  124360. */
  124361. private static _getDefaultOptions;
  124362. private _rootMesh;
  124363. /**
  124364. * Gets the root mesh created by the helper.
  124365. */
  124366. get rootMesh(): Mesh;
  124367. private _skybox;
  124368. /**
  124369. * Gets the skybox created by the helper.
  124370. */
  124371. get skybox(): Nullable<Mesh>;
  124372. private _skyboxTexture;
  124373. /**
  124374. * Gets the skybox texture created by the helper.
  124375. */
  124376. get skyboxTexture(): Nullable<BaseTexture>;
  124377. private _skyboxMaterial;
  124378. /**
  124379. * Gets the skybox material created by the helper.
  124380. */
  124381. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124382. private _ground;
  124383. /**
  124384. * Gets the ground mesh created by the helper.
  124385. */
  124386. get ground(): Nullable<Mesh>;
  124387. private _groundTexture;
  124388. /**
  124389. * Gets the ground texture created by the helper.
  124390. */
  124391. get groundTexture(): Nullable<BaseTexture>;
  124392. private _groundMirror;
  124393. /**
  124394. * Gets the ground mirror created by the helper.
  124395. */
  124396. get groundMirror(): Nullable<MirrorTexture>;
  124397. /**
  124398. * Gets the ground mirror render list to helps pushing the meshes
  124399. * you wish in the ground reflection.
  124400. */
  124401. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124402. private _groundMaterial;
  124403. /**
  124404. * Gets the ground material created by the helper.
  124405. */
  124406. get groundMaterial(): Nullable<BackgroundMaterial>;
  124407. /**
  124408. * Stores the creation options.
  124409. */
  124410. private readonly _scene;
  124411. private _options;
  124412. /**
  124413. * This observable will be notified with any error during the creation of the environment,
  124414. * mainly texture creation errors.
  124415. */
  124416. onErrorObservable: Observable<{
  124417. message?: string;
  124418. exception?: any;
  124419. }>;
  124420. /**
  124421. * constructor
  124422. * @param options Defines the options we want to customize the helper
  124423. * @param scene The scene to add the material to
  124424. */
  124425. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124426. /**
  124427. * Updates the background according to the new options
  124428. * @param options
  124429. */
  124430. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124431. /**
  124432. * Sets the primary color of all the available elements.
  124433. * @param color the main color to affect to the ground and the background
  124434. */
  124435. setMainColor(color: Color3): void;
  124436. /**
  124437. * Setup the image processing according to the specified options.
  124438. */
  124439. private _setupImageProcessing;
  124440. /**
  124441. * Setup the environment texture according to the specified options.
  124442. */
  124443. private _setupEnvironmentTexture;
  124444. /**
  124445. * Setup the background according to the specified options.
  124446. */
  124447. private _setupBackground;
  124448. /**
  124449. * Get the scene sizes according to the setup.
  124450. */
  124451. private _getSceneSize;
  124452. /**
  124453. * Setup the ground according to the specified options.
  124454. */
  124455. private _setupGround;
  124456. /**
  124457. * Setup the ground material according to the specified options.
  124458. */
  124459. private _setupGroundMaterial;
  124460. /**
  124461. * Setup the ground diffuse texture according to the specified options.
  124462. */
  124463. private _setupGroundDiffuseTexture;
  124464. /**
  124465. * Setup the ground mirror texture according to the specified options.
  124466. */
  124467. private _setupGroundMirrorTexture;
  124468. /**
  124469. * Setup the ground to receive the mirror texture.
  124470. */
  124471. private _setupMirrorInGroundMaterial;
  124472. /**
  124473. * Setup the skybox according to the specified options.
  124474. */
  124475. private _setupSkybox;
  124476. /**
  124477. * Setup the skybox material according to the specified options.
  124478. */
  124479. private _setupSkyboxMaterial;
  124480. /**
  124481. * Setup the skybox reflection texture according to the specified options.
  124482. */
  124483. private _setupSkyboxReflectionTexture;
  124484. private _errorHandler;
  124485. /**
  124486. * Dispose all the elements created by the Helper.
  124487. */
  124488. dispose(): void;
  124489. }
  124490. }
  124491. declare module BABYLON {
  124492. /**
  124493. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124494. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124495. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124496. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124497. */
  124498. export class PhotoDome extends TransformNode {
  124499. /**
  124500. * Define the image as a Monoscopic panoramic 360 image.
  124501. */
  124502. static readonly MODE_MONOSCOPIC: number;
  124503. /**
  124504. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124505. */
  124506. static readonly MODE_TOPBOTTOM: number;
  124507. /**
  124508. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124509. */
  124510. static readonly MODE_SIDEBYSIDE: number;
  124511. private _useDirectMapping;
  124512. /**
  124513. * The texture being displayed on the sphere
  124514. */
  124515. protected _photoTexture: Texture;
  124516. /**
  124517. * Gets or sets the texture being displayed on the sphere
  124518. */
  124519. get photoTexture(): Texture;
  124520. set photoTexture(value: Texture);
  124521. /**
  124522. * Observable raised when an error occured while loading the 360 image
  124523. */
  124524. onLoadErrorObservable: Observable<string>;
  124525. /**
  124526. * The skybox material
  124527. */
  124528. protected _material: BackgroundMaterial;
  124529. /**
  124530. * The surface used for the skybox
  124531. */
  124532. protected _mesh: Mesh;
  124533. /**
  124534. * Gets the mesh used for the skybox.
  124535. */
  124536. get mesh(): Mesh;
  124537. /**
  124538. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124539. * Also see the options.resolution property.
  124540. */
  124541. get fovMultiplier(): number;
  124542. set fovMultiplier(value: number);
  124543. private _imageMode;
  124544. /**
  124545. * Gets or set the current video mode for the video. It can be:
  124546. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124547. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124548. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124549. */
  124550. get imageMode(): number;
  124551. set imageMode(value: number);
  124552. /**
  124553. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124554. * @param name Element's name, child elements will append suffixes for their own names.
  124555. * @param urlsOfPhoto defines the url of the photo to display
  124556. * @param options defines an object containing optional or exposed sub element properties
  124557. * @param onError defines a callback called when an error occured while loading the texture
  124558. */
  124559. constructor(name: string, urlOfPhoto: string, options: {
  124560. resolution?: number;
  124561. size?: number;
  124562. useDirectMapping?: boolean;
  124563. faceForward?: boolean;
  124564. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124565. private _onBeforeCameraRenderObserver;
  124566. private _changeImageMode;
  124567. /**
  124568. * Releases resources associated with this node.
  124569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124571. */
  124572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124573. }
  124574. }
  124575. declare module BABYLON {
  124576. /**
  124577. * Class used to host RGBD texture specific utilities
  124578. */
  124579. export class RGBDTextureTools {
  124580. /**
  124581. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124582. * @param texture the texture to expand.
  124583. */
  124584. static ExpandRGBDTexture(texture: Texture): void;
  124585. }
  124586. }
  124587. declare module BABYLON {
  124588. /**
  124589. * Class used to host texture specific utilities
  124590. */
  124591. export class BRDFTextureTools {
  124592. /**
  124593. * Prevents texture cache collision
  124594. */
  124595. private static _instanceNumber;
  124596. /**
  124597. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124598. * @param scene defines the hosting scene
  124599. * @returns the environment BRDF texture
  124600. */
  124601. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124602. private static _environmentBRDFBase64Texture;
  124603. }
  124604. }
  124605. declare module BABYLON {
  124606. /**
  124607. * @hidden
  124608. */
  124609. export interface IMaterialClearCoatDefines {
  124610. CLEARCOAT: boolean;
  124611. CLEARCOAT_DEFAULTIOR: boolean;
  124612. CLEARCOAT_TEXTURE: boolean;
  124613. CLEARCOAT_TEXTUREDIRECTUV: number;
  124614. CLEARCOAT_BUMP: boolean;
  124615. CLEARCOAT_BUMPDIRECTUV: number;
  124616. CLEARCOAT_TINT: boolean;
  124617. CLEARCOAT_TINT_TEXTURE: boolean;
  124618. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124619. /** @hidden */
  124620. _areTexturesDirty: boolean;
  124621. }
  124622. /**
  124623. * Define the code related to the clear coat parameters of the pbr material.
  124624. */
  124625. export class PBRClearCoatConfiguration {
  124626. /**
  124627. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124628. * The default fits with a polyurethane material.
  124629. */
  124630. private static readonly _DefaultIndexOfRefraction;
  124631. private _isEnabled;
  124632. /**
  124633. * Defines if the clear coat is enabled in the material.
  124634. */
  124635. isEnabled: boolean;
  124636. /**
  124637. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124638. */
  124639. intensity: number;
  124640. /**
  124641. * Defines the clear coat layer roughness.
  124642. */
  124643. roughness: number;
  124644. private _indexOfRefraction;
  124645. /**
  124646. * Defines the index of refraction of the clear coat.
  124647. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124648. * The default fits with a polyurethane material.
  124649. * Changing the default value is more performance intensive.
  124650. */
  124651. indexOfRefraction: number;
  124652. private _texture;
  124653. /**
  124654. * Stores the clear coat values in a texture.
  124655. */
  124656. texture: Nullable<BaseTexture>;
  124657. private _bumpTexture;
  124658. /**
  124659. * Define the clear coat specific bump texture.
  124660. */
  124661. bumpTexture: Nullable<BaseTexture>;
  124662. private _isTintEnabled;
  124663. /**
  124664. * Defines if the clear coat tint is enabled in the material.
  124665. */
  124666. isTintEnabled: boolean;
  124667. /**
  124668. * Defines the clear coat tint of the material.
  124669. * This is only use if tint is enabled
  124670. */
  124671. tintColor: Color3;
  124672. /**
  124673. * Defines the distance at which the tint color should be found in the
  124674. * clear coat media.
  124675. * This is only use if tint is enabled
  124676. */
  124677. tintColorAtDistance: number;
  124678. /**
  124679. * Defines the clear coat layer thickness.
  124680. * This is only use if tint is enabled
  124681. */
  124682. tintThickness: number;
  124683. private _tintTexture;
  124684. /**
  124685. * Stores the clear tint values in a texture.
  124686. * rgb is tint
  124687. * a is a thickness factor
  124688. */
  124689. tintTexture: Nullable<BaseTexture>;
  124690. /** @hidden */
  124691. private _internalMarkAllSubMeshesAsTexturesDirty;
  124692. /** @hidden */
  124693. _markAllSubMeshesAsTexturesDirty(): void;
  124694. /**
  124695. * Instantiate a new istance of clear coat configuration.
  124696. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124697. */
  124698. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124699. /**
  124700. * Gets wehter the submesh is ready to be used or not.
  124701. * @param defines the list of "defines" to update.
  124702. * @param scene defines the scene the material belongs to.
  124703. * @param engine defines the engine the material belongs to.
  124704. * @param disableBumpMap defines wether the material disables bump or not.
  124705. * @returns - boolean indicating that the submesh is ready or not.
  124706. */
  124707. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124708. /**
  124709. * Checks to see if a texture is used in the material.
  124710. * @param defines the list of "defines" to update.
  124711. * @param scene defines the scene to the material belongs to.
  124712. */
  124713. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124714. /**
  124715. * Binds the material data.
  124716. * @param uniformBuffer defines the Uniform buffer to fill in.
  124717. * @param scene defines the scene the material belongs to.
  124718. * @param engine defines the engine the material belongs to.
  124719. * @param disableBumpMap defines wether the material disables bump or not.
  124720. * @param isFrozen defines wether the material is frozen or not.
  124721. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124722. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124723. */
  124724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124725. /**
  124726. * Checks to see if a texture is used in the material.
  124727. * @param texture - Base texture to use.
  124728. * @returns - Boolean specifying if a texture is used in the material.
  124729. */
  124730. hasTexture(texture: BaseTexture): boolean;
  124731. /**
  124732. * Returns an array of the actively used textures.
  124733. * @param activeTextures Array of BaseTextures
  124734. */
  124735. getActiveTextures(activeTextures: BaseTexture[]): void;
  124736. /**
  124737. * Returns the animatable textures.
  124738. * @param animatables Array of animatable textures.
  124739. */
  124740. getAnimatables(animatables: IAnimatable[]): void;
  124741. /**
  124742. * Disposes the resources of the material.
  124743. * @param forceDisposeTextures - Forces the disposal of all textures.
  124744. */
  124745. dispose(forceDisposeTextures?: boolean): void;
  124746. /**
  124747. * Get the current class name of the texture useful for serialization or dynamic coding.
  124748. * @returns "PBRClearCoatConfiguration"
  124749. */
  124750. getClassName(): string;
  124751. /**
  124752. * Add fallbacks to the effect fallbacks list.
  124753. * @param defines defines the Base texture to use.
  124754. * @param fallbacks defines the current fallback list.
  124755. * @param currentRank defines the current fallback rank.
  124756. * @returns the new fallback rank.
  124757. */
  124758. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124759. /**
  124760. * Add the required uniforms to the current list.
  124761. * @param uniforms defines the current uniform list.
  124762. */
  124763. static AddUniforms(uniforms: string[]): void;
  124764. /**
  124765. * Add the required samplers to the current list.
  124766. * @param samplers defines the current sampler list.
  124767. */
  124768. static AddSamplers(samplers: string[]): void;
  124769. /**
  124770. * Add the required uniforms to the current buffer.
  124771. * @param uniformBuffer defines the current uniform buffer.
  124772. */
  124773. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124774. /**
  124775. * Makes a duplicate of the current configuration into another one.
  124776. * @param clearCoatConfiguration define the config where to copy the info
  124777. */
  124778. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124779. /**
  124780. * Serializes this clear coat configuration.
  124781. * @returns - An object with the serialized config.
  124782. */
  124783. serialize(): any;
  124784. /**
  124785. * Parses a anisotropy Configuration from a serialized object.
  124786. * @param source - Serialized object.
  124787. * @param scene Defines the scene we are parsing for
  124788. * @param rootUrl Defines the rootUrl to load from
  124789. */
  124790. parse(source: any, scene: Scene, rootUrl: string): void;
  124791. }
  124792. }
  124793. declare module BABYLON {
  124794. /**
  124795. * @hidden
  124796. */
  124797. export interface IMaterialAnisotropicDefines {
  124798. ANISOTROPIC: boolean;
  124799. ANISOTROPIC_TEXTURE: boolean;
  124800. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124801. MAINUV1: boolean;
  124802. _areTexturesDirty: boolean;
  124803. _needUVs: boolean;
  124804. }
  124805. /**
  124806. * Define the code related to the anisotropic parameters of the pbr material.
  124807. */
  124808. export class PBRAnisotropicConfiguration {
  124809. private _isEnabled;
  124810. /**
  124811. * Defines if the anisotropy is enabled in the material.
  124812. */
  124813. isEnabled: boolean;
  124814. /**
  124815. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124816. */
  124817. intensity: number;
  124818. /**
  124819. * Defines if the effect is along the tangents, bitangents or in between.
  124820. * By default, the effect is "strectching" the highlights along the tangents.
  124821. */
  124822. direction: Vector2;
  124823. private _texture;
  124824. /**
  124825. * Stores the anisotropy values in a texture.
  124826. * rg is direction (like normal from -1 to 1)
  124827. * b is a intensity
  124828. */
  124829. texture: Nullable<BaseTexture>;
  124830. /** @hidden */
  124831. private _internalMarkAllSubMeshesAsTexturesDirty;
  124832. /** @hidden */
  124833. _markAllSubMeshesAsTexturesDirty(): void;
  124834. /**
  124835. * Instantiate a new istance of anisotropy configuration.
  124836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124837. */
  124838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124839. /**
  124840. * Specifies that the submesh is ready to be used.
  124841. * @param defines the list of "defines" to update.
  124842. * @param scene defines the scene the material belongs to.
  124843. * @returns - boolean indicating that the submesh is ready or not.
  124844. */
  124845. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124846. /**
  124847. * Checks to see if a texture is used in the material.
  124848. * @param defines the list of "defines" to update.
  124849. * @param mesh the mesh we are preparing the defines for.
  124850. * @param scene defines the scene the material belongs to.
  124851. */
  124852. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124853. /**
  124854. * Binds the material data.
  124855. * @param uniformBuffer defines the Uniform buffer to fill in.
  124856. * @param scene defines the scene the material belongs to.
  124857. * @param isFrozen defines wether the material is frozen or not.
  124858. */
  124859. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124860. /**
  124861. * Checks to see if a texture is used in the material.
  124862. * @param texture - Base texture to use.
  124863. * @returns - Boolean specifying if a texture is used in the material.
  124864. */
  124865. hasTexture(texture: BaseTexture): boolean;
  124866. /**
  124867. * Returns an array of the actively used textures.
  124868. * @param activeTextures Array of BaseTextures
  124869. */
  124870. getActiveTextures(activeTextures: BaseTexture[]): void;
  124871. /**
  124872. * Returns the animatable textures.
  124873. * @param animatables Array of animatable textures.
  124874. */
  124875. getAnimatables(animatables: IAnimatable[]): void;
  124876. /**
  124877. * Disposes the resources of the material.
  124878. * @param forceDisposeTextures - Forces the disposal of all textures.
  124879. */
  124880. dispose(forceDisposeTextures?: boolean): void;
  124881. /**
  124882. * Get the current class name of the texture useful for serialization or dynamic coding.
  124883. * @returns "PBRAnisotropicConfiguration"
  124884. */
  124885. getClassName(): string;
  124886. /**
  124887. * Add fallbacks to the effect fallbacks list.
  124888. * @param defines defines the Base texture to use.
  124889. * @param fallbacks defines the current fallback list.
  124890. * @param currentRank defines the current fallback rank.
  124891. * @returns the new fallback rank.
  124892. */
  124893. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124894. /**
  124895. * Add the required uniforms to the current list.
  124896. * @param uniforms defines the current uniform list.
  124897. */
  124898. static AddUniforms(uniforms: string[]): void;
  124899. /**
  124900. * Add the required uniforms to the current buffer.
  124901. * @param uniformBuffer defines the current uniform buffer.
  124902. */
  124903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124904. /**
  124905. * Add the required samplers to the current list.
  124906. * @param samplers defines the current sampler list.
  124907. */
  124908. static AddSamplers(samplers: string[]): void;
  124909. /**
  124910. * Makes a duplicate of the current configuration into another one.
  124911. * @param anisotropicConfiguration define the config where to copy the info
  124912. */
  124913. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124914. /**
  124915. * Serializes this anisotropy configuration.
  124916. * @returns - An object with the serialized config.
  124917. */
  124918. serialize(): any;
  124919. /**
  124920. * Parses a anisotropy Configuration from a serialized object.
  124921. * @param source - Serialized object.
  124922. * @param scene Defines the scene we are parsing for
  124923. * @param rootUrl Defines the rootUrl to load from
  124924. */
  124925. parse(source: any, scene: Scene, rootUrl: string): void;
  124926. }
  124927. }
  124928. declare module BABYLON {
  124929. /**
  124930. * @hidden
  124931. */
  124932. export interface IMaterialBRDFDefines {
  124933. BRDF_V_HEIGHT_CORRELATED: boolean;
  124934. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124935. SPHERICAL_HARMONICS: boolean;
  124936. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124937. /** @hidden */
  124938. _areMiscDirty: boolean;
  124939. }
  124940. /**
  124941. * Define the code related to the BRDF parameters of the pbr material.
  124942. */
  124943. export class PBRBRDFConfiguration {
  124944. /**
  124945. * Default value used for the energy conservation.
  124946. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124947. */
  124948. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124949. /**
  124950. * Default value used for the Smith Visibility Height Correlated mode.
  124951. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124952. */
  124953. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124954. /**
  124955. * Default value used for the IBL diffuse part.
  124956. * This can help switching back to the polynomials mode globally which is a tiny bit
  124957. * less GPU intensive at the drawback of a lower quality.
  124958. */
  124959. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124960. /**
  124961. * Default value used for activating energy conservation for the specular workflow.
  124962. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124963. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124964. */
  124965. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124966. private _useEnergyConservation;
  124967. /**
  124968. * Defines if the material uses energy conservation.
  124969. */
  124970. useEnergyConservation: boolean;
  124971. private _useSmithVisibilityHeightCorrelated;
  124972. /**
  124973. * LEGACY Mode set to false
  124974. * Defines if the material uses height smith correlated visibility term.
  124975. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124976. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124977. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124978. * Not relying on height correlated will also disable energy conservation.
  124979. */
  124980. useSmithVisibilityHeightCorrelated: boolean;
  124981. private _useSphericalHarmonics;
  124982. /**
  124983. * LEGACY Mode set to false
  124984. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124985. * diffuse part of the IBL.
  124986. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124987. * to the ground truth.
  124988. */
  124989. useSphericalHarmonics: boolean;
  124990. private _useSpecularGlossinessInputEnergyConservation;
  124991. /**
  124992. * Defines if the material uses energy conservation, when the specular workflow is active.
  124993. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124994. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124995. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124996. */
  124997. useSpecularGlossinessInputEnergyConservation: boolean;
  124998. /** @hidden */
  124999. private _internalMarkAllSubMeshesAsMiscDirty;
  125000. /** @hidden */
  125001. _markAllSubMeshesAsMiscDirty(): void;
  125002. /**
  125003. * Instantiate a new istance of clear coat configuration.
  125004. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  125005. */
  125006. constructor(markAllSubMeshesAsMiscDirty: () => void);
  125007. /**
  125008. * Checks to see if a texture is used in the material.
  125009. * @param defines the list of "defines" to update.
  125010. */
  125011. prepareDefines(defines: IMaterialBRDFDefines): void;
  125012. /**
  125013. * Get the current class name of the texture useful for serialization or dynamic coding.
  125014. * @returns "PBRClearCoatConfiguration"
  125015. */
  125016. getClassName(): string;
  125017. /**
  125018. * Makes a duplicate of the current configuration into another one.
  125019. * @param brdfConfiguration define the config where to copy the info
  125020. */
  125021. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  125022. /**
  125023. * Serializes this BRDF configuration.
  125024. * @returns - An object with the serialized config.
  125025. */
  125026. serialize(): any;
  125027. /**
  125028. * Parses a anisotropy Configuration from a serialized object.
  125029. * @param source - Serialized object.
  125030. * @param scene Defines the scene we are parsing for
  125031. * @param rootUrl Defines the rootUrl to load from
  125032. */
  125033. parse(source: any, scene: Scene, rootUrl: string): void;
  125034. }
  125035. }
  125036. declare module BABYLON {
  125037. /**
  125038. * @hidden
  125039. */
  125040. export interface IMaterialSheenDefines {
  125041. SHEEN: boolean;
  125042. SHEEN_TEXTURE: boolean;
  125043. SHEEN_TEXTUREDIRECTUV: number;
  125044. SHEEN_LINKWITHALBEDO: boolean;
  125045. SHEEN_ROUGHNESS: boolean;
  125046. SHEEN_ALBEDOSCALING: boolean;
  125047. /** @hidden */
  125048. _areTexturesDirty: boolean;
  125049. }
  125050. /**
  125051. * Define the code related to the Sheen parameters of the pbr material.
  125052. */
  125053. export class PBRSheenConfiguration {
  125054. private _isEnabled;
  125055. /**
  125056. * Defines if the material uses sheen.
  125057. */
  125058. isEnabled: boolean;
  125059. private _linkSheenWithAlbedo;
  125060. /**
  125061. * Defines if the sheen is linked to the sheen color.
  125062. */
  125063. linkSheenWithAlbedo: boolean;
  125064. /**
  125065. * Defines the sheen intensity.
  125066. */
  125067. intensity: number;
  125068. /**
  125069. * Defines the sheen color.
  125070. */
  125071. color: Color3;
  125072. private _texture;
  125073. /**
  125074. * Stores the sheen tint values in a texture.
  125075. * rgb is tint
  125076. * a is a intensity
  125077. */
  125078. texture: Nullable<BaseTexture>;
  125079. private _roughness;
  125080. /**
  125081. * Defines the sheen roughness.
  125082. * It is not taken into account if linkSheenWithAlbedo is true.
  125083. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125084. */
  125085. roughness: Nullable<number>;
  125086. private _albedoScaling;
  125087. /**
  125088. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125089. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125090. * making it easier to setup and tweak the effect
  125091. */
  125092. albedoScaling: boolean;
  125093. /** @hidden */
  125094. private _internalMarkAllSubMeshesAsTexturesDirty;
  125095. /** @hidden */
  125096. _markAllSubMeshesAsTexturesDirty(): void;
  125097. /**
  125098. * Instantiate a new istance of clear coat configuration.
  125099. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125100. */
  125101. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125102. /**
  125103. * Specifies that the submesh is ready to be used.
  125104. * @param defines the list of "defines" to update.
  125105. * @param scene defines the scene the material belongs to.
  125106. * @returns - boolean indicating that the submesh is ready or not.
  125107. */
  125108. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125109. /**
  125110. * Checks to see if a texture is used in the material.
  125111. * @param defines the list of "defines" to update.
  125112. * @param scene defines the scene the material belongs to.
  125113. */
  125114. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125115. /**
  125116. * Binds the material data.
  125117. * @param uniformBuffer defines the Uniform buffer to fill in.
  125118. * @param scene defines the scene the material belongs to.
  125119. * @param isFrozen defines wether the material is frozen or not.
  125120. */
  125121. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125122. /**
  125123. * Checks to see if a texture is used in the material.
  125124. * @param texture - Base texture to use.
  125125. * @returns - Boolean specifying if a texture is used in the material.
  125126. */
  125127. hasTexture(texture: BaseTexture): boolean;
  125128. /**
  125129. * Returns an array of the actively used textures.
  125130. * @param activeTextures Array of BaseTextures
  125131. */
  125132. getActiveTextures(activeTextures: BaseTexture[]): void;
  125133. /**
  125134. * Returns the animatable textures.
  125135. * @param animatables Array of animatable textures.
  125136. */
  125137. getAnimatables(animatables: IAnimatable[]): void;
  125138. /**
  125139. * Disposes the resources of the material.
  125140. * @param forceDisposeTextures - Forces the disposal of all textures.
  125141. */
  125142. dispose(forceDisposeTextures?: boolean): void;
  125143. /**
  125144. * Get the current class name of the texture useful for serialization or dynamic coding.
  125145. * @returns "PBRSheenConfiguration"
  125146. */
  125147. getClassName(): string;
  125148. /**
  125149. * Add fallbacks to the effect fallbacks list.
  125150. * @param defines defines the Base texture to use.
  125151. * @param fallbacks defines the current fallback list.
  125152. * @param currentRank defines the current fallback rank.
  125153. * @returns the new fallback rank.
  125154. */
  125155. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125156. /**
  125157. * Add the required uniforms to the current list.
  125158. * @param uniforms defines the current uniform list.
  125159. */
  125160. static AddUniforms(uniforms: string[]): void;
  125161. /**
  125162. * Add the required uniforms to the current buffer.
  125163. * @param uniformBuffer defines the current uniform buffer.
  125164. */
  125165. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125166. /**
  125167. * Add the required samplers to the current list.
  125168. * @param samplers defines the current sampler list.
  125169. */
  125170. static AddSamplers(samplers: string[]): void;
  125171. /**
  125172. * Makes a duplicate of the current configuration into another one.
  125173. * @param sheenConfiguration define the config where to copy the info
  125174. */
  125175. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125176. /**
  125177. * Serializes this BRDF configuration.
  125178. * @returns - An object with the serialized config.
  125179. */
  125180. serialize(): any;
  125181. /**
  125182. * Parses a anisotropy Configuration from a serialized object.
  125183. * @param source - Serialized object.
  125184. * @param scene Defines the scene we are parsing for
  125185. * @param rootUrl Defines the rootUrl to load from
  125186. */
  125187. parse(source: any, scene: Scene, rootUrl: string): void;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * @hidden
  125193. */
  125194. export interface IMaterialSubSurfaceDefines {
  125195. SUBSURFACE: boolean;
  125196. SS_REFRACTION: boolean;
  125197. SS_TRANSLUCENCY: boolean;
  125198. SS_SCATERRING: boolean;
  125199. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125200. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125201. SS_REFRACTIONMAP_3D: boolean;
  125202. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125203. SS_LODINREFRACTIONALPHA: boolean;
  125204. SS_GAMMAREFRACTION: boolean;
  125205. SS_RGBDREFRACTION: boolean;
  125206. SS_LINEARSPECULARREFRACTION: boolean;
  125207. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125208. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125209. /** @hidden */
  125210. _areTexturesDirty: boolean;
  125211. }
  125212. /**
  125213. * Define the code related to the sub surface parameters of the pbr material.
  125214. */
  125215. export class PBRSubSurfaceConfiguration {
  125216. private _isRefractionEnabled;
  125217. /**
  125218. * Defines if the refraction is enabled in the material.
  125219. */
  125220. isRefractionEnabled: boolean;
  125221. private _isTranslucencyEnabled;
  125222. /**
  125223. * Defines if the translucency is enabled in the material.
  125224. */
  125225. isTranslucencyEnabled: boolean;
  125226. private _isScatteringEnabled;
  125227. /**
  125228. * Defines the refraction intensity of the material.
  125229. * The refraction when enabled replaces the Diffuse part of the material.
  125230. * The intensity helps transitionning between diffuse and refraction.
  125231. */
  125232. refractionIntensity: number;
  125233. /**
  125234. * Defines the translucency intensity of the material.
  125235. * When translucency has been enabled, this defines how much of the "translucency"
  125236. * is addded to the diffuse part of the material.
  125237. */
  125238. translucencyIntensity: number;
  125239. /**
  125240. * Defines the scattering intensity of the material.
  125241. * When scattering has been enabled, this defines how much of the "scattered light"
  125242. * is addded to the diffuse part of the material.
  125243. */
  125244. scatteringIntensity: number;
  125245. private _thicknessTexture;
  125246. /**
  125247. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125248. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125249. * 0 would mean minimumThickness
  125250. * 1 would mean maximumThickness
  125251. * The other channels might be use as a mask to vary the different effects intensity.
  125252. */
  125253. thicknessTexture: Nullable<BaseTexture>;
  125254. private _refractionTexture;
  125255. /**
  125256. * Defines the texture to use for refraction.
  125257. */
  125258. refractionTexture: Nullable<BaseTexture>;
  125259. private _indexOfRefraction;
  125260. /**
  125261. * Defines the index of refraction used in the material.
  125262. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125263. */
  125264. indexOfRefraction: number;
  125265. private _invertRefractionY;
  125266. /**
  125267. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125268. */
  125269. invertRefractionY: boolean;
  125270. private _linkRefractionWithTransparency;
  125271. /**
  125272. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125273. * Materials half opaque for instance using refraction could benefit from this control.
  125274. */
  125275. linkRefractionWithTransparency: boolean;
  125276. /**
  125277. * Defines the minimum thickness stored in the thickness map.
  125278. * If no thickness map is defined, this value will be used to simulate thickness.
  125279. */
  125280. minimumThickness: number;
  125281. /**
  125282. * Defines the maximum thickness stored in the thickness map.
  125283. */
  125284. maximumThickness: number;
  125285. /**
  125286. * Defines the volume tint of the material.
  125287. * This is used for both translucency and scattering.
  125288. */
  125289. tintColor: Color3;
  125290. /**
  125291. * Defines the distance at which the tint color should be found in the media.
  125292. * This is used for refraction only.
  125293. */
  125294. tintColorAtDistance: number;
  125295. /**
  125296. * Defines how far each channel transmit through the media.
  125297. * It is defined as a color to simplify it selection.
  125298. */
  125299. diffusionDistance: Color3;
  125300. private _useMaskFromThicknessTexture;
  125301. /**
  125302. * Stores the intensity of the different subsurface effects in the thickness texture.
  125303. * * the green channel is the translucency intensity.
  125304. * * the blue channel is the scattering intensity.
  125305. * * the alpha channel is the refraction intensity.
  125306. */
  125307. useMaskFromThicknessTexture: boolean;
  125308. /** @hidden */
  125309. private _internalMarkAllSubMeshesAsTexturesDirty;
  125310. /** @hidden */
  125311. _markAllSubMeshesAsTexturesDirty(): void;
  125312. /**
  125313. * Instantiate a new istance of sub surface configuration.
  125314. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125315. */
  125316. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125317. /**
  125318. * Gets wehter the submesh is ready to be used or not.
  125319. * @param defines the list of "defines" to update.
  125320. * @param scene defines the scene the material belongs to.
  125321. * @returns - boolean indicating that the submesh is ready or not.
  125322. */
  125323. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125324. /**
  125325. * Checks to see if a texture is used in the material.
  125326. * @param defines the list of "defines" to update.
  125327. * @param scene defines the scene to the material belongs to.
  125328. */
  125329. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125330. /**
  125331. * Binds the material data.
  125332. * @param uniformBuffer defines the Uniform buffer to fill in.
  125333. * @param scene defines the scene the material belongs to.
  125334. * @param engine defines the engine the material belongs to.
  125335. * @param isFrozen defines wether the material is frozen or not.
  125336. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125337. */
  125338. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125339. /**
  125340. * Unbinds the material from the mesh.
  125341. * @param activeEffect defines the effect that should be unbound from.
  125342. * @returns true if unbound, otherwise false
  125343. */
  125344. unbind(activeEffect: Effect): boolean;
  125345. /**
  125346. * Returns the texture used for refraction or null if none is used.
  125347. * @param scene defines the scene the material belongs to.
  125348. * @returns - Refraction texture if present. If no refraction texture and refraction
  125349. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125350. */
  125351. private _getRefractionTexture;
  125352. /**
  125353. * Returns true if alpha blending should be disabled.
  125354. */
  125355. get disableAlphaBlending(): boolean;
  125356. /**
  125357. * Fills the list of render target textures.
  125358. * @param renderTargets the list of render targets to update
  125359. */
  125360. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125361. /**
  125362. * Checks to see if a texture is used in the material.
  125363. * @param texture - Base texture to use.
  125364. * @returns - Boolean specifying if a texture is used in the material.
  125365. */
  125366. hasTexture(texture: BaseTexture): boolean;
  125367. /**
  125368. * Gets a boolean indicating that current material needs to register RTT
  125369. * @returns true if this uses a render target otherwise false.
  125370. */
  125371. hasRenderTargetTextures(): boolean;
  125372. /**
  125373. * Returns an array of the actively used textures.
  125374. * @param activeTextures Array of BaseTextures
  125375. */
  125376. getActiveTextures(activeTextures: BaseTexture[]): void;
  125377. /**
  125378. * Returns the animatable textures.
  125379. * @param animatables Array of animatable textures.
  125380. */
  125381. getAnimatables(animatables: IAnimatable[]): void;
  125382. /**
  125383. * Disposes the resources of the material.
  125384. * @param forceDisposeTextures - Forces the disposal of all textures.
  125385. */
  125386. dispose(forceDisposeTextures?: boolean): void;
  125387. /**
  125388. * Get the current class name of the texture useful for serialization or dynamic coding.
  125389. * @returns "PBRSubSurfaceConfiguration"
  125390. */
  125391. getClassName(): string;
  125392. /**
  125393. * Add fallbacks to the effect fallbacks list.
  125394. * @param defines defines the Base texture to use.
  125395. * @param fallbacks defines the current fallback list.
  125396. * @param currentRank defines the current fallback rank.
  125397. * @returns the new fallback rank.
  125398. */
  125399. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125400. /**
  125401. * Add the required uniforms to the current list.
  125402. * @param uniforms defines the current uniform list.
  125403. */
  125404. static AddUniforms(uniforms: string[]): void;
  125405. /**
  125406. * Add the required samplers to the current list.
  125407. * @param samplers defines the current sampler list.
  125408. */
  125409. static AddSamplers(samplers: string[]): void;
  125410. /**
  125411. * Add the required uniforms to the current buffer.
  125412. * @param uniformBuffer defines the current uniform buffer.
  125413. */
  125414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125415. /**
  125416. * Makes a duplicate of the current configuration into another one.
  125417. * @param configuration define the config where to copy the info
  125418. */
  125419. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125420. /**
  125421. * Serializes this Sub Surface configuration.
  125422. * @returns - An object with the serialized config.
  125423. */
  125424. serialize(): any;
  125425. /**
  125426. * Parses a anisotropy Configuration from a serialized object.
  125427. * @param source - Serialized object.
  125428. * @param scene Defines the scene we are parsing for
  125429. * @param rootUrl Defines the rootUrl to load from
  125430. */
  125431. parse(source: any, scene: Scene, rootUrl: string): void;
  125432. }
  125433. }
  125434. declare module BABYLON {
  125435. /** @hidden */
  125436. export var pbrFragmentDeclaration: {
  125437. name: string;
  125438. shader: string;
  125439. };
  125440. }
  125441. declare module BABYLON {
  125442. /** @hidden */
  125443. export var pbrUboDeclaration: {
  125444. name: string;
  125445. shader: string;
  125446. };
  125447. }
  125448. declare module BABYLON {
  125449. /** @hidden */
  125450. export var pbrFragmentExtraDeclaration: {
  125451. name: string;
  125452. shader: string;
  125453. };
  125454. }
  125455. declare module BABYLON {
  125456. /** @hidden */
  125457. export var pbrFragmentSamplersDeclaration: {
  125458. name: string;
  125459. shader: string;
  125460. };
  125461. }
  125462. declare module BABYLON {
  125463. /** @hidden */
  125464. export var pbrHelperFunctions: {
  125465. name: string;
  125466. shader: string;
  125467. };
  125468. }
  125469. declare module BABYLON {
  125470. /** @hidden */
  125471. export var harmonicsFunctions: {
  125472. name: string;
  125473. shader: string;
  125474. };
  125475. }
  125476. declare module BABYLON {
  125477. /** @hidden */
  125478. export var pbrDirectLightingSetupFunctions: {
  125479. name: string;
  125480. shader: string;
  125481. };
  125482. }
  125483. declare module BABYLON {
  125484. /** @hidden */
  125485. export var pbrDirectLightingFalloffFunctions: {
  125486. name: string;
  125487. shader: string;
  125488. };
  125489. }
  125490. declare module BABYLON {
  125491. /** @hidden */
  125492. export var pbrBRDFFunctions: {
  125493. name: string;
  125494. shader: string;
  125495. };
  125496. }
  125497. declare module BABYLON {
  125498. /** @hidden */
  125499. export var pbrDirectLightingFunctions: {
  125500. name: string;
  125501. shader: string;
  125502. };
  125503. }
  125504. declare module BABYLON {
  125505. /** @hidden */
  125506. export var pbrIBLFunctions: {
  125507. name: string;
  125508. shader: string;
  125509. };
  125510. }
  125511. declare module BABYLON {
  125512. /** @hidden */
  125513. export var pbrBlockAlbedoOpacity: {
  125514. name: string;
  125515. shader: string;
  125516. };
  125517. }
  125518. declare module BABYLON {
  125519. /** @hidden */
  125520. export var pbrBlockReflectivity: {
  125521. name: string;
  125522. shader: string;
  125523. };
  125524. }
  125525. declare module BABYLON {
  125526. /** @hidden */
  125527. export var pbrBlockAmbientOcclusion: {
  125528. name: string;
  125529. shader: string;
  125530. };
  125531. }
  125532. declare module BABYLON {
  125533. /** @hidden */
  125534. export var pbrBlockAlphaFresnel: {
  125535. name: string;
  125536. shader: string;
  125537. };
  125538. }
  125539. declare module BABYLON {
  125540. /** @hidden */
  125541. export var pbrBlockAnisotropic: {
  125542. name: string;
  125543. shader: string;
  125544. };
  125545. }
  125546. declare module BABYLON {
  125547. /** @hidden */
  125548. export var pbrBlockReflection: {
  125549. name: string;
  125550. shader: string;
  125551. };
  125552. }
  125553. declare module BABYLON {
  125554. /** @hidden */
  125555. export var pbrBlockSheen: {
  125556. name: string;
  125557. shader: string;
  125558. };
  125559. }
  125560. declare module BABYLON {
  125561. /** @hidden */
  125562. export var pbrBlockClearcoat: {
  125563. name: string;
  125564. shader: string;
  125565. };
  125566. }
  125567. declare module BABYLON {
  125568. /** @hidden */
  125569. export var pbrBlockSubSurface: {
  125570. name: string;
  125571. shader: string;
  125572. };
  125573. }
  125574. declare module BABYLON {
  125575. /** @hidden */
  125576. export var pbrBlockNormalGeometric: {
  125577. name: string;
  125578. shader: string;
  125579. };
  125580. }
  125581. declare module BABYLON {
  125582. /** @hidden */
  125583. export var pbrBlockNormalFinal: {
  125584. name: string;
  125585. shader: string;
  125586. };
  125587. }
  125588. declare module BABYLON {
  125589. /** @hidden */
  125590. export var pbrBlockGeometryInfo: {
  125591. name: string;
  125592. shader: string;
  125593. };
  125594. }
  125595. declare module BABYLON {
  125596. /** @hidden */
  125597. export var pbrBlockReflectance0: {
  125598. name: string;
  125599. shader: string;
  125600. };
  125601. }
  125602. declare module BABYLON {
  125603. /** @hidden */
  125604. export var pbrBlockReflectance: {
  125605. name: string;
  125606. shader: string;
  125607. };
  125608. }
  125609. declare module BABYLON {
  125610. /** @hidden */
  125611. export var pbrBlockDirectLighting: {
  125612. name: string;
  125613. shader: string;
  125614. };
  125615. }
  125616. declare module BABYLON {
  125617. /** @hidden */
  125618. export var pbrBlockFinalLitComponents: {
  125619. name: string;
  125620. shader: string;
  125621. };
  125622. }
  125623. declare module BABYLON {
  125624. /** @hidden */
  125625. export var pbrBlockFinalUnlitComponents: {
  125626. name: string;
  125627. shader: string;
  125628. };
  125629. }
  125630. declare module BABYLON {
  125631. /** @hidden */
  125632. export var pbrBlockFinalColorComposition: {
  125633. name: string;
  125634. shader: string;
  125635. };
  125636. }
  125637. declare module BABYLON {
  125638. /** @hidden */
  125639. export var pbrBlockImageProcessing: {
  125640. name: string;
  125641. shader: string;
  125642. };
  125643. }
  125644. declare module BABYLON {
  125645. /** @hidden */
  125646. export var pbrDebug: {
  125647. name: string;
  125648. shader: string;
  125649. };
  125650. }
  125651. declare module BABYLON {
  125652. /** @hidden */
  125653. export var pbrPixelShader: {
  125654. name: string;
  125655. shader: string;
  125656. };
  125657. }
  125658. declare module BABYLON {
  125659. /** @hidden */
  125660. export var pbrVertexDeclaration: {
  125661. name: string;
  125662. shader: string;
  125663. };
  125664. }
  125665. declare module BABYLON {
  125666. /** @hidden */
  125667. export var pbrVertexShader: {
  125668. name: string;
  125669. shader: string;
  125670. };
  125671. }
  125672. declare module BABYLON {
  125673. /**
  125674. * Manages the defines for the PBR Material.
  125675. * @hidden
  125676. */
  125677. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125678. PBR: boolean;
  125679. MAINUV1: boolean;
  125680. MAINUV2: boolean;
  125681. UV1: boolean;
  125682. UV2: boolean;
  125683. ALBEDO: boolean;
  125684. GAMMAALBEDO: boolean;
  125685. ALBEDODIRECTUV: number;
  125686. VERTEXCOLOR: boolean;
  125687. AMBIENT: boolean;
  125688. AMBIENTDIRECTUV: number;
  125689. AMBIENTINGRAYSCALE: boolean;
  125690. OPACITY: boolean;
  125691. VERTEXALPHA: boolean;
  125692. OPACITYDIRECTUV: number;
  125693. OPACITYRGB: boolean;
  125694. ALPHATEST: boolean;
  125695. DEPTHPREPASS: boolean;
  125696. ALPHABLEND: boolean;
  125697. ALPHAFROMALBEDO: boolean;
  125698. ALPHATESTVALUE: string;
  125699. SPECULAROVERALPHA: boolean;
  125700. RADIANCEOVERALPHA: boolean;
  125701. ALPHAFRESNEL: boolean;
  125702. LINEARALPHAFRESNEL: boolean;
  125703. PREMULTIPLYALPHA: boolean;
  125704. EMISSIVE: boolean;
  125705. EMISSIVEDIRECTUV: number;
  125706. REFLECTIVITY: boolean;
  125707. REFLECTIVITYDIRECTUV: number;
  125708. SPECULARTERM: boolean;
  125709. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125710. MICROSURFACEAUTOMATIC: boolean;
  125711. LODBASEDMICROSFURACE: boolean;
  125712. MICROSURFACEMAP: boolean;
  125713. MICROSURFACEMAPDIRECTUV: number;
  125714. METALLICWORKFLOW: boolean;
  125715. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125716. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125717. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125718. AOSTOREINMETALMAPRED: boolean;
  125719. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125720. ENVIRONMENTBRDF: boolean;
  125721. ENVIRONMENTBRDF_RGBD: boolean;
  125722. NORMAL: boolean;
  125723. TANGENT: boolean;
  125724. BUMP: boolean;
  125725. BUMPDIRECTUV: number;
  125726. OBJECTSPACE_NORMALMAP: boolean;
  125727. PARALLAX: boolean;
  125728. PARALLAXOCCLUSION: boolean;
  125729. NORMALXYSCALE: boolean;
  125730. LIGHTMAP: boolean;
  125731. LIGHTMAPDIRECTUV: number;
  125732. USELIGHTMAPASSHADOWMAP: boolean;
  125733. GAMMALIGHTMAP: boolean;
  125734. RGBDLIGHTMAP: boolean;
  125735. REFLECTION: boolean;
  125736. REFLECTIONMAP_3D: boolean;
  125737. REFLECTIONMAP_SPHERICAL: boolean;
  125738. REFLECTIONMAP_PLANAR: boolean;
  125739. REFLECTIONMAP_CUBIC: boolean;
  125740. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125741. REFLECTIONMAP_PROJECTION: boolean;
  125742. REFLECTIONMAP_SKYBOX: boolean;
  125743. REFLECTIONMAP_EXPLICIT: boolean;
  125744. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125745. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125746. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125747. INVERTCUBICMAP: boolean;
  125748. USESPHERICALFROMREFLECTIONMAP: boolean;
  125749. USEIRRADIANCEMAP: boolean;
  125750. SPHERICAL_HARMONICS: boolean;
  125751. USESPHERICALINVERTEX: boolean;
  125752. REFLECTIONMAP_OPPOSITEZ: boolean;
  125753. LODINREFLECTIONALPHA: boolean;
  125754. GAMMAREFLECTION: boolean;
  125755. RGBDREFLECTION: boolean;
  125756. LINEARSPECULARREFLECTION: boolean;
  125757. RADIANCEOCCLUSION: boolean;
  125758. HORIZONOCCLUSION: boolean;
  125759. INSTANCES: boolean;
  125760. NUM_BONE_INFLUENCERS: number;
  125761. BonesPerMesh: number;
  125762. BONETEXTURE: boolean;
  125763. NONUNIFORMSCALING: boolean;
  125764. MORPHTARGETS: boolean;
  125765. MORPHTARGETS_NORMAL: boolean;
  125766. MORPHTARGETS_TANGENT: boolean;
  125767. MORPHTARGETS_UV: boolean;
  125768. NUM_MORPH_INFLUENCERS: number;
  125769. IMAGEPROCESSING: boolean;
  125770. VIGNETTE: boolean;
  125771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125772. VIGNETTEBLENDMODEOPAQUE: boolean;
  125773. TONEMAPPING: boolean;
  125774. TONEMAPPING_ACES: boolean;
  125775. CONTRAST: boolean;
  125776. COLORCURVES: boolean;
  125777. COLORGRADING: boolean;
  125778. COLORGRADING3D: boolean;
  125779. SAMPLER3DGREENDEPTH: boolean;
  125780. SAMPLER3DBGRMAP: boolean;
  125781. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125782. EXPOSURE: boolean;
  125783. MULTIVIEW: boolean;
  125784. USEPHYSICALLIGHTFALLOFF: boolean;
  125785. USEGLTFLIGHTFALLOFF: boolean;
  125786. TWOSIDEDLIGHTING: boolean;
  125787. SHADOWFLOAT: boolean;
  125788. CLIPPLANE: boolean;
  125789. CLIPPLANE2: boolean;
  125790. CLIPPLANE3: boolean;
  125791. CLIPPLANE4: boolean;
  125792. CLIPPLANE5: boolean;
  125793. CLIPPLANE6: boolean;
  125794. POINTSIZE: boolean;
  125795. FOG: boolean;
  125796. LOGARITHMICDEPTH: boolean;
  125797. FORCENORMALFORWARD: boolean;
  125798. SPECULARAA: boolean;
  125799. CLEARCOAT: boolean;
  125800. CLEARCOAT_DEFAULTIOR: boolean;
  125801. CLEARCOAT_TEXTURE: boolean;
  125802. CLEARCOAT_TEXTUREDIRECTUV: number;
  125803. CLEARCOAT_BUMP: boolean;
  125804. CLEARCOAT_BUMPDIRECTUV: number;
  125805. CLEARCOAT_TINT: boolean;
  125806. CLEARCOAT_TINT_TEXTURE: boolean;
  125807. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125808. ANISOTROPIC: boolean;
  125809. ANISOTROPIC_TEXTURE: boolean;
  125810. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125811. BRDF_V_HEIGHT_CORRELATED: boolean;
  125812. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125813. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125814. SHEEN: boolean;
  125815. SHEEN_TEXTURE: boolean;
  125816. SHEEN_TEXTUREDIRECTUV: number;
  125817. SHEEN_LINKWITHALBEDO: boolean;
  125818. SHEEN_ROUGHNESS: boolean;
  125819. SHEEN_ALBEDOSCALING: boolean;
  125820. SUBSURFACE: boolean;
  125821. SS_REFRACTION: boolean;
  125822. SS_TRANSLUCENCY: boolean;
  125823. SS_SCATERRING: boolean;
  125824. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125825. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125826. SS_REFRACTIONMAP_3D: boolean;
  125827. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125828. SS_LODINREFRACTIONALPHA: boolean;
  125829. SS_GAMMAREFRACTION: boolean;
  125830. SS_RGBDREFRACTION: boolean;
  125831. SS_LINEARSPECULARREFRACTION: boolean;
  125832. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125833. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125834. UNLIT: boolean;
  125835. DEBUGMODE: number;
  125836. /**
  125837. * Initializes the PBR Material defines.
  125838. */
  125839. constructor();
  125840. /**
  125841. * Resets the PBR Material defines.
  125842. */
  125843. reset(): void;
  125844. }
  125845. /**
  125846. * The Physically based material base class of BJS.
  125847. *
  125848. * This offers the main features of a standard PBR material.
  125849. * For more information, please refer to the documentation :
  125850. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125851. */
  125852. export abstract class PBRBaseMaterial extends PushMaterial {
  125853. /**
  125854. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125855. */
  125856. static readonly PBRMATERIAL_OPAQUE: number;
  125857. /**
  125858. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125859. */
  125860. static readonly PBRMATERIAL_ALPHATEST: number;
  125861. /**
  125862. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125863. */
  125864. static readonly PBRMATERIAL_ALPHABLEND: number;
  125865. /**
  125866. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125867. * They are also discarded below the alpha cutoff threshold to improve performances.
  125868. */
  125869. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125870. /**
  125871. * Defines the default value of how much AO map is occluding the analytical lights
  125872. * (point spot...).
  125873. */
  125874. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125875. /**
  125876. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125877. */
  125878. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125879. /**
  125880. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125881. * to enhance interoperability with other engines.
  125882. */
  125883. static readonly LIGHTFALLOFF_GLTF: number;
  125884. /**
  125885. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125886. * to enhance interoperability with other materials.
  125887. */
  125888. static readonly LIGHTFALLOFF_STANDARD: number;
  125889. /**
  125890. * Intensity of the direct lights e.g. the four lights available in your scene.
  125891. * This impacts both the direct diffuse and specular highlights.
  125892. */
  125893. protected _directIntensity: number;
  125894. /**
  125895. * Intensity of the emissive part of the material.
  125896. * This helps controlling the emissive effect without modifying the emissive color.
  125897. */
  125898. protected _emissiveIntensity: number;
  125899. /**
  125900. * Intensity of the environment e.g. how much the environment will light the object
  125901. * either through harmonics for rough material or through the refelction for shiny ones.
  125902. */
  125903. protected _environmentIntensity: number;
  125904. /**
  125905. * This is a special control allowing the reduction of the specular highlights coming from the
  125906. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125907. */
  125908. protected _specularIntensity: number;
  125909. /**
  125910. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125911. */
  125912. private _lightingInfos;
  125913. /**
  125914. * Debug Control allowing disabling the bump map on this material.
  125915. */
  125916. protected _disableBumpMap: boolean;
  125917. /**
  125918. * AKA Diffuse Texture in standard nomenclature.
  125919. */
  125920. protected _albedoTexture: Nullable<BaseTexture>;
  125921. /**
  125922. * AKA Occlusion Texture in other nomenclature.
  125923. */
  125924. protected _ambientTexture: Nullable<BaseTexture>;
  125925. /**
  125926. * AKA Occlusion Texture Intensity in other nomenclature.
  125927. */
  125928. protected _ambientTextureStrength: number;
  125929. /**
  125930. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125931. * 1 means it completely occludes it
  125932. * 0 mean it has no impact
  125933. */
  125934. protected _ambientTextureImpactOnAnalyticalLights: number;
  125935. /**
  125936. * Stores the alpha values in a texture.
  125937. */
  125938. protected _opacityTexture: Nullable<BaseTexture>;
  125939. /**
  125940. * Stores the reflection values in a texture.
  125941. */
  125942. protected _reflectionTexture: Nullable<BaseTexture>;
  125943. /**
  125944. * Stores the emissive values in a texture.
  125945. */
  125946. protected _emissiveTexture: Nullable<BaseTexture>;
  125947. /**
  125948. * AKA Specular texture in other nomenclature.
  125949. */
  125950. protected _reflectivityTexture: Nullable<BaseTexture>;
  125951. /**
  125952. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125953. */
  125954. protected _metallicTexture: Nullable<BaseTexture>;
  125955. /**
  125956. * Specifies the metallic scalar of the metallic/roughness workflow.
  125957. * Can also be used to scale the metalness values of the metallic texture.
  125958. */
  125959. protected _metallic: Nullable<number>;
  125960. /**
  125961. * Specifies the roughness scalar of the metallic/roughness workflow.
  125962. * Can also be used to scale the roughness values of the metallic texture.
  125963. */
  125964. protected _roughness: Nullable<number>;
  125965. /**
  125966. * Specifies the an F0 factor to help configuring the material F0.
  125967. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125968. * to 0.5 the previously hard coded value stays the same.
  125969. * Can also be used to scale the F0 values of the metallic texture.
  125970. */
  125971. protected _metallicF0Factor: number;
  125972. /**
  125973. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125974. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125975. * your expectation as it multiplies with the texture data.
  125976. */
  125977. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125978. /**
  125979. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125980. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125981. */
  125982. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125983. /**
  125984. * Stores surface normal data used to displace a mesh in a texture.
  125985. */
  125986. protected _bumpTexture: Nullable<BaseTexture>;
  125987. /**
  125988. * Stores the pre-calculated light information of a mesh in a texture.
  125989. */
  125990. protected _lightmapTexture: Nullable<BaseTexture>;
  125991. /**
  125992. * The color of a material in ambient lighting.
  125993. */
  125994. protected _ambientColor: Color3;
  125995. /**
  125996. * AKA Diffuse Color in other nomenclature.
  125997. */
  125998. protected _albedoColor: Color3;
  125999. /**
  126000. * AKA Specular Color in other nomenclature.
  126001. */
  126002. protected _reflectivityColor: Color3;
  126003. /**
  126004. * The color applied when light is reflected from a material.
  126005. */
  126006. protected _reflectionColor: Color3;
  126007. /**
  126008. * The color applied when light is emitted from a material.
  126009. */
  126010. protected _emissiveColor: Color3;
  126011. /**
  126012. * AKA Glossiness in other nomenclature.
  126013. */
  126014. protected _microSurface: number;
  126015. /**
  126016. * Specifies that the material will use the light map as a show map.
  126017. */
  126018. protected _useLightmapAsShadowmap: boolean;
  126019. /**
  126020. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126021. * makes the reflect vector face the model (under horizon).
  126022. */
  126023. protected _useHorizonOcclusion: boolean;
  126024. /**
  126025. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126026. * too much the area relying on ambient texture to define their ambient occlusion.
  126027. */
  126028. protected _useRadianceOcclusion: boolean;
  126029. /**
  126030. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126031. */
  126032. protected _useAlphaFromAlbedoTexture: boolean;
  126033. /**
  126034. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126035. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126036. */
  126037. protected _useSpecularOverAlpha: boolean;
  126038. /**
  126039. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126040. */
  126041. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126042. /**
  126043. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126044. */
  126045. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126046. /**
  126047. * Specifies if the metallic texture contains the roughness information in its green channel.
  126048. */
  126049. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126050. /**
  126051. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126052. */
  126053. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126054. /**
  126055. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126056. */
  126057. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126058. /**
  126059. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126060. */
  126061. protected _useAmbientInGrayScale: boolean;
  126062. /**
  126063. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126064. * The material will try to infer what glossiness each pixel should be.
  126065. */
  126066. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126067. /**
  126068. * Defines the falloff type used in this material.
  126069. * It by default is Physical.
  126070. */
  126071. protected _lightFalloff: number;
  126072. /**
  126073. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126074. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126075. */
  126076. protected _useRadianceOverAlpha: boolean;
  126077. /**
  126078. * Allows using an object space normal map (instead of tangent space).
  126079. */
  126080. protected _useObjectSpaceNormalMap: boolean;
  126081. /**
  126082. * Allows using the bump map in parallax mode.
  126083. */
  126084. protected _useParallax: boolean;
  126085. /**
  126086. * Allows using the bump map in parallax occlusion mode.
  126087. */
  126088. protected _useParallaxOcclusion: boolean;
  126089. /**
  126090. * Controls the scale bias of the parallax mode.
  126091. */
  126092. protected _parallaxScaleBias: number;
  126093. /**
  126094. * If sets to true, disables all the lights affecting the material.
  126095. */
  126096. protected _disableLighting: boolean;
  126097. /**
  126098. * Number of Simultaneous lights allowed on the material.
  126099. */
  126100. protected _maxSimultaneousLights: number;
  126101. /**
  126102. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126103. */
  126104. protected _invertNormalMapX: boolean;
  126105. /**
  126106. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126107. */
  126108. protected _invertNormalMapY: boolean;
  126109. /**
  126110. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126111. */
  126112. protected _twoSidedLighting: boolean;
  126113. /**
  126114. * Defines the alpha limits in alpha test mode.
  126115. */
  126116. protected _alphaCutOff: number;
  126117. /**
  126118. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126119. */
  126120. protected _forceAlphaTest: boolean;
  126121. /**
  126122. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126123. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126124. */
  126125. protected _useAlphaFresnel: boolean;
  126126. /**
  126127. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126128. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126129. */
  126130. protected _useLinearAlphaFresnel: boolean;
  126131. /**
  126132. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126133. * from cos thetav and roughness:
  126134. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126135. */
  126136. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126137. /**
  126138. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126139. */
  126140. protected _forceIrradianceInFragment: boolean;
  126141. /**
  126142. * Force normal to face away from face.
  126143. */
  126144. protected _forceNormalForward: boolean;
  126145. /**
  126146. * Enables specular anti aliasing in the PBR shader.
  126147. * It will both interacts on the Geometry for analytical and IBL lighting.
  126148. * It also prefilter the roughness map based on the bump values.
  126149. */
  126150. protected _enableSpecularAntiAliasing: boolean;
  126151. /**
  126152. * Default configuration related to image processing available in the PBR Material.
  126153. */
  126154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126155. /**
  126156. * Keep track of the image processing observer to allow dispose and replace.
  126157. */
  126158. private _imageProcessingObserver;
  126159. /**
  126160. * Attaches a new image processing configuration to the PBR Material.
  126161. * @param configuration
  126162. */
  126163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126164. /**
  126165. * Stores the available render targets.
  126166. */
  126167. private _renderTargets;
  126168. /**
  126169. * Sets the global ambient color for the material used in lighting calculations.
  126170. */
  126171. private _globalAmbientColor;
  126172. /**
  126173. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126174. */
  126175. private _useLogarithmicDepth;
  126176. /**
  126177. * If set to true, no lighting calculations will be applied.
  126178. */
  126179. private _unlit;
  126180. private _debugMode;
  126181. /**
  126182. * @hidden
  126183. * This is reserved for the inspector.
  126184. * Defines the material debug mode.
  126185. * It helps seeing only some components of the material while troubleshooting.
  126186. */
  126187. debugMode: number;
  126188. /**
  126189. * @hidden
  126190. * This is reserved for the inspector.
  126191. * Specify from where on screen the debug mode should start.
  126192. * The value goes from -1 (full screen) to 1 (not visible)
  126193. * It helps with side by side comparison against the final render
  126194. * This defaults to -1
  126195. */
  126196. private debugLimit;
  126197. /**
  126198. * @hidden
  126199. * This is reserved for the inspector.
  126200. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126201. * You can use the factor to better multiply the final value.
  126202. */
  126203. private debugFactor;
  126204. /**
  126205. * Defines the clear coat layer parameters for the material.
  126206. */
  126207. readonly clearCoat: PBRClearCoatConfiguration;
  126208. /**
  126209. * Defines the anisotropic parameters for the material.
  126210. */
  126211. readonly anisotropy: PBRAnisotropicConfiguration;
  126212. /**
  126213. * Defines the BRDF parameters for the material.
  126214. */
  126215. readonly brdf: PBRBRDFConfiguration;
  126216. /**
  126217. * Defines the Sheen parameters for the material.
  126218. */
  126219. readonly sheen: PBRSheenConfiguration;
  126220. /**
  126221. * Defines the SubSurface parameters for the material.
  126222. */
  126223. readonly subSurface: PBRSubSurfaceConfiguration;
  126224. /**
  126225. * Custom callback helping to override the default shader used in the material.
  126226. */
  126227. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  126228. protected _rebuildInParallel: boolean;
  126229. /**
  126230. * Instantiates a new PBRMaterial instance.
  126231. *
  126232. * @param name The material name
  126233. * @param scene The scene the material will be use in.
  126234. */
  126235. constructor(name: string, scene: Scene);
  126236. /**
  126237. * Gets a boolean indicating that current material needs to register RTT
  126238. */
  126239. get hasRenderTargetTextures(): boolean;
  126240. /**
  126241. * Gets the name of the material class.
  126242. */
  126243. getClassName(): string;
  126244. /**
  126245. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126246. */
  126247. get useLogarithmicDepth(): boolean;
  126248. /**
  126249. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126250. */
  126251. set useLogarithmicDepth(value: boolean);
  126252. /**
  126253. * Returns true if alpha blending should be disabled.
  126254. */
  126255. protected get _disableAlphaBlending(): boolean;
  126256. /**
  126257. * Specifies whether or not this material should be rendered in alpha blend mode.
  126258. */
  126259. needAlphaBlending(): boolean;
  126260. /**
  126261. * Specifies whether or not this material should be rendered in alpha test mode.
  126262. */
  126263. needAlphaTesting(): boolean;
  126264. /**
  126265. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126266. */
  126267. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126268. /**
  126269. * Gets the texture used for the alpha test.
  126270. */
  126271. getAlphaTestTexture(): Nullable<BaseTexture>;
  126272. /**
  126273. * Specifies that the submesh is ready to be used.
  126274. * @param mesh - BJS mesh.
  126275. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126276. * @param useInstances - Specifies that instances should be used.
  126277. * @returns - boolean indicating that the submesh is ready or not.
  126278. */
  126279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126280. /**
  126281. * Specifies if the material uses metallic roughness workflow.
  126282. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126283. */
  126284. isMetallicWorkflow(): boolean;
  126285. private _prepareEffect;
  126286. private _prepareDefines;
  126287. /**
  126288. * Force shader compilation
  126289. */
  126290. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126291. /**
  126292. * Initializes the uniform buffer layout for the shader.
  126293. */
  126294. buildUniformLayout(): void;
  126295. /**
  126296. * Unbinds the material from the mesh
  126297. */
  126298. unbind(): void;
  126299. /**
  126300. * Binds the submesh data.
  126301. * @param world - The world matrix.
  126302. * @param mesh - The BJS mesh.
  126303. * @param subMesh - A submesh of the BJS mesh.
  126304. */
  126305. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126306. /**
  126307. * Returns the animatable textures.
  126308. * @returns - Array of animatable textures.
  126309. */
  126310. getAnimatables(): IAnimatable[];
  126311. /**
  126312. * Returns the texture used for reflections.
  126313. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126314. */
  126315. private _getReflectionTexture;
  126316. /**
  126317. * Returns an array of the actively used textures.
  126318. * @returns - Array of BaseTextures
  126319. */
  126320. getActiveTextures(): BaseTexture[];
  126321. /**
  126322. * Checks to see if a texture is used in the material.
  126323. * @param texture - Base texture to use.
  126324. * @returns - Boolean specifying if a texture is used in the material.
  126325. */
  126326. hasTexture(texture: BaseTexture): boolean;
  126327. /**
  126328. * Disposes the resources of the material.
  126329. * @param forceDisposeEffect - Forces the disposal of effects.
  126330. * @param forceDisposeTextures - Forces the disposal of all textures.
  126331. */
  126332. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126333. }
  126334. }
  126335. declare module BABYLON {
  126336. /**
  126337. * The Physically based material of BJS.
  126338. *
  126339. * This offers the main features of a standard PBR material.
  126340. * For more information, please refer to the documentation :
  126341. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126342. */
  126343. export class PBRMaterial extends PBRBaseMaterial {
  126344. /**
  126345. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126346. */
  126347. static readonly PBRMATERIAL_OPAQUE: number;
  126348. /**
  126349. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126350. */
  126351. static readonly PBRMATERIAL_ALPHATEST: number;
  126352. /**
  126353. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126354. */
  126355. static readonly PBRMATERIAL_ALPHABLEND: number;
  126356. /**
  126357. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126358. * They are also discarded below the alpha cutoff threshold to improve performances.
  126359. */
  126360. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126361. /**
  126362. * Defines the default value of how much AO map is occluding the analytical lights
  126363. * (point spot...).
  126364. */
  126365. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126366. /**
  126367. * Intensity of the direct lights e.g. the four lights available in your scene.
  126368. * This impacts both the direct diffuse and specular highlights.
  126369. */
  126370. directIntensity: number;
  126371. /**
  126372. * Intensity of the emissive part of the material.
  126373. * This helps controlling the emissive effect without modifying the emissive color.
  126374. */
  126375. emissiveIntensity: number;
  126376. /**
  126377. * Intensity of the environment e.g. how much the environment will light the object
  126378. * either through harmonics for rough material or through the refelction for shiny ones.
  126379. */
  126380. environmentIntensity: number;
  126381. /**
  126382. * This is a special control allowing the reduction of the specular highlights coming from the
  126383. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126384. */
  126385. specularIntensity: number;
  126386. /**
  126387. * Debug Control allowing disabling the bump map on this material.
  126388. */
  126389. disableBumpMap: boolean;
  126390. /**
  126391. * AKA Diffuse Texture in standard nomenclature.
  126392. */
  126393. albedoTexture: BaseTexture;
  126394. /**
  126395. * AKA Occlusion Texture in other nomenclature.
  126396. */
  126397. ambientTexture: BaseTexture;
  126398. /**
  126399. * AKA Occlusion Texture Intensity in other nomenclature.
  126400. */
  126401. ambientTextureStrength: number;
  126402. /**
  126403. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126404. * 1 means it completely occludes it
  126405. * 0 mean it has no impact
  126406. */
  126407. ambientTextureImpactOnAnalyticalLights: number;
  126408. /**
  126409. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126410. */
  126411. opacityTexture: BaseTexture;
  126412. /**
  126413. * Stores the reflection values in a texture.
  126414. */
  126415. reflectionTexture: Nullable<BaseTexture>;
  126416. /**
  126417. * Stores the emissive values in a texture.
  126418. */
  126419. emissiveTexture: BaseTexture;
  126420. /**
  126421. * AKA Specular texture in other nomenclature.
  126422. */
  126423. reflectivityTexture: BaseTexture;
  126424. /**
  126425. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126426. */
  126427. metallicTexture: BaseTexture;
  126428. /**
  126429. * Specifies the metallic scalar of the metallic/roughness workflow.
  126430. * Can also be used to scale the metalness values of the metallic texture.
  126431. */
  126432. metallic: Nullable<number>;
  126433. /**
  126434. * Specifies the roughness scalar of the metallic/roughness workflow.
  126435. * Can also be used to scale the roughness values of the metallic texture.
  126436. */
  126437. roughness: Nullable<number>;
  126438. /**
  126439. * Specifies the an F0 factor to help configuring the material F0.
  126440. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126441. * to 0.5 the previously hard coded value stays the same.
  126442. * Can also be used to scale the F0 values of the metallic texture.
  126443. */
  126444. metallicF0Factor: number;
  126445. /**
  126446. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126447. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126448. * your expectation as it multiplies with the texture data.
  126449. */
  126450. useMetallicF0FactorFromMetallicTexture: boolean;
  126451. /**
  126452. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126453. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126454. */
  126455. microSurfaceTexture: BaseTexture;
  126456. /**
  126457. * Stores surface normal data used to displace a mesh in a texture.
  126458. */
  126459. bumpTexture: BaseTexture;
  126460. /**
  126461. * Stores the pre-calculated light information of a mesh in a texture.
  126462. */
  126463. lightmapTexture: BaseTexture;
  126464. /**
  126465. * Stores the refracted light information in a texture.
  126466. */
  126467. get refractionTexture(): Nullable<BaseTexture>;
  126468. set refractionTexture(value: Nullable<BaseTexture>);
  126469. /**
  126470. * The color of a material in ambient lighting.
  126471. */
  126472. ambientColor: Color3;
  126473. /**
  126474. * AKA Diffuse Color in other nomenclature.
  126475. */
  126476. albedoColor: Color3;
  126477. /**
  126478. * AKA Specular Color in other nomenclature.
  126479. */
  126480. reflectivityColor: Color3;
  126481. /**
  126482. * The color reflected from the material.
  126483. */
  126484. reflectionColor: Color3;
  126485. /**
  126486. * The color emitted from the material.
  126487. */
  126488. emissiveColor: Color3;
  126489. /**
  126490. * AKA Glossiness in other nomenclature.
  126491. */
  126492. microSurface: number;
  126493. /**
  126494. * source material index of refraction (IOR)' / 'destination material IOR.
  126495. */
  126496. get indexOfRefraction(): number;
  126497. set indexOfRefraction(value: number);
  126498. /**
  126499. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126500. */
  126501. get invertRefractionY(): boolean;
  126502. set invertRefractionY(value: boolean);
  126503. /**
  126504. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126505. * Materials half opaque for instance using refraction could benefit from this control.
  126506. */
  126507. get linkRefractionWithTransparency(): boolean;
  126508. set linkRefractionWithTransparency(value: boolean);
  126509. /**
  126510. * If true, the light map contains occlusion information instead of lighting info.
  126511. */
  126512. useLightmapAsShadowmap: boolean;
  126513. /**
  126514. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126515. */
  126516. useAlphaFromAlbedoTexture: boolean;
  126517. /**
  126518. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126519. */
  126520. forceAlphaTest: boolean;
  126521. /**
  126522. * Defines the alpha limits in alpha test mode.
  126523. */
  126524. alphaCutOff: number;
  126525. /**
  126526. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126527. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126528. */
  126529. useSpecularOverAlpha: boolean;
  126530. /**
  126531. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126532. */
  126533. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126534. /**
  126535. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126536. */
  126537. useRoughnessFromMetallicTextureAlpha: boolean;
  126538. /**
  126539. * Specifies if the metallic texture contains the roughness information in its green channel.
  126540. */
  126541. useRoughnessFromMetallicTextureGreen: boolean;
  126542. /**
  126543. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126544. */
  126545. useMetallnessFromMetallicTextureBlue: boolean;
  126546. /**
  126547. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126548. */
  126549. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126550. /**
  126551. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126552. */
  126553. useAmbientInGrayScale: boolean;
  126554. /**
  126555. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126556. * The material will try to infer what glossiness each pixel should be.
  126557. */
  126558. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126559. /**
  126560. * BJS is using an harcoded light falloff based on a manually sets up range.
  126561. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126562. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126563. */
  126564. get usePhysicalLightFalloff(): boolean;
  126565. /**
  126566. * BJS is using an harcoded light falloff based on a manually sets up range.
  126567. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126568. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126569. */
  126570. set usePhysicalLightFalloff(value: boolean);
  126571. /**
  126572. * In order to support the falloff compatibility with gltf, a special mode has been added
  126573. * to reproduce the gltf light falloff.
  126574. */
  126575. get useGLTFLightFalloff(): boolean;
  126576. /**
  126577. * In order to support the falloff compatibility with gltf, a special mode has been added
  126578. * to reproduce the gltf light falloff.
  126579. */
  126580. set useGLTFLightFalloff(value: boolean);
  126581. /**
  126582. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126583. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126584. */
  126585. useRadianceOverAlpha: boolean;
  126586. /**
  126587. * Allows using an object space normal map (instead of tangent space).
  126588. */
  126589. useObjectSpaceNormalMap: boolean;
  126590. /**
  126591. * Allows using the bump map in parallax mode.
  126592. */
  126593. useParallax: boolean;
  126594. /**
  126595. * Allows using the bump map in parallax occlusion mode.
  126596. */
  126597. useParallaxOcclusion: boolean;
  126598. /**
  126599. * Controls the scale bias of the parallax mode.
  126600. */
  126601. parallaxScaleBias: number;
  126602. /**
  126603. * If sets to true, disables all the lights affecting the material.
  126604. */
  126605. disableLighting: boolean;
  126606. /**
  126607. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126608. */
  126609. forceIrradianceInFragment: boolean;
  126610. /**
  126611. * Number of Simultaneous lights allowed on the material.
  126612. */
  126613. maxSimultaneousLights: number;
  126614. /**
  126615. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126616. */
  126617. invertNormalMapX: boolean;
  126618. /**
  126619. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126620. */
  126621. invertNormalMapY: boolean;
  126622. /**
  126623. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126624. */
  126625. twoSidedLighting: boolean;
  126626. /**
  126627. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126628. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126629. */
  126630. useAlphaFresnel: boolean;
  126631. /**
  126632. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126633. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126634. */
  126635. useLinearAlphaFresnel: boolean;
  126636. /**
  126637. * Let user defines the brdf lookup texture used for IBL.
  126638. * A default 8bit version is embedded but you could point at :
  126639. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126640. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126641. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126642. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126643. */
  126644. environmentBRDFTexture: Nullable<BaseTexture>;
  126645. /**
  126646. * Force normal to face away from face.
  126647. */
  126648. forceNormalForward: boolean;
  126649. /**
  126650. * Enables specular anti aliasing in the PBR shader.
  126651. * It will both interacts on the Geometry for analytical and IBL lighting.
  126652. * It also prefilter the roughness map based on the bump values.
  126653. */
  126654. enableSpecularAntiAliasing: boolean;
  126655. /**
  126656. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126657. * makes the reflect vector face the model (under horizon).
  126658. */
  126659. useHorizonOcclusion: boolean;
  126660. /**
  126661. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126662. * too much the area relying on ambient texture to define their ambient occlusion.
  126663. */
  126664. useRadianceOcclusion: boolean;
  126665. /**
  126666. * If set to true, no lighting calculations will be applied.
  126667. */
  126668. unlit: boolean;
  126669. /**
  126670. * Gets the image processing configuration used either in this material.
  126671. */
  126672. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126673. /**
  126674. * Sets the Default image processing configuration used either in the this material.
  126675. *
  126676. * If sets to null, the scene one is in use.
  126677. */
  126678. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126679. /**
  126680. * Gets wether the color curves effect is enabled.
  126681. */
  126682. get cameraColorCurvesEnabled(): boolean;
  126683. /**
  126684. * Sets wether the color curves effect is enabled.
  126685. */
  126686. set cameraColorCurvesEnabled(value: boolean);
  126687. /**
  126688. * Gets wether the color grading effect is enabled.
  126689. */
  126690. get cameraColorGradingEnabled(): boolean;
  126691. /**
  126692. * Gets wether the color grading effect is enabled.
  126693. */
  126694. set cameraColorGradingEnabled(value: boolean);
  126695. /**
  126696. * Gets wether tonemapping is enabled or not.
  126697. */
  126698. get cameraToneMappingEnabled(): boolean;
  126699. /**
  126700. * Sets wether tonemapping is enabled or not
  126701. */
  126702. set cameraToneMappingEnabled(value: boolean);
  126703. /**
  126704. * The camera exposure used on this material.
  126705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126706. * This corresponds to a photographic exposure.
  126707. */
  126708. get cameraExposure(): number;
  126709. /**
  126710. * The camera exposure used on this material.
  126711. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126712. * This corresponds to a photographic exposure.
  126713. */
  126714. set cameraExposure(value: number);
  126715. /**
  126716. * Gets The camera contrast used on this material.
  126717. */
  126718. get cameraContrast(): number;
  126719. /**
  126720. * Sets The camera contrast used on this material.
  126721. */
  126722. set cameraContrast(value: number);
  126723. /**
  126724. * Gets the Color Grading 2D Lookup Texture.
  126725. */
  126726. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126727. /**
  126728. * Sets the Color Grading 2D Lookup Texture.
  126729. */
  126730. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126731. /**
  126732. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126733. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126734. * 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;
  126735. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126736. */
  126737. get cameraColorCurves(): Nullable<ColorCurves>;
  126738. /**
  126739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126741. * 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;
  126742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126743. */
  126744. set cameraColorCurves(value: Nullable<ColorCurves>);
  126745. /**
  126746. * Instantiates a new PBRMaterial instance.
  126747. *
  126748. * @param name The material name
  126749. * @param scene The scene the material will be use in.
  126750. */
  126751. constructor(name: string, scene: Scene);
  126752. /**
  126753. * Returns the name of this material class.
  126754. */
  126755. getClassName(): string;
  126756. /**
  126757. * Makes a duplicate of the current material.
  126758. * @param name - name to use for the new material.
  126759. */
  126760. clone(name: string): PBRMaterial;
  126761. /**
  126762. * Serializes this PBR Material.
  126763. * @returns - An object with the serialized material.
  126764. */
  126765. serialize(): any;
  126766. /**
  126767. * Parses a PBR Material from a serialized object.
  126768. * @param source - Serialized object.
  126769. * @param scene - BJS scene instance.
  126770. * @param rootUrl - url for the scene object
  126771. * @returns - PBRMaterial
  126772. */
  126773. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126774. }
  126775. }
  126776. declare module BABYLON {
  126777. /**
  126778. * Direct draw surface info
  126779. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126780. */
  126781. export interface DDSInfo {
  126782. /**
  126783. * Width of the texture
  126784. */
  126785. width: number;
  126786. /**
  126787. * Width of the texture
  126788. */
  126789. height: number;
  126790. /**
  126791. * Number of Mipmaps for the texture
  126792. * @see https://en.wikipedia.org/wiki/Mipmap
  126793. */
  126794. mipmapCount: number;
  126795. /**
  126796. * If the textures format is a known fourCC format
  126797. * @see https://www.fourcc.org/
  126798. */
  126799. isFourCC: boolean;
  126800. /**
  126801. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126802. */
  126803. isRGB: boolean;
  126804. /**
  126805. * If the texture is a lumincance format
  126806. */
  126807. isLuminance: boolean;
  126808. /**
  126809. * If this is a cube texture
  126810. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126811. */
  126812. isCube: boolean;
  126813. /**
  126814. * If the texture is a compressed format eg. FOURCC_DXT1
  126815. */
  126816. isCompressed: boolean;
  126817. /**
  126818. * The dxgiFormat of the texture
  126819. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126820. */
  126821. dxgiFormat: number;
  126822. /**
  126823. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126824. */
  126825. textureType: number;
  126826. /**
  126827. * Sphericle polynomial created for the dds texture
  126828. */
  126829. sphericalPolynomial?: SphericalPolynomial;
  126830. }
  126831. /**
  126832. * Class used to provide DDS decompression tools
  126833. */
  126834. export class DDSTools {
  126835. /**
  126836. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126837. */
  126838. static StoreLODInAlphaChannel: boolean;
  126839. /**
  126840. * Gets DDS information from an array buffer
  126841. * @param data defines the array buffer view to read data from
  126842. * @returns the DDS information
  126843. */
  126844. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126845. private static _FloatView;
  126846. private static _Int32View;
  126847. private static _ToHalfFloat;
  126848. private static _FromHalfFloat;
  126849. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126850. private static _GetHalfFloatRGBAArrayBuffer;
  126851. private static _GetFloatRGBAArrayBuffer;
  126852. private static _GetFloatAsUIntRGBAArrayBuffer;
  126853. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126854. private static _GetRGBAArrayBuffer;
  126855. private static _ExtractLongWordOrder;
  126856. private static _GetRGBArrayBuffer;
  126857. private static _GetLuminanceArrayBuffer;
  126858. /**
  126859. * Uploads DDS Levels to a Babylon Texture
  126860. * @hidden
  126861. */
  126862. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126863. }
  126864. interface ThinEngine {
  126865. /**
  126866. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126867. * @param rootUrl defines the url where the file to load is located
  126868. * @param scene defines the current scene
  126869. * @param lodScale defines scale to apply to the mip map selection
  126870. * @param lodOffset defines offset to apply to the mip map selection
  126871. * @param onLoad defines an optional callback raised when the texture is loaded
  126872. * @param onError defines an optional callback raised if there is an issue to load the texture
  126873. * @param format defines the format of the data
  126874. * @param forcedExtension defines the extension to use to pick the right loader
  126875. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126876. * @returns the cube texture as an InternalTexture
  126877. */
  126878. 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;
  126879. }
  126880. }
  126881. declare module BABYLON {
  126882. /**
  126883. * Implementation of the DDS Texture Loader.
  126884. * @hidden
  126885. */
  126886. export class _DDSTextureLoader implements IInternalTextureLoader {
  126887. /**
  126888. * Defines wether the loader supports cascade loading the different faces.
  126889. */
  126890. readonly supportCascades: boolean;
  126891. /**
  126892. * This returns if the loader support the current file information.
  126893. * @param extension defines the file extension of the file being loaded
  126894. * @returns true if the loader can load the specified file
  126895. */
  126896. canLoad(extension: string): boolean;
  126897. /**
  126898. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126899. * @param data contains the texture data
  126900. * @param texture defines the BabylonJS internal texture
  126901. * @param createPolynomials will be true if polynomials have been requested
  126902. * @param onLoad defines the callback to trigger once the texture is ready
  126903. * @param onError defines the callback to trigger in case of error
  126904. */
  126905. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126906. /**
  126907. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126908. * @param data contains the texture data
  126909. * @param texture defines the BabylonJS internal texture
  126910. * @param callback defines the method to call once ready to upload
  126911. */
  126912. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126913. }
  126914. }
  126915. declare module BABYLON {
  126916. /**
  126917. * Implementation of the ENV Texture Loader.
  126918. * @hidden
  126919. */
  126920. export class _ENVTextureLoader implements IInternalTextureLoader {
  126921. /**
  126922. * Defines wether the loader supports cascade loading the different faces.
  126923. */
  126924. readonly supportCascades: boolean;
  126925. /**
  126926. * This returns if the loader support the current file information.
  126927. * @param extension defines the file extension of the file being loaded
  126928. * @returns true if the loader can load the specified file
  126929. */
  126930. canLoad(extension: string): boolean;
  126931. /**
  126932. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126933. * @param data contains the texture data
  126934. * @param texture defines the BabylonJS internal texture
  126935. * @param createPolynomials will be true if polynomials have been requested
  126936. * @param onLoad defines the callback to trigger once the texture is ready
  126937. * @param onError defines the callback to trigger in case of error
  126938. */
  126939. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126940. /**
  126941. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126942. * @param data contains the texture data
  126943. * @param texture defines the BabylonJS internal texture
  126944. * @param callback defines the method to call once ready to upload
  126945. */
  126946. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126947. }
  126948. }
  126949. declare module BABYLON {
  126950. /**
  126951. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126952. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126953. */
  126954. export class KhronosTextureContainer {
  126955. /** contents of the KTX container file */
  126956. data: ArrayBufferView;
  126957. private static HEADER_LEN;
  126958. private static COMPRESSED_2D;
  126959. private static COMPRESSED_3D;
  126960. private static TEX_2D;
  126961. private static TEX_3D;
  126962. /**
  126963. * Gets the openGL type
  126964. */
  126965. glType: number;
  126966. /**
  126967. * Gets the openGL type size
  126968. */
  126969. glTypeSize: number;
  126970. /**
  126971. * Gets the openGL format
  126972. */
  126973. glFormat: number;
  126974. /**
  126975. * Gets the openGL internal format
  126976. */
  126977. glInternalFormat: number;
  126978. /**
  126979. * Gets the base internal format
  126980. */
  126981. glBaseInternalFormat: number;
  126982. /**
  126983. * Gets image width in pixel
  126984. */
  126985. pixelWidth: number;
  126986. /**
  126987. * Gets image height in pixel
  126988. */
  126989. pixelHeight: number;
  126990. /**
  126991. * Gets image depth in pixels
  126992. */
  126993. pixelDepth: number;
  126994. /**
  126995. * Gets the number of array elements
  126996. */
  126997. numberOfArrayElements: number;
  126998. /**
  126999. * Gets the number of faces
  127000. */
  127001. numberOfFaces: number;
  127002. /**
  127003. * Gets the number of mipmap levels
  127004. */
  127005. numberOfMipmapLevels: number;
  127006. /**
  127007. * Gets the bytes of key value data
  127008. */
  127009. bytesOfKeyValueData: number;
  127010. /**
  127011. * Gets the load type
  127012. */
  127013. loadType: number;
  127014. /**
  127015. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  127016. */
  127017. isInvalid: boolean;
  127018. /**
  127019. * Creates a new KhronosTextureContainer
  127020. * @param data contents of the KTX container file
  127021. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  127022. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  127023. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  127024. */
  127025. constructor(
  127026. /** contents of the KTX container file */
  127027. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  127028. /**
  127029. * Uploads KTX content to a Babylon Texture.
  127030. * It is assumed that the texture has already been created & is currently bound
  127031. * @hidden
  127032. */
  127033. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127034. private _upload2DCompressedLevels;
  127035. /**
  127036. * Checks if the given data starts with a KTX file identifier.
  127037. * @param data the data to check
  127038. * @returns true if the data is a KTX file or false otherwise
  127039. */
  127040. static IsValid(data: ArrayBufferView): boolean;
  127041. }
  127042. }
  127043. declare module BABYLON {
  127044. /**
  127045. * Class for loading KTX2 files
  127046. * !!! Experimental Extension Subject to Changes !!!
  127047. * @hidden
  127048. */
  127049. export class KhronosTextureContainer2 {
  127050. private static _ModulePromise;
  127051. private static _TranscodeFormat;
  127052. constructor(engine: ThinEngine);
  127053. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127054. private _determineTranscodeFormat;
  127055. /**
  127056. * Checks if the given data starts with a KTX2 file identifier.
  127057. * @param data the data to check
  127058. * @returns true if the data is a KTX2 file or false otherwise
  127059. */
  127060. static IsValid(data: ArrayBufferView): boolean;
  127061. }
  127062. }
  127063. declare module BABYLON {
  127064. /**
  127065. * Implementation of the KTX Texture Loader.
  127066. * @hidden
  127067. */
  127068. export class _KTXTextureLoader implements IInternalTextureLoader {
  127069. /**
  127070. * Defines wether the loader supports cascade loading the different faces.
  127071. */
  127072. readonly supportCascades: boolean;
  127073. /**
  127074. * This returns if the loader support the current file information.
  127075. * @param extension defines the file extension of the file being loaded
  127076. * @returns true if the loader can load the specified file
  127077. */
  127078. canLoad(extension: string): boolean;
  127079. /**
  127080. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127081. * @param data contains the texture data
  127082. * @param texture defines the BabylonJS internal texture
  127083. * @param createPolynomials will be true if polynomials have been requested
  127084. * @param onLoad defines the callback to trigger once the texture is ready
  127085. * @param onError defines the callback to trigger in case of error
  127086. */
  127087. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127088. /**
  127089. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127090. * @param data contains the texture data
  127091. * @param texture defines the BabylonJS internal texture
  127092. * @param callback defines the method to call once ready to upload
  127093. */
  127094. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127095. }
  127096. }
  127097. declare module BABYLON {
  127098. /** @hidden */
  127099. export var _forceSceneHelpersToBundle: boolean;
  127100. interface Scene {
  127101. /**
  127102. * Creates a default light for the scene.
  127103. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127104. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127105. */
  127106. createDefaultLight(replace?: boolean): void;
  127107. /**
  127108. * Creates a default camera for the scene.
  127109. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127110. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127111. * @param replace has default false, when true replaces the active camera in the scene
  127112. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127113. */
  127114. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127115. /**
  127116. * Creates a default camera and a default light.
  127117. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127118. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127119. * @param replace has the default false, when true replaces the active camera/light in the scene
  127120. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127121. */
  127122. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127123. /**
  127124. * Creates a new sky box
  127125. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127126. * @param environmentTexture defines the texture to use as environment texture
  127127. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127128. * @param scale defines the overall scale of the skybox
  127129. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127130. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127131. * @returns a new mesh holding the sky box
  127132. */
  127133. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127134. /**
  127135. * Creates a new environment
  127136. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127137. * @param options defines the options you can use to configure the environment
  127138. * @returns the new EnvironmentHelper
  127139. */
  127140. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127141. /**
  127142. * Creates a new VREXperienceHelper
  127143. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127144. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127145. * @returns a new VREXperienceHelper
  127146. */
  127147. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127148. /**
  127149. * Creates a new WebXRDefaultExperience
  127150. * @see http://doc.babylonjs.com/how_to/webxr
  127151. * @param options experience options
  127152. * @returns a promise for a new WebXRDefaultExperience
  127153. */
  127154. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127155. }
  127156. }
  127157. declare module BABYLON {
  127158. /**
  127159. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127160. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127161. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127162. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127163. */
  127164. export class VideoDome extends TransformNode {
  127165. /**
  127166. * Define the video source as a Monoscopic panoramic 360 video.
  127167. */
  127168. static readonly MODE_MONOSCOPIC: number;
  127169. /**
  127170. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127171. */
  127172. static readonly MODE_TOPBOTTOM: number;
  127173. /**
  127174. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127175. */
  127176. static readonly MODE_SIDEBYSIDE: number;
  127177. private _halfDome;
  127178. private _useDirectMapping;
  127179. /**
  127180. * The video texture being displayed on the sphere
  127181. */
  127182. protected _videoTexture: VideoTexture;
  127183. /**
  127184. * Gets the video texture being displayed on the sphere
  127185. */
  127186. get videoTexture(): VideoTexture;
  127187. /**
  127188. * The skybox material
  127189. */
  127190. protected _material: BackgroundMaterial;
  127191. /**
  127192. * The surface used for the skybox
  127193. */
  127194. protected _mesh: Mesh;
  127195. /**
  127196. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127197. */
  127198. private _halfDomeMask;
  127199. /**
  127200. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127201. * Also see the options.resolution property.
  127202. */
  127203. get fovMultiplier(): number;
  127204. set fovMultiplier(value: number);
  127205. private _videoMode;
  127206. /**
  127207. * Gets or set the current video mode for the video. It can be:
  127208. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127209. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127210. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127211. */
  127212. get videoMode(): number;
  127213. set videoMode(value: number);
  127214. /**
  127215. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127216. *
  127217. */
  127218. get halfDome(): boolean;
  127219. /**
  127220. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127221. */
  127222. set halfDome(enabled: boolean);
  127223. /**
  127224. * Oberserver used in Stereoscopic VR Mode.
  127225. */
  127226. private _onBeforeCameraRenderObserver;
  127227. /**
  127228. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127229. * @param name Element's name, child elements will append suffixes for their own names.
  127230. * @param urlsOrVideo defines the url(s) or the video element to use
  127231. * @param options An object containing optional or exposed sub element properties
  127232. */
  127233. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127234. resolution?: number;
  127235. clickToPlay?: boolean;
  127236. autoPlay?: boolean;
  127237. loop?: boolean;
  127238. size?: number;
  127239. poster?: string;
  127240. faceForward?: boolean;
  127241. useDirectMapping?: boolean;
  127242. halfDomeMode?: boolean;
  127243. }, scene: Scene);
  127244. private _changeVideoMode;
  127245. /**
  127246. * Releases resources associated with this node.
  127247. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127248. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127249. */
  127250. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127251. }
  127252. }
  127253. declare module BABYLON {
  127254. /**
  127255. * This class can be used to get instrumentation data from a Babylon engine
  127256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127257. */
  127258. export class EngineInstrumentation implements IDisposable {
  127259. /**
  127260. * Define the instrumented engine.
  127261. */
  127262. engine: Engine;
  127263. private _captureGPUFrameTime;
  127264. private _gpuFrameTimeToken;
  127265. private _gpuFrameTime;
  127266. private _captureShaderCompilationTime;
  127267. private _shaderCompilationTime;
  127268. private _onBeginFrameObserver;
  127269. private _onEndFrameObserver;
  127270. private _onBeforeShaderCompilationObserver;
  127271. private _onAfterShaderCompilationObserver;
  127272. /**
  127273. * Gets the perf counter used for GPU frame time
  127274. */
  127275. get gpuFrameTimeCounter(): PerfCounter;
  127276. /**
  127277. * Gets the GPU frame time capture status
  127278. */
  127279. get captureGPUFrameTime(): boolean;
  127280. /**
  127281. * Enable or disable the GPU frame time capture
  127282. */
  127283. set captureGPUFrameTime(value: boolean);
  127284. /**
  127285. * Gets the perf counter used for shader compilation time
  127286. */
  127287. get shaderCompilationTimeCounter(): PerfCounter;
  127288. /**
  127289. * Gets the shader compilation time capture status
  127290. */
  127291. get captureShaderCompilationTime(): boolean;
  127292. /**
  127293. * Enable or disable the shader compilation time capture
  127294. */
  127295. set captureShaderCompilationTime(value: boolean);
  127296. /**
  127297. * Instantiates a new engine instrumentation.
  127298. * This class can be used to get instrumentation data from a Babylon engine
  127299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127300. * @param engine Defines the engine to instrument
  127301. */
  127302. constructor(
  127303. /**
  127304. * Define the instrumented engine.
  127305. */
  127306. engine: Engine);
  127307. /**
  127308. * Dispose and release associated resources.
  127309. */
  127310. dispose(): void;
  127311. }
  127312. }
  127313. declare module BABYLON {
  127314. /**
  127315. * This class can be used to get instrumentation data from a Babylon engine
  127316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127317. */
  127318. export class SceneInstrumentation implements IDisposable {
  127319. /**
  127320. * Defines the scene to instrument
  127321. */
  127322. scene: Scene;
  127323. private _captureActiveMeshesEvaluationTime;
  127324. private _activeMeshesEvaluationTime;
  127325. private _captureRenderTargetsRenderTime;
  127326. private _renderTargetsRenderTime;
  127327. private _captureFrameTime;
  127328. private _frameTime;
  127329. private _captureRenderTime;
  127330. private _renderTime;
  127331. private _captureInterFrameTime;
  127332. private _interFrameTime;
  127333. private _captureParticlesRenderTime;
  127334. private _particlesRenderTime;
  127335. private _captureSpritesRenderTime;
  127336. private _spritesRenderTime;
  127337. private _capturePhysicsTime;
  127338. private _physicsTime;
  127339. private _captureAnimationsTime;
  127340. private _animationsTime;
  127341. private _captureCameraRenderTime;
  127342. private _cameraRenderTime;
  127343. private _onBeforeActiveMeshesEvaluationObserver;
  127344. private _onAfterActiveMeshesEvaluationObserver;
  127345. private _onBeforeRenderTargetsRenderObserver;
  127346. private _onAfterRenderTargetsRenderObserver;
  127347. private _onAfterRenderObserver;
  127348. private _onBeforeDrawPhaseObserver;
  127349. private _onAfterDrawPhaseObserver;
  127350. private _onBeforeAnimationsObserver;
  127351. private _onBeforeParticlesRenderingObserver;
  127352. private _onAfterParticlesRenderingObserver;
  127353. private _onBeforeSpritesRenderingObserver;
  127354. private _onAfterSpritesRenderingObserver;
  127355. private _onBeforePhysicsObserver;
  127356. private _onAfterPhysicsObserver;
  127357. private _onAfterAnimationsObserver;
  127358. private _onBeforeCameraRenderObserver;
  127359. private _onAfterCameraRenderObserver;
  127360. /**
  127361. * Gets the perf counter used for active meshes evaluation time
  127362. */
  127363. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127364. /**
  127365. * Gets the active meshes evaluation time capture status
  127366. */
  127367. get captureActiveMeshesEvaluationTime(): boolean;
  127368. /**
  127369. * Enable or disable the active meshes evaluation time capture
  127370. */
  127371. set captureActiveMeshesEvaluationTime(value: boolean);
  127372. /**
  127373. * Gets the perf counter used for render targets render time
  127374. */
  127375. get renderTargetsRenderTimeCounter(): PerfCounter;
  127376. /**
  127377. * Gets the render targets render time capture status
  127378. */
  127379. get captureRenderTargetsRenderTime(): boolean;
  127380. /**
  127381. * Enable or disable the render targets render time capture
  127382. */
  127383. set captureRenderTargetsRenderTime(value: boolean);
  127384. /**
  127385. * Gets the perf counter used for particles render time
  127386. */
  127387. get particlesRenderTimeCounter(): PerfCounter;
  127388. /**
  127389. * Gets the particles render time capture status
  127390. */
  127391. get captureParticlesRenderTime(): boolean;
  127392. /**
  127393. * Enable or disable the particles render time capture
  127394. */
  127395. set captureParticlesRenderTime(value: boolean);
  127396. /**
  127397. * Gets the perf counter used for sprites render time
  127398. */
  127399. get spritesRenderTimeCounter(): PerfCounter;
  127400. /**
  127401. * Gets the sprites render time capture status
  127402. */
  127403. get captureSpritesRenderTime(): boolean;
  127404. /**
  127405. * Enable or disable the sprites render time capture
  127406. */
  127407. set captureSpritesRenderTime(value: boolean);
  127408. /**
  127409. * Gets the perf counter used for physics time
  127410. */
  127411. get physicsTimeCounter(): PerfCounter;
  127412. /**
  127413. * Gets the physics time capture status
  127414. */
  127415. get capturePhysicsTime(): boolean;
  127416. /**
  127417. * Enable or disable the physics time capture
  127418. */
  127419. set capturePhysicsTime(value: boolean);
  127420. /**
  127421. * Gets the perf counter used for animations time
  127422. */
  127423. get animationsTimeCounter(): PerfCounter;
  127424. /**
  127425. * Gets the animations time capture status
  127426. */
  127427. get captureAnimationsTime(): boolean;
  127428. /**
  127429. * Enable or disable the animations time capture
  127430. */
  127431. set captureAnimationsTime(value: boolean);
  127432. /**
  127433. * Gets the perf counter used for frame time capture
  127434. */
  127435. get frameTimeCounter(): PerfCounter;
  127436. /**
  127437. * Gets the frame time capture status
  127438. */
  127439. get captureFrameTime(): boolean;
  127440. /**
  127441. * Enable or disable the frame time capture
  127442. */
  127443. set captureFrameTime(value: boolean);
  127444. /**
  127445. * Gets the perf counter used for inter-frames time capture
  127446. */
  127447. get interFrameTimeCounter(): PerfCounter;
  127448. /**
  127449. * Gets the inter-frames time capture status
  127450. */
  127451. get captureInterFrameTime(): boolean;
  127452. /**
  127453. * Enable or disable the inter-frames time capture
  127454. */
  127455. set captureInterFrameTime(value: boolean);
  127456. /**
  127457. * Gets the perf counter used for render time capture
  127458. */
  127459. get renderTimeCounter(): PerfCounter;
  127460. /**
  127461. * Gets the render time capture status
  127462. */
  127463. get captureRenderTime(): boolean;
  127464. /**
  127465. * Enable or disable the render time capture
  127466. */
  127467. set captureRenderTime(value: boolean);
  127468. /**
  127469. * Gets the perf counter used for camera render time capture
  127470. */
  127471. get cameraRenderTimeCounter(): PerfCounter;
  127472. /**
  127473. * Gets the camera render time capture status
  127474. */
  127475. get captureCameraRenderTime(): boolean;
  127476. /**
  127477. * Enable or disable the camera render time capture
  127478. */
  127479. set captureCameraRenderTime(value: boolean);
  127480. /**
  127481. * Gets the perf counter used for draw calls
  127482. */
  127483. get drawCallsCounter(): PerfCounter;
  127484. /**
  127485. * Instantiates a new scene instrumentation.
  127486. * This class can be used to get instrumentation data from a Babylon engine
  127487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127488. * @param scene Defines the scene to instrument
  127489. */
  127490. constructor(
  127491. /**
  127492. * Defines the scene to instrument
  127493. */
  127494. scene: Scene);
  127495. /**
  127496. * Dispose and release associated resources.
  127497. */
  127498. dispose(): void;
  127499. }
  127500. }
  127501. declare module BABYLON {
  127502. /** @hidden */
  127503. export var glowMapGenerationPixelShader: {
  127504. name: string;
  127505. shader: string;
  127506. };
  127507. }
  127508. declare module BABYLON {
  127509. /** @hidden */
  127510. export var glowMapGenerationVertexShader: {
  127511. name: string;
  127512. shader: string;
  127513. };
  127514. }
  127515. declare module BABYLON {
  127516. /**
  127517. * Effect layer options. This helps customizing the behaviour
  127518. * of the effect layer.
  127519. */
  127520. export interface IEffectLayerOptions {
  127521. /**
  127522. * Multiplication factor apply to the canvas size to compute the render target size
  127523. * used to generated the objects (the smaller the faster).
  127524. */
  127525. mainTextureRatio: number;
  127526. /**
  127527. * Enforces a fixed size texture to ensure effect stability across devices.
  127528. */
  127529. mainTextureFixedSize?: number;
  127530. /**
  127531. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127532. */
  127533. alphaBlendingMode: number;
  127534. /**
  127535. * The camera attached to the layer.
  127536. */
  127537. camera: Nullable<Camera>;
  127538. /**
  127539. * The rendering group to draw the layer in.
  127540. */
  127541. renderingGroupId: number;
  127542. }
  127543. /**
  127544. * The effect layer Helps adding post process effect blended with the main pass.
  127545. *
  127546. * This can be for instance use to generate glow or higlight effects on the scene.
  127547. *
  127548. * The effect layer class can not be used directly and is intented to inherited from to be
  127549. * customized per effects.
  127550. */
  127551. export abstract class EffectLayer {
  127552. private _vertexBuffers;
  127553. private _indexBuffer;
  127554. private _cachedDefines;
  127555. private _effectLayerMapGenerationEffect;
  127556. private _effectLayerOptions;
  127557. private _mergeEffect;
  127558. protected _scene: Scene;
  127559. protected _engine: Engine;
  127560. protected _maxSize: number;
  127561. protected _mainTextureDesiredSize: ISize;
  127562. protected _mainTexture: RenderTargetTexture;
  127563. protected _shouldRender: boolean;
  127564. protected _postProcesses: PostProcess[];
  127565. protected _textures: BaseTexture[];
  127566. protected _emissiveTextureAndColor: {
  127567. texture: Nullable<BaseTexture>;
  127568. color: Color4;
  127569. };
  127570. /**
  127571. * The name of the layer
  127572. */
  127573. name: string;
  127574. /**
  127575. * The clear color of the texture used to generate the glow map.
  127576. */
  127577. neutralColor: Color4;
  127578. /**
  127579. * Specifies whether the highlight layer is enabled or not.
  127580. */
  127581. isEnabled: boolean;
  127582. /**
  127583. * Gets the camera attached to the layer.
  127584. */
  127585. get camera(): Nullable<Camera>;
  127586. /**
  127587. * Gets the rendering group id the layer should render in.
  127588. */
  127589. get renderingGroupId(): number;
  127590. set renderingGroupId(renderingGroupId: number);
  127591. /**
  127592. * An event triggered when the effect layer has been disposed.
  127593. */
  127594. onDisposeObservable: Observable<EffectLayer>;
  127595. /**
  127596. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127597. */
  127598. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127599. /**
  127600. * An event triggered when the generated texture is being merged in the scene.
  127601. */
  127602. onBeforeComposeObservable: Observable<EffectLayer>;
  127603. /**
  127604. * An event triggered when the mesh is rendered into the effect render target.
  127605. */
  127606. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127607. /**
  127608. * An event triggered after the mesh has been rendered into the effect render target.
  127609. */
  127610. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127611. /**
  127612. * An event triggered when the generated texture has been merged in the scene.
  127613. */
  127614. onAfterComposeObservable: Observable<EffectLayer>;
  127615. /**
  127616. * An event triggered when the efffect layer changes its size.
  127617. */
  127618. onSizeChangedObservable: Observable<EffectLayer>;
  127619. /** @hidden */
  127620. static _SceneComponentInitialization: (scene: Scene) => void;
  127621. /**
  127622. * Instantiates a new effect Layer and references it in the scene.
  127623. * @param name The name of the layer
  127624. * @param scene The scene to use the layer in
  127625. */
  127626. constructor(
  127627. /** The Friendly of the effect in the scene */
  127628. name: string, scene: Scene);
  127629. /**
  127630. * Get the effect name of the layer.
  127631. * @return The effect name
  127632. */
  127633. abstract getEffectName(): string;
  127634. /**
  127635. * Checks for the readiness of the element composing the layer.
  127636. * @param subMesh the mesh to check for
  127637. * @param useInstances specify whether or not to use instances to render the mesh
  127638. * @return true if ready otherwise, false
  127639. */
  127640. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127641. /**
  127642. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127643. * @returns true if the effect requires stencil during the main canvas render pass.
  127644. */
  127645. abstract needStencil(): boolean;
  127646. /**
  127647. * Create the merge effect. This is the shader use to blit the information back
  127648. * to the main canvas at the end of the scene rendering.
  127649. * @returns The effect containing the shader used to merge the effect on the main canvas
  127650. */
  127651. protected abstract _createMergeEffect(): Effect;
  127652. /**
  127653. * Creates the render target textures and post processes used in the effect layer.
  127654. */
  127655. protected abstract _createTextureAndPostProcesses(): void;
  127656. /**
  127657. * Implementation specific of rendering the generating effect on the main canvas.
  127658. * @param effect The effect used to render through
  127659. */
  127660. protected abstract _internalRender(effect: Effect): void;
  127661. /**
  127662. * Sets the required values for both the emissive texture and and the main color.
  127663. */
  127664. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127665. /**
  127666. * Free any resources and references associated to a mesh.
  127667. * Internal use
  127668. * @param mesh The mesh to free.
  127669. */
  127670. abstract _disposeMesh(mesh: Mesh): void;
  127671. /**
  127672. * Serializes this layer (Glow or Highlight for example)
  127673. * @returns a serialized layer object
  127674. */
  127675. abstract serialize?(): any;
  127676. /**
  127677. * Initializes the effect layer with the required options.
  127678. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127679. */
  127680. protected _init(options: Partial<IEffectLayerOptions>): void;
  127681. /**
  127682. * Generates the index buffer of the full screen quad blending to the main canvas.
  127683. */
  127684. private _generateIndexBuffer;
  127685. /**
  127686. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127687. */
  127688. private _generateVertexBuffer;
  127689. /**
  127690. * Sets the main texture desired size which is the closest power of two
  127691. * of the engine canvas size.
  127692. */
  127693. private _setMainTextureSize;
  127694. /**
  127695. * Creates the main texture for the effect layer.
  127696. */
  127697. protected _createMainTexture(): void;
  127698. /**
  127699. * Adds specific effects defines.
  127700. * @param defines The defines to add specifics to.
  127701. */
  127702. protected _addCustomEffectDefines(defines: string[]): void;
  127703. /**
  127704. * Checks for the readiness of the element composing the layer.
  127705. * @param subMesh the mesh to check for
  127706. * @param useInstances specify whether or not to use instances to render the mesh
  127707. * @param emissiveTexture the associated emissive texture used to generate the glow
  127708. * @return true if ready otherwise, false
  127709. */
  127710. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127711. /**
  127712. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127713. */
  127714. render(): void;
  127715. /**
  127716. * Determine if a given mesh will be used in the current effect.
  127717. * @param mesh mesh to test
  127718. * @returns true if the mesh will be used
  127719. */
  127720. hasMesh(mesh: AbstractMesh): boolean;
  127721. /**
  127722. * Returns true if the layer contains information to display, otherwise false.
  127723. * @returns true if the glow layer should be rendered
  127724. */
  127725. shouldRender(): boolean;
  127726. /**
  127727. * Returns true if the mesh should render, otherwise false.
  127728. * @param mesh The mesh to render
  127729. * @returns true if it should render otherwise false
  127730. */
  127731. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127732. /**
  127733. * Returns true if the mesh can be rendered, otherwise false.
  127734. * @param mesh The mesh to render
  127735. * @param material The material used on the mesh
  127736. * @returns true if it can be rendered otherwise false
  127737. */
  127738. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127739. /**
  127740. * Returns true if the mesh should render, otherwise false.
  127741. * @param mesh The mesh to render
  127742. * @returns true if it should render otherwise false
  127743. */
  127744. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127745. /**
  127746. * Renders the submesh passed in parameter to the generation map.
  127747. */
  127748. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127749. /**
  127750. * Defines whether the current material of the mesh should be use to render the effect.
  127751. * @param mesh defines the current mesh to render
  127752. */
  127753. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127754. /**
  127755. * Rebuild the required buffers.
  127756. * @hidden Internal use only.
  127757. */
  127758. _rebuild(): void;
  127759. /**
  127760. * Dispose only the render target textures and post process.
  127761. */
  127762. private _disposeTextureAndPostProcesses;
  127763. /**
  127764. * Dispose the highlight layer and free resources.
  127765. */
  127766. dispose(): void;
  127767. /**
  127768. * Gets the class name of the effect layer
  127769. * @returns the string with the class name of the effect layer
  127770. */
  127771. getClassName(): string;
  127772. /**
  127773. * Creates an effect layer from parsed effect layer data
  127774. * @param parsedEffectLayer defines effect layer data
  127775. * @param scene defines the current scene
  127776. * @param rootUrl defines the root URL containing the effect layer information
  127777. * @returns a parsed effect Layer
  127778. */
  127779. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127780. }
  127781. }
  127782. declare module BABYLON {
  127783. interface AbstractScene {
  127784. /**
  127785. * The list of effect layers (highlights/glow) added to the scene
  127786. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127787. * @see http://doc.babylonjs.com/how_to/glow_layer
  127788. */
  127789. effectLayers: Array<EffectLayer>;
  127790. /**
  127791. * Removes the given effect layer from this scene.
  127792. * @param toRemove defines the effect layer to remove
  127793. * @returns the index of the removed effect layer
  127794. */
  127795. removeEffectLayer(toRemove: EffectLayer): number;
  127796. /**
  127797. * Adds the given effect layer to this scene
  127798. * @param newEffectLayer defines the effect layer to add
  127799. */
  127800. addEffectLayer(newEffectLayer: EffectLayer): void;
  127801. }
  127802. /**
  127803. * Defines the layer scene component responsible to manage any effect layers
  127804. * in a given scene.
  127805. */
  127806. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127807. /**
  127808. * The component name helpfull to identify the component in the list of scene components.
  127809. */
  127810. readonly name: string;
  127811. /**
  127812. * The scene the component belongs to.
  127813. */
  127814. scene: Scene;
  127815. private _engine;
  127816. private _renderEffects;
  127817. private _needStencil;
  127818. private _previousStencilState;
  127819. /**
  127820. * Creates a new instance of the component for the given scene
  127821. * @param scene Defines the scene to register the component in
  127822. */
  127823. constructor(scene: Scene);
  127824. /**
  127825. * Registers the component in a given scene
  127826. */
  127827. register(): void;
  127828. /**
  127829. * Rebuilds the elements related to this component in case of
  127830. * context lost for instance.
  127831. */
  127832. rebuild(): void;
  127833. /**
  127834. * Serializes the component data to the specified json object
  127835. * @param serializationObject The object to serialize to
  127836. */
  127837. serialize(serializationObject: any): void;
  127838. /**
  127839. * Adds all the elements from the container to the scene
  127840. * @param container the container holding the elements
  127841. */
  127842. addFromContainer(container: AbstractScene): void;
  127843. /**
  127844. * Removes all the elements in the container from the scene
  127845. * @param container contains the elements to remove
  127846. * @param dispose if the removed element should be disposed (default: false)
  127847. */
  127848. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127849. /**
  127850. * Disposes the component and the associated ressources.
  127851. */
  127852. dispose(): void;
  127853. private _isReadyForMesh;
  127854. private _renderMainTexture;
  127855. private _setStencil;
  127856. private _setStencilBack;
  127857. private _draw;
  127858. private _drawCamera;
  127859. private _drawRenderingGroup;
  127860. }
  127861. }
  127862. declare module BABYLON {
  127863. /** @hidden */
  127864. export var glowMapMergePixelShader: {
  127865. name: string;
  127866. shader: string;
  127867. };
  127868. }
  127869. declare module BABYLON {
  127870. /** @hidden */
  127871. export var glowMapMergeVertexShader: {
  127872. name: string;
  127873. shader: string;
  127874. };
  127875. }
  127876. declare module BABYLON {
  127877. interface AbstractScene {
  127878. /**
  127879. * Return a the first highlight layer of the scene with a given name.
  127880. * @param name The name of the highlight layer to look for.
  127881. * @return The highlight layer if found otherwise null.
  127882. */
  127883. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127884. }
  127885. /**
  127886. * Glow layer options. This helps customizing the behaviour
  127887. * of the glow layer.
  127888. */
  127889. export interface IGlowLayerOptions {
  127890. /**
  127891. * Multiplication factor apply to the canvas size to compute the render target size
  127892. * used to generated the glowing objects (the smaller the faster).
  127893. */
  127894. mainTextureRatio: number;
  127895. /**
  127896. * Enforces a fixed size texture to ensure resize independant blur.
  127897. */
  127898. mainTextureFixedSize?: number;
  127899. /**
  127900. * How big is the kernel of the blur texture.
  127901. */
  127902. blurKernelSize: number;
  127903. /**
  127904. * The camera attached to the layer.
  127905. */
  127906. camera: Nullable<Camera>;
  127907. /**
  127908. * Enable MSAA by chosing the number of samples.
  127909. */
  127910. mainTextureSamples?: number;
  127911. /**
  127912. * The rendering group to draw the layer in.
  127913. */
  127914. renderingGroupId: number;
  127915. }
  127916. /**
  127917. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127918. *
  127919. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127920. *
  127921. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127922. */
  127923. export class GlowLayer extends EffectLayer {
  127924. /**
  127925. * Effect Name of the layer.
  127926. */
  127927. static readonly EffectName: string;
  127928. /**
  127929. * The default blur kernel size used for the glow.
  127930. */
  127931. static DefaultBlurKernelSize: number;
  127932. /**
  127933. * The default texture size ratio used for the glow.
  127934. */
  127935. static DefaultTextureRatio: number;
  127936. /**
  127937. * Sets the kernel size of the blur.
  127938. */
  127939. set blurKernelSize(value: number);
  127940. /**
  127941. * Gets the kernel size of the blur.
  127942. */
  127943. get blurKernelSize(): number;
  127944. /**
  127945. * Sets the glow intensity.
  127946. */
  127947. set intensity(value: number);
  127948. /**
  127949. * Gets the glow intensity.
  127950. */
  127951. get intensity(): number;
  127952. private _options;
  127953. private _intensity;
  127954. private _horizontalBlurPostprocess1;
  127955. private _verticalBlurPostprocess1;
  127956. private _horizontalBlurPostprocess2;
  127957. private _verticalBlurPostprocess2;
  127958. private _blurTexture1;
  127959. private _blurTexture2;
  127960. private _postProcesses1;
  127961. private _postProcesses2;
  127962. private _includedOnlyMeshes;
  127963. private _excludedMeshes;
  127964. private _meshesUsingTheirOwnMaterials;
  127965. /**
  127966. * Callback used to let the user override the color selection on a per mesh basis
  127967. */
  127968. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127969. /**
  127970. * Callback used to let the user override the texture selection on a per mesh basis
  127971. */
  127972. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127973. /**
  127974. * Instantiates a new glow Layer and references it to the scene.
  127975. * @param name The name of the layer
  127976. * @param scene The scene to use the layer in
  127977. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127978. */
  127979. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127980. /**
  127981. * Get the effect name of the layer.
  127982. * @return The effect name
  127983. */
  127984. getEffectName(): string;
  127985. /**
  127986. * Create the merge effect. This is the shader use to blit the information back
  127987. * to the main canvas at the end of the scene rendering.
  127988. */
  127989. protected _createMergeEffect(): Effect;
  127990. /**
  127991. * Creates the render target textures and post processes used in the glow layer.
  127992. */
  127993. protected _createTextureAndPostProcesses(): void;
  127994. /**
  127995. * Checks for the readiness of the element composing the layer.
  127996. * @param subMesh the mesh to check for
  127997. * @param useInstances specify wether or not to use instances to render the mesh
  127998. * @param emissiveTexture the associated emissive texture used to generate the glow
  127999. * @return true if ready otherwise, false
  128000. */
  128001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128002. /**
  128003. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  128004. */
  128005. needStencil(): boolean;
  128006. /**
  128007. * Returns true if the mesh can be rendered, otherwise false.
  128008. * @param mesh The mesh to render
  128009. * @param material The material used on the mesh
  128010. * @returns true if it can be rendered otherwise false
  128011. */
  128012. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  128013. /**
  128014. * Implementation specific of rendering the generating effect on the main canvas.
  128015. * @param effect The effect used to render through
  128016. */
  128017. protected _internalRender(effect: Effect): void;
  128018. /**
  128019. * Sets the required values for both the emissive texture and and the main color.
  128020. */
  128021. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128022. /**
  128023. * Returns true if the mesh should render, otherwise false.
  128024. * @param mesh The mesh to render
  128025. * @returns true if it should render otherwise false
  128026. */
  128027. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128028. /**
  128029. * Adds specific effects defines.
  128030. * @param defines The defines to add specifics to.
  128031. */
  128032. protected _addCustomEffectDefines(defines: string[]): void;
  128033. /**
  128034. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128035. * @param mesh The mesh to exclude from the glow layer
  128036. */
  128037. addExcludedMesh(mesh: Mesh): void;
  128038. /**
  128039. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128040. * @param mesh The mesh to remove
  128041. */
  128042. removeExcludedMesh(mesh: Mesh): void;
  128043. /**
  128044. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128045. * @param mesh The mesh to include in the glow layer
  128046. */
  128047. addIncludedOnlyMesh(mesh: Mesh): void;
  128048. /**
  128049. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128050. * @param mesh The mesh to remove
  128051. */
  128052. removeIncludedOnlyMesh(mesh: Mesh): void;
  128053. /**
  128054. * Determine if a given mesh will be used in the glow layer
  128055. * @param mesh The mesh to test
  128056. * @returns true if the mesh will be highlighted by the current glow layer
  128057. */
  128058. hasMesh(mesh: AbstractMesh): boolean;
  128059. /**
  128060. * Defines whether the current material of the mesh should be use to render the effect.
  128061. * @param mesh defines the current mesh to render
  128062. */
  128063. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128064. /**
  128065. * Add a mesh to be rendered through its own material and not with emissive only.
  128066. * @param mesh The mesh for which we need to use its material
  128067. */
  128068. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128069. /**
  128070. * Remove a mesh from being rendered through its own material and not with emissive only.
  128071. * @param mesh The mesh for which we need to not use its material
  128072. */
  128073. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128074. /**
  128075. * Free any resources and references associated to a mesh.
  128076. * Internal use
  128077. * @param mesh The mesh to free.
  128078. * @hidden
  128079. */
  128080. _disposeMesh(mesh: Mesh): void;
  128081. /**
  128082. * Gets the class name of the effect layer
  128083. * @returns the string with the class name of the effect layer
  128084. */
  128085. getClassName(): string;
  128086. /**
  128087. * Serializes this glow layer
  128088. * @returns a serialized glow layer object
  128089. */
  128090. serialize(): any;
  128091. /**
  128092. * Creates a Glow Layer from parsed glow layer data
  128093. * @param parsedGlowLayer defines glow layer data
  128094. * @param scene defines the current scene
  128095. * @param rootUrl defines the root URL containing the glow layer information
  128096. * @returns a parsed Glow Layer
  128097. */
  128098. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128099. }
  128100. }
  128101. declare module BABYLON {
  128102. /** @hidden */
  128103. export var glowBlurPostProcessPixelShader: {
  128104. name: string;
  128105. shader: string;
  128106. };
  128107. }
  128108. declare module BABYLON {
  128109. interface AbstractScene {
  128110. /**
  128111. * Return a the first highlight layer of the scene with a given name.
  128112. * @param name The name of the highlight layer to look for.
  128113. * @return The highlight layer if found otherwise null.
  128114. */
  128115. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128116. }
  128117. /**
  128118. * Highlight layer options. This helps customizing the behaviour
  128119. * of the highlight layer.
  128120. */
  128121. export interface IHighlightLayerOptions {
  128122. /**
  128123. * Multiplication factor apply to the canvas size to compute the render target size
  128124. * used to generated the glowing objects (the smaller the faster).
  128125. */
  128126. mainTextureRatio: number;
  128127. /**
  128128. * Enforces a fixed size texture to ensure resize independant blur.
  128129. */
  128130. mainTextureFixedSize?: number;
  128131. /**
  128132. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128133. * of the picture to blur (the smaller the faster).
  128134. */
  128135. blurTextureSizeRatio: number;
  128136. /**
  128137. * How big in texel of the blur texture is the vertical blur.
  128138. */
  128139. blurVerticalSize: number;
  128140. /**
  128141. * How big in texel of the blur texture is the horizontal blur.
  128142. */
  128143. blurHorizontalSize: number;
  128144. /**
  128145. * Alpha blending mode used to apply the blur. Default is combine.
  128146. */
  128147. alphaBlendingMode: number;
  128148. /**
  128149. * The camera attached to the layer.
  128150. */
  128151. camera: Nullable<Camera>;
  128152. /**
  128153. * Should we display highlight as a solid stroke?
  128154. */
  128155. isStroke?: boolean;
  128156. /**
  128157. * The rendering group to draw the layer in.
  128158. */
  128159. renderingGroupId: number;
  128160. }
  128161. /**
  128162. * The highlight layer Helps adding a glow effect around a mesh.
  128163. *
  128164. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128165. * glowy meshes to your scene.
  128166. *
  128167. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128168. */
  128169. export class HighlightLayer extends EffectLayer {
  128170. name: string;
  128171. /**
  128172. * Effect Name of the highlight layer.
  128173. */
  128174. static readonly EffectName: string;
  128175. /**
  128176. * The neutral color used during the preparation of the glow effect.
  128177. * This is black by default as the blend operation is a blend operation.
  128178. */
  128179. static NeutralColor: Color4;
  128180. /**
  128181. * Stencil value used for glowing meshes.
  128182. */
  128183. static GlowingMeshStencilReference: number;
  128184. /**
  128185. * Stencil value used for the other meshes in the scene.
  128186. */
  128187. static NormalMeshStencilReference: number;
  128188. /**
  128189. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128190. */
  128191. innerGlow: boolean;
  128192. /**
  128193. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128194. */
  128195. outerGlow: boolean;
  128196. /**
  128197. * Specifies the horizontal size of the blur.
  128198. */
  128199. set blurHorizontalSize(value: number);
  128200. /**
  128201. * Specifies the vertical size of the blur.
  128202. */
  128203. set blurVerticalSize(value: number);
  128204. /**
  128205. * Gets the horizontal size of the blur.
  128206. */
  128207. get blurHorizontalSize(): number;
  128208. /**
  128209. * Gets the vertical size of the blur.
  128210. */
  128211. get blurVerticalSize(): number;
  128212. /**
  128213. * An event triggered when the highlight layer is being blurred.
  128214. */
  128215. onBeforeBlurObservable: Observable<HighlightLayer>;
  128216. /**
  128217. * An event triggered when the highlight layer has been blurred.
  128218. */
  128219. onAfterBlurObservable: Observable<HighlightLayer>;
  128220. private _instanceGlowingMeshStencilReference;
  128221. private _options;
  128222. private _downSamplePostprocess;
  128223. private _horizontalBlurPostprocess;
  128224. private _verticalBlurPostprocess;
  128225. private _blurTexture;
  128226. private _meshes;
  128227. private _excludedMeshes;
  128228. /**
  128229. * Instantiates a new highlight Layer and references it to the scene..
  128230. * @param name The name of the layer
  128231. * @param scene The scene to use the layer in
  128232. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128233. */
  128234. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128235. /**
  128236. * Get the effect name of the layer.
  128237. * @return The effect name
  128238. */
  128239. getEffectName(): string;
  128240. /**
  128241. * Create the merge effect. This is the shader use to blit the information back
  128242. * to the main canvas at the end of the scene rendering.
  128243. */
  128244. protected _createMergeEffect(): Effect;
  128245. /**
  128246. * Creates the render target textures and post processes used in the highlight layer.
  128247. */
  128248. protected _createTextureAndPostProcesses(): void;
  128249. /**
  128250. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128251. */
  128252. needStencil(): boolean;
  128253. /**
  128254. * Checks for the readiness of the element composing the layer.
  128255. * @param subMesh the mesh to check for
  128256. * @param useInstances specify wether or not to use instances to render the mesh
  128257. * @param emissiveTexture the associated emissive texture used to generate the glow
  128258. * @return true if ready otherwise, false
  128259. */
  128260. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128261. /**
  128262. * Implementation specific of rendering the generating effect on the main canvas.
  128263. * @param effect The effect used to render through
  128264. */
  128265. protected _internalRender(effect: Effect): void;
  128266. /**
  128267. * Returns true if the layer contains information to display, otherwise false.
  128268. */
  128269. shouldRender(): boolean;
  128270. /**
  128271. * Returns true if the mesh should render, otherwise false.
  128272. * @param mesh The mesh to render
  128273. * @returns true if it should render otherwise false
  128274. */
  128275. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128276. /**
  128277. * Adds specific effects defines.
  128278. * @param defines The defines to add specifics to.
  128279. */
  128280. protected _addCustomEffectDefines(defines: string[]): void;
  128281. /**
  128282. * Sets the required values for both the emissive texture and and the main color.
  128283. */
  128284. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128285. /**
  128286. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128287. * @param mesh The mesh to exclude from the highlight layer
  128288. */
  128289. addExcludedMesh(mesh: Mesh): void;
  128290. /**
  128291. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128292. * @param mesh The mesh to highlight
  128293. */
  128294. removeExcludedMesh(mesh: Mesh): void;
  128295. /**
  128296. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128297. * @param mesh mesh to test
  128298. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128299. */
  128300. hasMesh(mesh: AbstractMesh): boolean;
  128301. /**
  128302. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128303. * @param mesh The mesh to highlight
  128304. * @param color The color of the highlight
  128305. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128306. */
  128307. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128308. /**
  128309. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128310. * @param mesh The mesh to highlight
  128311. */
  128312. removeMesh(mesh: Mesh): void;
  128313. /**
  128314. * Remove all the meshes currently referenced in the highlight layer
  128315. */
  128316. removeAllMeshes(): void;
  128317. /**
  128318. * Force the stencil to the normal expected value for none glowing parts
  128319. */
  128320. private _defaultStencilReference;
  128321. /**
  128322. * Free any resources and references associated to a mesh.
  128323. * Internal use
  128324. * @param mesh The mesh to free.
  128325. * @hidden
  128326. */
  128327. _disposeMesh(mesh: Mesh): void;
  128328. /**
  128329. * Dispose the highlight layer and free resources.
  128330. */
  128331. dispose(): void;
  128332. /**
  128333. * Gets the class name of the effect layer
  128334. * @returns the string with the class name of the effect layer
  128335. */
  128336. getClassName(): string;
  128337. /**
  128338. * Serializes this Highlight layer
  128339. * @returns a serialized Highlight layer object
  128340. */
  128341. serialize(): any;
  128342. /**
  128343. * Creates a Highlight layer from parsed Highlight layer data
  128344. * @param parsedHightlightLayer defines the Highlight layer data
  128345. * @param scene defines the current scene
  128346. * @param rootUrl defines the root URL containing the Highlight layer information
  128347. * @returns a parsed Highlight layer
  128348. */
  128349. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128350. }
  128351. }
  128352. declare module BABYLON {
  128353. interface AbstractScene {
  128354. /**
  128355. * The list of layers (background and foreground) of the scene
  128356. */
  128357. layers: Array<Layer>;
  128358. }
  128359. /**
  128360. * Defines the layer scene component responsible to manage any layers
  128361. * in a given scene.
  128362. */
  128363. export class LayerSceneComponent implements ISceneComponent {
  128364. /**
  128365. * The component name helpfull to identify the component in the list of scene components.
  128366. */
  128367. readonly name: string;
  128368. /**
  128369. * The scene the component belongs to.
  128370. */
  128371. scene: Scene;
  128372. private _engine;
  128373. /**
  128374. * Creates a new instance of the component for the given scene
  128375. * @param scene Defines the scene to register the component in
  128376. */
  128377. constructor(scene: Scene);
  128378. /**
  128379. * Registers the component in a given scene
  128380. */
  128381. register(): void;
  128382. /**
  128383. * Rebuilds the elements related to this component in case of
  128384. * context lost for instance.
  128385. */
  128386. rebuild(): void;
  128387. /**
  128388. * Disposes the component and the associated ressources.
  128389. */
  128390. dispose(): void;
  128391. private _draw;
  128392. private _drawCameraPredicate;
  128393. private _drawCameraBackground;
  128394. private _drawCameraForeground;
  128395. private _drawRenderTargetPredicate;
  128396. private _drawRenderTargetBackground;
  128397. private _drawRenderTargetForeground;
  128398. /**
  128399. * Adds all the elements from the container to the scene
  128400. * @param container the container holding the elements
  128401. */
  128402. addFromContainer(container: AbstractScene): void;
  128403. /**
  128404. * Removes all the elements in the container from the scene
  128405. * @param container contains the elements to remove
  128406. * @param dispose if the removed element should be disposed (default: false)
  128407. */
  128408. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128409. }
  128410. }
  128411. declare module BABYLON {
  128412. /** @hidden */
  128413. export var layerPixelShader: {
  128414. name: string;
  128415. shader: string;
  128416. };
  128417. }
  128418. declare module BABYLON {
  128419. /** @hidden */
  128420. export var layerVertexShader: {
  128421. name: string;
  128422. shader: string;
  128423. };
  128424. }
  128425. declare module BABYLON {
  128426. /**
  128427. * This represents a full screen 2d layer.
  128428. * This can be useful to display a picture in the background of your scene for instance.
  128429. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128430. */
  128431. export class Layer {
  128432. /**
  128433. * Define the name of the layer.
  128434. */
  128435. name: string;
  128436. /**
  128437. * Define the texture the layer should display.
  128438. */
  128439. texture: Nullable<Texture>;
  128440. /**
  128441. * Is the layer in background or foreground.
  128442. */
  128443. isBackground: boolean;
  128444. /**
  128445. * Define the color of the layer (instead of texture).
  128446. */
  128447. color: Color4;
  128448. /**
  128449. * Define the scale of the layer in order to zoom in out of the texture.
  128450. */
  128451. scale: Vector2;
  128452. /**
  128453. * Define an offset for the layer in order to shift the texture.
  128454. */
  128455. offset: Vector2;
  128456. /**
  128457. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128458. */
  128459. alphaBlendingMode: number;
  128460. /**
  128461. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128462. * Alpha test will not mix with the background color in case of transparency.
  128463. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128464. */
  128465. alphaTest: boolean;
  128466. /**
  128467. * Define a mask to restrict the layer to only some of the scene cameras.
  128468. */
  128469. layerMask: number;
  128470. /**
  128471. * Define the list of render target the layer is visible into.
  128472. */
  128473. renderTargetTextures: RenderTargetTexture[];
  128474. /**
  128475. * Define if the layer is only used in renderTarget or if it also
  128476. * renders in the main frame buffer of the canvas.
  128477. */
  128478. renderOnlyInRenderTargetTextures: boolean;
  128479. private _scene;
  128480. private _vertexBuffers;
  128481. private _indexBuffer;
  128482. private _effect;
  128483. private _previousDefines;
  128484. /**
  128485. * An event triggered when the layer is disposed.
  128486. */
  128487. onDisposeObservable: Observable<Layer>;
  128488. private _onDisposeObserver;
  128489. /**
  128490. * Back compatibility with callback before the onDisposeObservable existed.
  128491. * The set callback will be triggered when the layer has been disposed.
  128492. */
  128493. set onDispose(callback: () => void);
  128494. /**
  128495. * An event triggered before rendering the scene
  128496. */
  128497. onBeforeRenderObservable: Observable<Layer>;
  128498. private _onBeforeRenderObserver;
  128499. /**
  128500. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128501. * The set callback will be triggered just before rendering the layer.
  128502. */
  128503. set onBeforeRender(callback: () => void);
  128504. /**
  128505. * An event triggered after rendering the scene
  128506. */
  128507. onAfterRenderObservable: Observable<Layer>;
  128508. private _onAfterRenderObserver;
  128509. /**
  128510. * Back compatibility with callback before the onAfterRenderObservable existed.
  128511. * The set callback will be triggered just after rendering the layer.
  128512. */
  128513. set onAfterRender(callback: () => void);
  128514. /**
  128515. * Instantiates a new layer.
  128516. * This represents a full screen 2d layer.
  128517. * This can be useful to display a picture in the background of your scene for instance.
  128518. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128519. * @param name Define the name of the layer in the scene
  128520. * @param imgUrl Define the url of the texture to display in the layer
  128521. * @param scene Define the scene the layer belongs to
  128522. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128523. * @param color Defines a color for the layer
  128524. */
  128525. constructor(
  128526. /**
  128527. * Define the name of the layer.
  128528. */
  128529. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128530. private _createIndexBuffer;
  128531. /** @hidden */
  128532. _rebuild(): void;
  128533. /**
  128534. * Renders the layer in the scene.
  128535. */
  128536. render(): void;
  128537. /**
  128538. * Disposes and releases the associated ressources.
  128539. */
  128540. dispose(): void;
  128541. }
  128542. }
  128543. declare module BABYLON {
  128544. /** @hidden */
  128545. export var lensFlarePixelShader: {
  128546. name: string;
  128547. shader: string;
  128548. };
  128549. }
  128550. declare module BABYLON {
  128551. /** @hidden */
  128552. export var lensFlareVertexShader: {
  128553. name: string;
  128554. shader: string;
  128555. };
  128556. }
  128557. declare module BABYLON {
  128558. /**
  128559. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128560. * It is usually composed of several `lensFlare`.
  128561. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128562. */
  128563. export class LensFlareSystem {
  128564. /**
  128565. * Define the name of the lens flare system
  128566. */
  128567. name: string;
  128568. /**
  128569. * List of lens flares used in this system.
  128570. */
  128571. lensFlares: LensFlare[];
  128572. /**
  128573. * Define a limit from the border the lens flare can be visible.
  128574. */
  128575. borderLimit: number;
  128576. /**
  128577. * Define a viewport border we do not want to see the lens flare in.
  128578. */
  128579. viewportBorder: number;
  128580. /**
  128581. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128582. */
  128583. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128584. /**
  128585. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128586. */
  128587. layerMask: number;
  128588. /**
  128589. * Define the id of the lens flare system in the scene.
  128590. * (equal to name by default)
  128591. */
  128592. id: string;
  128593. private _scene;
  128594. private _emitter;
  128595. private _vertexBuffers;
  128596. private _indexBuffer;
  128597. private _effect;
  128598. private _positionX;
  128599. private _positionY;
  128600. private _isEnabled;
  128601. /** @hidden */
  128602. static _SceneComponentInitialization: (scene: Scene) => void;
  128603. /**
  128604. * Instantiates a lens flare system.
  128605. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128606. * It is usually composed of several `lensFlare`.
  128607. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128608. * @param name Define the name of the lens flare system in the scene
  128609. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128610. * @param scene Define the scene the lens flare system belongs to
  128611. */
  128612. constructor(
  128613. /**
  128614. * Define the name of the lens flare system
  128615. */
  128616. name: string, emitter: any, scene: Scene);
  128617. /**
  128618. * Define if the lens flare system is enabled.
  128619. */
  128620. get isEnabled(): boolean;
  128621. set isEnabled(value: boolean);
  128622. /**
  128623. * Get the scene the effects belongs to.
  128624. * @returns the scene holding the lens flare system
  128625. */
  128626. getScene(): Scene;
  128627. /**
  128628. * Get the emitter of the lens flare system.
  128629. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128630. * @returns the emitter of the lens flare system
  128631. */
  128632. getEmitter(): any;
  128633. /**
  128634. * Set the emitter of the lens flare system.
  128635. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128636. * @param newEmitter Define the new emitter of the system
  128637. */
  128638. setEmitter(newEmitter: any): void;
  128639. /**
  128640. * Get the lens flare system emitter position.
  128641. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128642. * @returns the position
  128643. */
  128644. getEmitterPosition(): Vector3;
  128645. /**
  128646. * @hidden
  128647. */
  128648. computeEffectivePosition(globalViewport: Viewport): boolean;
  128649. /** @hidden */
  128650. _isVisible(): boolean;
  128651. /**
  128652. * @hidden
  128653. */
  128654. render(): boolean;
  128655. /**
  128656. * Dispose and release the lens flare with its associated resources.
  128657. */
  128658. dispose(): void;
  128659. /**
  128660. * Parse a lens flare system from a JSON repressentation
  128661. * @param parsedLensFlareSystem Define the JSON to parse
  128662. * @param scene Define the scene the parsed system should be instantiated in
  128663. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128664. * @returns the parsed system
  128665. */
  128666. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128667. /**
  128668. * Serialize the current Lens Flare System into a JSON representation.
  128669. * @returns the serialized JSON
  128670. */
  128671. serialize(): any;
  128672. }
  128673. }
  128674. declare module BABYLON {
  128675. /**
  128676. * This represents one of the lens effect in a `lensFlareSystem`.
  128677. * It controls one of the indiviual texture used in the effect.
  128678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128679. */
  128680. export class LensFlare {
  128681. /**
  128682. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128683. */
  128684. size: number;
  128685. /**
  128686. * 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.
  128687. */
  128688. position: number;
  128689. /**
  128690. * Define the lens color.
  128691. */
  128692. color: Color3;
  128693. /**
  128694. * Define the lens texture.
  128695. */
  128696. texture: Nullable<Texture>;
  128697. /**
  128698. * Define the alpha mode to render this particular lens.
  128699. */
  128700. alphaMode: number;
  128701. private _system;
  128702. /**
  128703. * Creates a new Lens Flare.
  128704. * This represents one of the lens effect in a `lensFlareSystem`.
  128705. * It controls one of the indiviual texture used in the effect.
  128706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128707. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128708. * @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.
  128709. * @param color Define the lens color
  128710. * @param imgUrl Define the lens texture url
  128711. * @param system Define the `lensFlareSystem` this flare is part of
  128712. * @returns The newly created Lens Flare
  128713. */
  128714. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128715. /**
  128716. * Instantiates a new Lens Flare.
  128717. * This represents one of the lens effect in a `lensFlareSystem`.
  128718. * It controls one of the indiviual texture used in the effect.
  128719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128720. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128721. * @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.
  128722. * @param color Define the lens color
  128723. * @param imgUrl Define the lens texture url
  128724. * @param system Define the `lensFlareSystem` this flare is part of
  128725. */
  128726. constructor(
  128727. /**
  128728. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128729. */
  128730. size: number,
  128731. /**
  128732. * 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.
  128733. */
  128734. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128735. /**
  128736. * Dispose and release the lens flare with its associated resources.
  128737. */
  128738. dispose(): void;
  128739. }
  128740. }
  128741. declare module BABYLON {
  128742. interface AbstractScene {
  128743. /**
  128744. * The list of lens flare system added to the scene
  128745. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128746. */
  128747. lensFlareSystems: Array<LensFlareSystem>;
  128748. /**
  128749. * Removes the given lens flare system from this scene.
  128750. * @param toRemove The lens flare system to remove
  128751. * @returns The index of the removed lens flare system
  128752. */
  128753. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128754. /**
  128755. * Adds the given lens flare system to this scene
  128756. * @param newLensFlareSystem The lens flare system to add
  128757. */
  128758. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128759. /**
  128760. * Gets a lens flare system using its name
  128761. * @param name defines the name to look for
  128762. * @returns the lens flare system or null if not found
  128763. */
  128764. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128765. /**
  128766. * Gets a lens flare system using its id
  128767. * @param id defines the id to look for
  128768. * @returns the lens flare system or null if not found
  128769. */
  128770. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128771. }
  128772. /**
  128773. * Defines the lens flare scene component responsible to manage any lens flares
  128774. * in a given scene.
  128775. */
  128776. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128777. /**
  128778. * The component name helpfull to identify the component in the list of scene components.
  128779. */
  128780. readonly name: string;
  128781. /**
  128782. * The scene the component belongs to.
  128783. */
  128784. scene: Scene;
  128785. /**
  128786. * Creates a new instance of the component for the given scene
  128787. * @param scene Defines the scene to register the component in
  128788. */
  128789. constructor(scene: Scene);
  128790. /**
  128791. * Registers the component in a given scene
  128792. */
  128793. register(): void;
  128794. /**
  128795. * Rebuilds the elements related to this component in case of
  128796. * context lost for instance.
  128797. */
  128798. rebuild(): void;
  128799. /**
  128800. * Adds all the elements from the container to the scene
  128801. * @param container the container holding the elements
  128802. */
  128803. addFromContainer(container: AbstractScene): void;
  128804. /**
  128805. * Removes all the elements in the container from the scene
  128806. * @param container contains the elements to remove
  128807. * @param dispose if the removed element should be disposed (default: false)
  128808. */
  128809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128810. /**
  128811. * Serializes the component data to the specified json object
  128812. * @param serializationObject The object to serialize to
  128813. */
  128814. serialize(serializationObject: any): void;
  128815. /**
  128816. * Disposes the component and the associated ressources.
  128817. */
  128818. dispose(): void;
  128819. private _draw;
  128820. }
  128821. }
  128822. declare module BABYLON {
  128823. /** @hidden */
  128824. export var depthPixelShader: {
  128825. name: string;
  128826. shader: string;
  128827. };
  128828. }
  128829. declare module BABYLON {
  128830. /** @hidden */
  128831. export var depthVertexShader: {
  128832. name: string;
  128833. shader: string;
  128834. };
  128835. }
  128836. declare module BABYLON {
  128837. /**
  128838. * This represents a depth renderer in Babylon.
  128839. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128840. */
  128841. export class DepthRenderer {
  128842. private _scene;
  128843. private _depthMap;
  128844. private _effect;
  128845. private readonly _storeNonLinearDepth;
  128846. private readonly _clearColor;
  128847. /** Get if the depth renderer is using packed depth or not */
  128848. readonly isPacked: boolean;
  128849. private _cachedDefines;
  128850. private _camera;
  128851. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128852. enabled: boolean;
  128853. /**
  128854. * Specifiess that the depth renderer will only be used within
  128855. * the camera it is created for.
  128856. * This can help forcing its rendering during the camera processing.
  128857. */
  128858. useOnlyInActiveCamera: boolean;
  128859. /** @hidden */
  128860. static _SceneComponentInitialization: (scene: Scene) => void;
  128861. /**
  128862. * Instantiates a depth renderer
  128863. * @param scene The scene the renderer belongs to
  128864. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128865. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128866. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128867. */
  128868. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128869. /**
  128870. * Creates the depth rendering effect and checks if the effect is ready.
  128871. * @param subMesh The submesh to be used to render the depth map of
  128872. * @param useInstances If multiple world instances should be used
  128873. * @returns if the depth renderer is ready to render the depth map
  128874. */
  128875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128876. /**
  128877. * Gets the texture which the depth map will be written to.
  128878. * @returns The depth map texture
  128879. */
  128880. getDepthMap(): RenderTargetTexture;
  128881. /**
  128882. * Disposes of the depth renderer.
  128883. */
  128884. dispose(): void;
  128885. }
  128886. }
  128887. declare module BABYLON {
  128888. /** @hidden */
  128889. export var minmaxReduxPixelShader: {
  128890. name: string;
  128891. shader: string;
  128892. };
  128893. }
  128894. declare module BABYLON {
  128895. /**
  128896. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128897. * and maximum values from all values of the texture.
  128898. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128899. * The source values are read from the red channel of the texture.
  128900. */
  128901. export class MinMaxReducer {
  128902. /**
  128903. * Observable triggered when the computation has been performed
  128904. */
  128905. onAfterReductionPerformed: Observable<{
  128906. min: number;
  128907. max: number;
  128908. }>;
  128909. protected _camera: Camera;
  128910. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128911. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128912. protected _postProcessManager: PostProcessManager;
  128913. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128914. protected _forceFullscreenViewport: boolean;
  128915. /**
  128916. * Creates a min/max reducer
  128917. * @param camera The camera to use for the post processes
  128918. */
  128919. constructor(camera: Camera);
  128920. /**
  128921. * Gets the texture used to read the values from.
  128922. */
  128923. get sourceTexture(): Nullable<RenderTargetTexture>;
  128924. /**
  128925. * Sets the source texture to read the values from.
  128926. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128927. * because in such textures '1' value must not be taken into account to compute the maximum
  128928. * as this value is used to clear the texture.
  128929. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128930. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128931. * @param depthRedux Indicates if the texture is a depth texture or not
  128932. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128933. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128934. */
  128935. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128936. /**
  128937. * Defines the refresh rate of the computation.
  128938. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128939. */
  128940. get refreshRate(): number;
  128941. set refreshRate(value: number);
  128942. protected _activated: boolean;
  128943. /**
  128944. * Gets the activation status of the reducer
  128945. */
  128946. get activated(): boolean;
  128947. /**
  128948. * Activates the reduction computation.
  128949. * When activated, the observers registered in onAfterReductionPerformed are
  128950. * called after the compuation is performed
  128951. */
  128952. activate(): void;
  128953. /**
  128954. * Deactivates the reduction computation.
  128955. */
  128956. deactivate(): void;
  128957. /**
  128958. * Disposes the min/max reducer
  128959. * @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.
  128960. */
  128961. dispose(disposeAll?: boolean): void;
  128962. }
  128963. }
  128964. declare module BABYLON {
  128965. /**
  128966. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128967. */
  128968. export class DepthReducer extends MinMaxReducer {
  128969. private _depthRenderer;
  128970. private _depthRendererId;
  128971. /**
  128972. * Gets the depth renderer used for the computation.
  128973. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128974. */
  128975. get depthRenderer(): Nullable<DepthRenderer>;
  128976. /**
  128977. * Creates a depth reducer
  128978. * @param camera The camera used to render the depth texture
  128979. */
  128980. constructor(camera: Camera);
  128981. /**
  128982. * Sets the depth renderer to use to generate the depth map
  128983. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128984. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128985. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128986. */
  128987. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128988. /** @hidden */
  128989. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128990. /**
  128991. * Activates the reduction computation.
  128992. * When activated, the observers registered in onAfterReductionPerformed are
  128993. * called after the compuation is performed
  128994. */
  128995. activate(): void;
  128996. /**
  128997. * Deactivates the reduction computation.
  128998. */
  128999. deactivate(): void;
  129000. /**
  129001. * Disposes the depth reducer
  129002. * @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.
  129003. */
  129004. dispose(disposeAll?: boolean): void;
  129005. }
  129006. }
  129007. declare module BABYLON {
  129008. /**
  129009. * A CSM implementation allowing casting shadows on large scenes.
  129010. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129011. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  129012. */
  129013. export class CascadedShadowGenerator extends ShadowGenerator {
  129014. private static readonly frustumCornersNDCSpace;
  129015. /**
  129016. * Name of the CSM class
  129017. */
  129018. static CLASSNAME: string;
  129019. /**
  129020. * Defines the default number of cascades used by the CSM.
  129021. */
  129022. static readonly DEFAULT_CASCADES_COUNT: number;
  129023. /**
  129024. * Defines the minimum number of cascades used by the CSM.
  129025. */
  129026. static readonly MIN_CASCADES_COUNT: number;
  129027. /**
  129028. * Defines the maximum number of cascades used by the CSM.
  129029. */
  129030. static readonly MAX_CASCADES_COUNT: number;
  129031. protected _validateFilter(filter: number): number;
  129032. /**
  129033. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129034. */
  129035. penumbraDarkness: number;
  129036. private _numCascades;
  129037. /**
  129038. * Gets or set the number of cascades used by the CSM.
  129039. */
  129040. get numCascades(): number;
  129041. set numCascades(value: number);
  129042. /**
  129043. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129044. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129045. */
  129046. stabilizeCascades: boolean;
  129047. private _freezeShadowCastersBoundingInfo;
  129048. private _freezeShadowCastersBoundingInfoObservable;
  129049. /**
  129050. * Enables or disables the shadow casters bounding info computation.
  129051. * If your shadow casters don't move, you can disable this feature.
  129052. * If it is enabled, the bounding box computation is done every frame.
  129053. */
  129054. get freezeShadowCastersBoundingInfo(): boolean;
  129055. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129056. private _scbiMin;
  129057. private _scbiMax;
  129058. protected _computeShadowCastersBoundingInfo(): void;
  129059. protected _shadowCastersBoundingInfo: BoundingInfo;
  129060. /**
  129061. * Gets or sets the shadow casters bounding info.
  129062. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129063. * so that the system won't overwrite the bounds you provide
  129064. */
  129065. get shadowCastersBoundingInfo(): BoundingInfo;
  129066. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129067. protected _breaksAreDirty: boolean;
  129068. protected _minDistance: number;
  129069. protected _maxDistance: number;
  129070. /**
  129071. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129072. *
  129073. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129074. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129075. * @param min minimal distance for the breaks (default to 0.)
  129076. * @param max maximal distance for the breaks (default to 1.)
  129077. */
  129078. setMinMaxDistance(min: number, max: number): void;
  129079. /** Gets the minimal distance used in the cascade break computation */
  129080. get minDistance(): number;
  129081. /** Gets the maximal distance used in the cascade break computation */
  129082. get maxDistance(): number;
  129083. /**
  129084. * Gets the class name of that object
  129085. * @returns "CascadedShadowGenerator"
  129086. */
  129087. getClassName(): string;
  129088. private _cascadeMinExtents;
  129089. private _cascadeMaxExtents;
  129090. /**
  129091. * Gets a cascade minimum extents
  129092. * @param cascadeIndex index of the cascade
  129093. * @returns the minimum cascade extents
  129094. */
  129095. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129096. /**
  129097. * Gets a cascade maximum extents
  129098. * @param cascadeIndex index of the cascade
  129099. * @returns the maximum cascade extents
  129100. */
  129101. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129102. private _cascades;
  129103. private _currentLayer;
  129104. private _viewSpaceFrustumsZ;
  129105. private _viewMatrices;
  129106. private _projectionMatrices;
  129107. private _transformMatrices;
  129108. private _transformMatricesAsArray;
  129109. private _frustumLengths;
  129110. private _lightSizeUVCorrection;
  129111. private _depthCorrection;
  129112. private _frustumCornersWorldSpace;
  129113. private _frustumCenter;
  129114. private _shadowCameraPos;
  129115. private _shadowMaxZ;
  129116. /**
  129117. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129118. * It defaults to camera.maxZ
  129119. */
  129120. get shadowMaxZ(): number;
  129121. /**
  129122. * Sets the shadow max z distance.
  129123. */
  129124. set shadowMaxZ(value: number);
  129125. protected _debug: boolean;
  129126. /**
  129127. * Gets or sets the debug flag.
  129128. * When enabled, the cascades are materialized by different colors on the screen.
  129129. */
  129130. get debug(): boolean;
  129131. set debug(dbg: boolean);
  129132. private _depthClamp;
  129133. /**
  129134. * Gets or sets the depth clamping value.
  129135. *
  129136. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129137. * to account for the shadow casters far away.
  129138. *
  129139. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129140. */
  129141. get depthClamp(): boolean;
  129142. set depthClamp(value: boolean);
  129143. private _cascadeBlendPercentage;
  129144. /**
  129145. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129146. * It defaults to 0.1 (10% blending).
  129147. */
  129148. get cascadeBlendPercentage(): number;
  129149. set cascadeBlendPercentage(value: number);
  129150. private _lambda;
  129151. /**
  129152. * Gets or set the lambda parameter.
  129153. * This parameter is used to split the camera frustum and create the cascades.
  129154. * 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.
  129155. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129156. */
  129157. get lambda(): number;
  129158. set lambda(value: number);
  129159. /**
  129160. * Gets the view matrix corresponding to a given cascade
  129161. * @param cascadeNum cascade to retrieve the view matrix from
  129162. * @returns the cascade view matrix
  129163. */
  129164. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129165. /**
  129166. * Gets the projection matrix corresponding to a given cascade
  129167. * @param cascadeNum cascade to retrieve the projection matrix from
  129168. * @returns the cascade projection matrix
  129169. */
  129170. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129171. /**
  129172. * Gets the transformation matrix corresponding to a given cascade
  129173. * @param cascadeNum cascade to retrieve the transformation matrix from
  129174. * @returns the cascade transformation matrix
  129175. */
  129176. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129177. private _depthRenderer;
  129178. /**
  129179. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129180. *
  129181. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129182. *
  129183. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129184. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129185. * @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
  129186. */
  129187. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129188. private _depthReducer;
  129189. private _autoCalcDepthBounds;
  129190. /**
  129191. * Gets or sets the autoCalcDepthBounds property.
  129192. *
  129193. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129194. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129195. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129196. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129197. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129198. */
  129199. get autoCalcDepthBounds(): boolean;
  129200. set autoCalcDepthBounds(value: boolean);
  129201. /**
  129202. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129203. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129204. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129205. * for setting the refresh rate on the renderer yourself!
  129206. */
  129207. get autoCalcDepthBoundsRefreshRate(): number;
  129208. set autoCalcDepthBoundsRefreshRate(value: number);
  129209. /**
  129210. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129211. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129212. * you change the camera near/far planes!
  129213. */
  129214. splitFrustum(): void;
  129215. private _splitFrustum;
  129216. private _computeMatrices;
  129217. private _computeFrustumInWorldSpace;
  129218. private _computeCascadeFrustum;
  129219. /**
  129220. * Support test.
  129221. */
  129222. static get IsSupported(): boolean;
  129223. /** @hidden */
  129224. static _SceneComponentInitialization: (scene: Scene) => void;
  129225. /**
  129226. * Creates a Cascaded Shadow Generator object.
  129227. * A ShadowGenerator is the required tool to use the shadows.
  129228. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129229. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129230. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129231. * @param light The directional light object generating the shadows.
  129232. * @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.
  129233. */
  129234. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129235. protected _initializeGenerator(): void;
  129236. protected _createTargetRenderTexture(): void;
  129237. protected _initializeShadowMap(): void;
  129238. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  129239. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129240. /**
  129241. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129242. * @param defines Defines of the material we want to update
  129243. * @param lightIndex Index of the light in the enabled light list of the material
  129244. */
  129245. prepareDefines(defines: any, lightIndex: number): void;
  129246. /**
  129247. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129248. * defined in the generator but impacting the effect).
  129249. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129250. * @param effect The effect we are binfing the information for
  129251. */
  129252. bindShadowLight(lightIndex: string, effect: Effect): void;
  129253. /**
  129254. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129255. * (eq to view projection * shadow projection matrices)
  129256. * @returns The transform matrix used to create the shadow map
  129257. */
  129258. getTransformMatrix(): Matrix;
  129259. /**
  129260. * Disposes the ShadowGenerator.
  129261. * Returns nothing.
  129262. */
  129263. dispose(): void;
  129264. /**
  129265. * Serializes the shadow generator setup to a json object.
  129266. * @returns The serialized JSON object
  129267. */
  129268. serialize(): any;
  129269. /**
  129270. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129271. * @param parsedShadowGenerator The JSON object to parse
  129272. * @param scene The scene to create the shadow map for
  129273. * @returns The parsed shadow generator
  129274. */
  129275. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129276. }
  129277. }
  129278. declare module BABYLON {
  129279. /**
  129280. * Defines the shadow generator component responsible to manage any shadow generators
  129281. * in a given scene.
  129282. */
  129283. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129284. /**
  129285. * The component name helpfull to identify the component in the list of scene components.
  129286. */
  129287. readonly name: string;
  129288. /**
  129289. * The scene the component belongs to.
  129290. */
  129291. scene: Scene;
  129292. /**
  129293. * Creates a new instance of the component for the given scene
  129294. * @param scene Defines the scene to register the component in
  129295. */
  129296. constructor(scene: Scene);
  129297. /**
  129298. * Registers the component in a given scene
  129299. */
  129300. register(): void;
  129301. /**
  129302. * Rebuilds the elements related to this component in case of
  129303. * context lost for instance.
  129304. */
  129305. rebuild(): void;
  129306. /**
  129307. * Serializes the component data to the specified json object
  129308. * @param serializationObject The object to serialize to
  129309. */
  129310. serialize(serializationObject: any): void;
  129311. /**
  129312. * Adds all the elements from the container to the scene
  129313. * @param container the container holding the elements
  129314. */
  129315. addFromContainer(container: AbstractScene): void;
  129316. /**
  129317. * Removes all the elements in the container from the scene
  129318. * @param container contains the elements to remove
  129319. * @param dispose if the removed element should be disposed (default: false)
  129320. */
  129321. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129322. /**
  129323. * Rebuilds the elements related to this component in case of
  129324. * context lost for instance.
  129325. */
  129326. dispose(): void;
  129327. private _gatherRenderTargets;
  129328. }
  129329. }
  129330. declare module BABYLON {
  129331. /**
  129332. * A point light is a light defined by an unique point in world space.
  129333. * The light is emitted in every direction from this point.
  129334. * A good example of a point light is a standard light bulb.
  129335. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129336. */
  129337. export class PointLight extends ShadowLight {
  129338. private _shadowAngle;
  129339. /**
  129340. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129341. * This specifies what angle the shadow will use to be created.
  129342. *
  129343. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129344. */
  129345. get shadowAngle(): number;
  129346. /**
  129347. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129348. * This specifies what angle the shadow will use to be created.
  129349. *
  129350. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129351. */
  129352. set shadowAngle(value: number);
  129353. /**
  129354. * Gets the direction if it has been set.
  129355. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129356. */
  129357. get direction(): Vector3;
  129358. /**
  129359. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129360. */
  129361. set direction(value: Vector3);
  129362. /**
  129363. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129364. * A PointLight emits the light in every direction.
  129365. * It can cast shadows.
  129366. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129367. * ```javascript
  129368. * var pointLight = new PointLight("pl", camera.position, scene);
  129369. * ```
  129370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129371. * @param name The light friendly name
  129372. * @param position The position of the point light in the scene
  129373. * @param scene The scene the lights belongs to
  129374. */
  129375. constructor(name: string, position: Vector3, scene: Scene);
  129376. /**
  129377. * Returns the string "PointLight"
  129378. * @returns the class name
  129379. */
  129380. getClassName(): string;
  129381. /**
  129382. * Returns the integer 0.
  129383. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129384. */
  129385. getTypeID(): number;
  129386. /**
  129387. * Specifies wether or not the shadowmap should be a cube texture.
  129388. * @returns true if the shadowmap needs to be a cube texture.
  129389. */
  129390. needCube(): boolean;
  129391. /**
  129392. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129393. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129394. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129395. */
  129396. getShadowDirection(faceIndex?: number): Vector3;
  129397. /**
  129398. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129399. * - fov = PI / 2
  129400. * - aspect ratio : 1.0
  129401. * - z-near and far equal to the active camera minZ and maxZ.
  129402. * Returns the PointLight.
  129403. */
  129404. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129405. protected _buildUniformLayout(): void;
  129406. /**
  129407. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129408. * @param effect The effect to update
  129409. * @param lightIndex The index of the light in the effect to update
  129410. * @returns The point light
  129411. */
  129412. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129413. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129414. /**
  129415. * Prepares the list of defines specific to the light type.
  129416. * @param defines the list of defines
  129417. * @param lightIndex defines the index of the light for the effect
  129418. */
  129419. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129420. }
  129421. }
  129422. declare module BABYLON {
  129423. /**
  129424. * Header information of HDR texture files.
  129425. */
  129426. export interface HDRInfo {
  129427. /**
  129428. * The height of the texture in pixels.
  129429. */
  129430. height: number;
  129431. /**
  129432. * The width of the texture in pixels.
  129433. */
  129434. width: number;
  129435. /**
  129436. * The index of the beginning of the data in the binary file.
  129437. */
  129438. dataPosition: number;
  129439. }
  129440. /**
  129441. * This groups tools to convert HDR texture to native colors array.
  129442. */
  129443. export class HDRTools {
  129444. private static Ldexp;
  129445. private static Rgbe2float;
  129446. private static readStringLine;
  129447. /**
  129448. * Reads header information from an RGBE texture stored in a native array.
  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 native array.
  129453. * @return The header information.
  129454. */
  129455. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129456. /**
  129457. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129458. * This RGBE texture needs to store the information as a panorama.
  129459. *
  129460. * More information on this format are available here:
  129461. * https://en.wikipedia.org/wiki/RGBE_image_format
  129462. *
  129463. * @param buffer The binary file stored in an array buffer.
  129464. * @param size The expected size of the extracted cubemap.
  129465. * @return The Cube Map information.
  129466. */
  129467. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129468. /**
  129469. * Returns the pixels data extracted from an RGBE texture.
  129470. * This pixels will be stored left to right up to down in the R G B order in one array.
  129471. *
  129472. * More information on this format are available here:
  129473. * https://en.wikipedia.org/wiki/RGBE_image_format
  129474. *
  129475. * @param uint8array The binary file stored in an array buffer.
  129476. * @param hdrInfo The header information of the file.
  129477. * @return The pixels data in RGB right to left up to down order.
  129478. */
  129479. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129480. private static RGBE_ReadPixels_RLE;
  129481. }
  129482. }
  129483. declare module BABYLON {
  129484. /**
  129485. * This represents a texture coming from an HDR input.
  129486. *
  129487. * The only supported format is currently panorama picture stored in RGBE format.
  129488. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129489. */
  129490. export class HDRCubeTexture extends BaseTexture {
  129491. private static _facesMapping;
  129492. private _generateHarmonics;
  129493. private _noMipmap;
  129494. private _textureMatrix;
  129495. private _size;
  129496. private _onLoad;
  129497. private _onError;
  129498. /**
  129499. * The texture URL.
  129500. */
  129501. url: string;
  129502. /**
  129503. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129504. */
  129505. coordinatesMode: number;
  129506. protected _isBlocking: boolean;
  129507. /**
  129508. * Sets wether or not the texture is blocking during loading.
  129509. */
  129510. set isBlocking(value: boolean);
  129511. /**
  129512. * Gets wether or not the texture is blocking during loading.
  129513. */
  129514. get isBlocking(): boolean;
  129515. protected _rotationY: number;
  129516. /**
  129517. * Sets texture matrix rotation angle around Y axis in radians.
  129518. */
  129519. set rotationY(value: number);
  129520. /**
  129521. * Gets texture matrix rotation angle around Y axis radians.
  129522. */
  129523. get rotationY(): number;
  129524. /**
  129525. * Gets or sets the center of the bounding box associated with the cube texture
  129526. * It must define where the camera used to render the texture was set
  129527. */
  129528. boundingBoxPosition: Vector3;
  129529. private _boundingBoxSize;
  129530. /**
  129531. * Gets or sets the size of the bounding box associated with the cube texture
  129532. * When defined, the cubemap will switch to local mode
  129533. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129534. * @example https://www.babylonjs-playground.com/#RNASML
  129535. */
  129536. set boundingBoxSize(value: Vector3);
  129537. get boundingBoxSize(): Vector3;
  129538. /**
  129539. * Instantiates an HDRTexture from the following parameters.
  129540. *
  129541. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129542. * @param scene The scene the texture will be used in
  129543. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129544. * @param noMipmap Forces to not generate the mipmap if true
  129545. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129546. * @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)
  129547. * @param reserved Reserved flag for internal use.
  129548. */
  129549. 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>);
  129550. /**
  129551. * Get the current class name of the texture useful for serialization or dynamic coding.
  129552. * @returns "HDRCubeTexture"
  129553. */
  129554. getClassName(): string;
  129555. /**
  129556. * Occurs when the file is raw .hdr file.
  129557. */
  129558. private loadTexture;
  129559. clone(): HDRCubeTexture;
  129560. delayLoad(): void;
  129561. /**
  129562. * Get the texture reflection matrix used to rotate/transform the reflection.
  129563. * @returns the reflection matrix
  129564. */
  129565. getReflectionTextureMatrix(): Matrix;
  129566. /**
  129567. * Set the texture reflection matrix used to rotate/transform the reflection.
  129568. * @param value Define the reflection matrix to set
  129569. */
  129570. setReflectionTextureMatrix(value: Matrix): void;
  129571. /**
  129572. * Parses a JSON representation of an HDR Texture in order to create the texture
  129573. * @param parsedTexture Define the JSON representation
  129574. * @param scene Define the scene the texture should be created in
  129575. * @param rootUrl Define the root url in case we need to load relative dependencies
  129576. * @returns the newly created texture after parsing
  129577. */
  129578. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129579. serialize(): any;
  129580. }
  129581. }
  129582. declare module BABYLON {
  129583. /**
  129584. * Class used to control physics engine
  129585. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129586. */
  129587. export class PhysicsEngine implements IPhysicsEngine {
  129588. private _physicsPlugin;
  129589. /**
  129590. * Global value used to control the smallest number supported by the simulation
  129591. */
  129592. static Epsilon: number;
  129593. private _impostors;
  129594. private _joints;
  129595. private _subTimeStep;
  129596. /**
  129597. * Gets the gravity vector used by the simulation
  129598. */
  129599. gravity: Vector3;
  129600. /**
  129601. * Factory used to create the default physics plugin.
  129602. * @returns The default physics plugin
  129603. */
  129604. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129605. /**
  129606. * Creates a new Physics Engine
  129607. * @param gravity defines the gravity vector used by the simulation
  129608. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129609. */
  129610. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129611. /**
  129612. * Sets the gravity vector used by the simulation
  129613. * @param gravity defines the gravity vector to use
  129614. */
  129615. setGravity(gravity: Vector3): void;
  129616. /**
  129617. * Set the time step of the physics engine.
  129618. * Default is 1/60.
  129619. * To slow it down, enter 1/600 for example.
  129620. * To speed it up, 1/30
  129621. * @param newTimeStep defines the new timestep to apply to this world.
  129622. */
  129623. setTimeStep(newTimeStep?: number): void;
  129624. /**
  129625. * Get the time step of the physics engine.
  129626. * @returns the current time step
  129627. */
  129628. getTimeStep(): number;
  129629. /**
  129630. * Set the sub time step of the physics engine.
  129631. * Default is 0 meaning there is no sub steps
  129632. * To increase physics resolution precision, set a small value (like 1 ms)
  129633. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129634. */
  129635. setSubTimeStep(subTimeStep?: number): void;
  129636. /**
  129637. * Get the sub time step of the physics engine.
  129638. * @returns the current sub time step
  129639. */
  129640. getSubTimeStep(): number;
  129641. /**
  129642. * Release all resources
  129643. */
  129644. dispose(): void;
  129645. /**
  129646. * Gets the name of the current physics plugin
  129647. * @returns the name of the plugin
  129648. */
  129649. getPhysicsPluginName(): string;
  129650. /**
  129651. * Adding a new impostor for the impostor tracking.
  129652. * This will be done by the impostor itself.
  129653. * @param impostor the impostor to add
  129654. */
  129655. addImpostor(impostor: PhysicsImpostor): void;
  129656. /**
  129657. * Remove an impostor from the engine.
  129658. * This impostor and its mesh will not longer be updated by the physics engine.
  129659. * @param impostor the impostor to remove
  129660. */
  129661. removeImpostor(impostor: PhysicsImpostor): void;
  129662. /**
  129663. * Add a joint to the physics engine
  129664. * @param mainImpostor defines the main impostor to which the joint is added.
  129665. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129666. * @param joint defines the joint that will connect both impostors.
  129667. */
  129668. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129669. /**
  129670. * Removes a joint from the simulation
  129671. * @param mainImpostor defines the impostor used with the joint
  129672. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129673. * @param joint defines the joint to remove
  129674. */
  129675. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129676. /**
  129677. * Called by the scene. No need to call it.
  129678. * @param delta defines the timespam between frames
  129679. */
  129680. _step(delta: number): void;
  129681. /**
  129682. * Gets the current plugin used to run the simulation
  129683. * @returns current plugin
  129684. */
  129685. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129686. /**
  129687. * Gets the list of physic impostors
  129688. * @returns an array of PhysicsImpostor
  129689. */
  129690. getImpostors(): Array<PhysicsImpostor>;
  129691. /**
  129692. * Gets the impostor for a physics enabled object
  129693. * @param object defines the object impersonated by the impostor
  129694. * @returns the PhysicsImpostor or null if not found
  129695. */
  129696. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129697. /**
  129698. * Gets the impostor for a physics body object
  129699. * @param body defines physics body used by the impostor
  129700. * @returns the PhysicsImpostor or null if not found
  129701. */
  129702. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129703. /**
  129704. * Does a raycast in the physics world
  129705. * @param from when should the ray start?
  129706. * @param to when should the ray end?
  129707. * @returns PhysicsRaycastResult
  129708. */
  129709. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129710. }
  129711. }
  129712. declare module BABYLON {
  129713. /** @hidden */
  129714. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129715. private _useDeltaForWorldStep;
  129716. world: any;
  129717. name: string;
  129718. private _physicsMaterials;
  129719. private _fixedTimeStep;
  129720. private _cannonRaycastResult;
  129721. private _raycastResult;
  129722. private _physicsBodysToRemoveAfterStep;
  129723. BJSCANNON: any;
  129724. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129725. setGravity(gravity: Vector3): void;
  129726. setTimeStep(timeStep: number): void;
  129727. getTimeStep(): number;
  129728. executeStep(delta: number): void;
  129729. private _removeMarkedPhysicsBodiesFromWorld;
  129730. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129731. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129732. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129733. private _processChildMeshes;
  129734. removePhysicsBody(impostor: PhysicsImpostor): void;
  129735. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129736. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129737. private _addMaterial;
  129738. private _checkWithEpsilon;
  129739. private _createShape;
  129740. private _createHeightmap;
  129741. private _minus90X;
  129742. private _plus90X;
  129743. private _tmpPosition;
  129744. private _tmpDeltaPosition;
  129745. private _tmpUnityRotation;
  129746. private _updatePhysicsBodyTransformation;
  129747. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129748. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129749. isSupported(): boolean;
  129750. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129751. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129752. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129753. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129754. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129755. getBodyMass(impostor: PhysicsImpostor): number;
  129756. getBodyFriction(impostor: PhysicsImpostor): number;
  129757. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129758. getBodyRestitution(impostor: PhysicsImpostor): number;
  129759. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129760. sleepBody(impostor: PhysicsImpostor): void;
  129761. wakeUpBody(impostor: PhysicsImpostor): void;
  129762. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129763. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129764. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129765. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129766. getRadius(impostor: PhysicsImpostor): number;
  129767. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129768. dispose(): void;
  129769. private _extendNamespace;
  129770. /**
  129771. * Does a raycast in the physics world
  129772. * @param from when should the ray start?
  129773. * @param to when should the ray end?
  129774. * @returns PhysicsRaycastResult
  129775. */
  129776. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129777. }
  129778. }
  129779. declare module BABYLON {
  129780. /** @hidden */
  129781. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129782. world: any;
  129783. name: string;
  129784. BJSOIMO: any;
  129785. private _raycastResult;
  129786. constructor(iterations?: number, oimoInjection?: any);
  129787. setGravity(gravity: Vector3): void;
  129788. setTimeStep(timeStep: number): void;
  129789. getTimeStep(): number;
  129790. private _tmpImpostorsArray;
  129791. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129792. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129793. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129794. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129795. private _tmpPositionVector;
  129796. removePhysicsBody(impostor: PhysicsImpostor): void;
  129797. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129798. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129799. isSupported(): boolean;
  129800. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129801. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129807. getBodyMass(impostor: PhysicsImpostor): number;
  129808. getBodyFriction(impostor: PhysicsImpostor): number;
  129809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129810. getBodyRestitution(impostor: PhysicsImpostor): number;
  129811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129812. sleepBody(impostor: PhysicsImpostor): void;
  129813. wakeUpBody(impostor: PhysicsImpostor): void;
  129814. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129815. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129818. getRadius(impostor: PhysicsImpostor): number;
  129819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129820. dispose(): void;
  129821. /**
  129822. * Does a raycast in the physics world
  129823. * @param from when should the ray start?
  129824. * @param to when should the ray end?
  129825. * @returns PhysicsRaycastResult
  129826. */
  129827. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129828. }
  129829. }
  129830. declare module BABYLON {
  129831. /**
  129832. * Class containing static functions to help procedurally build meshes
  129833. */
  129834. export class RibbonBuilder {
  129835. /**
  129836. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129837. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129838. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129839. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129840. * * 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
  129841. * * 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
  129842. * * 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
  129843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129846. * * 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
  129847. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129848. * * 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
  129849. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129851. * @param name defines the name of the mesh
  129852. * @param options defines the options used to create the mesh
  129853. * @param scene defines the hosting scene
  129854. * @returns the ribbon mesh
  129855. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129857. */
  129858. static CreateRibbon(name: string, options: {
  129859. pathArray: Vector3[][];
  129860. closeArray?: boolean;
  129861. closePath?: boolean;
  129862. offset?: number;
  129863. updatable?: boolean;
  129864. sideOrientation?: number;
  129865. frontUVs?: Vector4;
  129866. backUVs?: Vector4;
  129867. instance?: Mesh;
  129868. invertUV?: boolean;
  129869. uvs?: Vector2[];
  129870. colors?: Color4[];
  129871. }, scene?: Nullable<Scene>): Mesh;
  129872. }
  129873. }
  129874. declare module BABYLON {
  129875. /**
  129876. * Class containing static functions to help procedurally build meshes
  129877. */
  129878. export class ShapeBuilder {
  129879. /**
  129880. * 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.
  129881. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  129882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129883. * * The parameter `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.
  129884. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129885. * * 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
  129886. * * 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
  129887. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129892. * @param name defines the name of the mesh
  129893. * @param options defines the options used to create the mesh
  129894. * @param scene defines the hosting scene
  129895. * @returns the extruded shape mesh
  129896. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129898. */
  129899. static ExtrudeShape(name: string, options: {
  129900. shape: Vector3[];
  129901. path: Vector3[];
  129902. scale?: number;
  129903. rotation?: number;
  129904. cap?: number;
  129905. updatable?: boolean;
  129906. sideOrientation?: number;
  129907. frontUVs?: Vector4;
  129908. backUVs?: Vector4;
  129909. instance?: Mesh;
  129910. invertUV?: boolean;
  129911. }, scene?: Nullable<Scene>): Mesh;
  129912. /**
  129913. * Creates an custom extruded shape mesh.
  129914. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129915. * * 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.
  129916. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129917. * * 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
  129918. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129919. * * 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
  129920. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129921. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129922. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129923. * * 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
  129924. * * 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
  129925. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129930. * @param name defines the name of the mesh
  129931. * @param options defines the options used to create the mesh
  129932. * @param scene defines the hosting scene
  129933. * @returns the custom extruded shape mesh
  129934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129937. */
  129938. static ExtrudeShapeCustom(name: string, options: {
  129939. shape: Vector3[];
  129940. path: Vector3[];
  129941. scaleFunction?: any;
  129942. rotationFunction?: any;
  129943. ribbonCloseArray?: boolean;
  129944. ribbonClosePath?: boolean;
  129945. cap?: number;
  129946. updatable?: boolean;
  129947. sideOrientation?: number;
  129948. frontUVs?: Vector4;
  129949. backUVs?: Vector4;
  129950. instance?: Mesh;
  129951. invertUV?: boolean;
  129952. }, scene?: Nullable<Scene>): Mesh;
  129953. private static _ExtrudeShapeGeneric;
  129954. }
  129955. }
  129956. declare module BABYLON {
  129957. /**
  129958. * AmmoJS Physics plugin
  129959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129960. * @see https://github.com/kripken/ammo.js/
  129961. */
  129962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129963. private _useDeltaForWorldStep;
  129964. /**
  129965. * Reference to the Ammo library
  129966. */
  129967. bjsAMMO: any;
  129968. /**
  129969. * Created ammoJS world which physics bodies are added to
  129970. */
  129971. world: any;
  129972. /**
  129973. * Name of the plugin
  129974. */
  129975. name: string;
  129976. private _timeStep;
  129977. private _fixedTimeStep;
  129978. private _maxSteps;
  129979. private _tmpQuaternion;
  129980. private _tmpAmmoTransform;
  129981. private _tmpAmmoQuaternion;
  129982. private _tmpAmmoConcreteContactResultCallback;
  129983. private _collisionConfiguration;
  129984. private _dispatcher;
  129985. private _overlappingPairCache;
  129986. private _solver;
  129987. private _softBodySolver;
  129988. private _tmpAmmoVectorA;
  129989. private _tmpAmmoVectorB;
  129990. private _tmpAmmoVectorC;
  129991. private _tmpAmmoVectorD;
  129992. private _tmpContactCallbackResult;
  129993. private _tmpAmmoVectorRCA;
  129994. private _tmpAmmoVectorRCB;
  129995. private _raycastResult;
  129996. private static readonly DISABLE_COLLISION_FLAG;
  129997. private static readonly KINEMATIC_FLAG;
  129998. private static readonly DISABLE_DEACTIVATION_FLAG;
  129999. /**
  130000. * Initializes the ammoJS plugin
  130001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  130002. * @param ammoInjection can be used to inject your own ammo reference
  130003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  130004. */
  130005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  130006. /**
  130007. * Sets the gravity of the physics world (m/(s^2))
  130008. * @param gravity Gravity to set
  130009. */
  130010. setGravity(gravity: Vector3): void;
  130011. /**
  130012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  130013. * @param timeStep timestep to use in seconds
  130014. */
  130015. setTimeStep(timeStep: number): void;
  130016. /**
  130017. * 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)
  130018. * @param fixedTimeStep fixedTimeStep to use in seconds
  130019. */
  130020. setFixedTimeStep(fixedTimeStep: number): void;
  130021. /**
  130022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  130023. * @param maxSteps the maximum number of steps by the physics engine per frame
  130024. */
  130025. setMaxSteps(maxSteps: number): void;
  130026. /**
  130027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  130028. * @returns the current timestep in seconds
  130029. */
  130030. getTimeStep(): number;
  130031. /**
  130032. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  130033. */
  130034. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130035. private _isImpostorInContact;
  130036. private _isImpostorPairInContact;
  130037. private _stepSimulation;
  130038. /**
  130039. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130040. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130041. * After the step the babylon meshes are set to the position of the physics imposters
  130042. * @param delta amount of time to step forward
  130043. * @param impostors array of imposters to update before/after the step
  130044. */
  130045. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130046. /**
  130047. * Update babylon mesh to match physics world object
  130048. * @param impostor imposter to match
  130049. */
  130050. private _afterSoftStep;
  130051. /**
  130052. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130053. * @param impostor imposter to match
  130054. */
  130055. private _ropeStep;
  130056. /**
  130057. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130058. * @param impostor imposter to match
  130059. */
  130060. private _softbodyOrClothStep;
  130061. private _tmpMatrix;
  130062. /**
  130063. * Applies an impulse on the imposter
  130064. * @param impostor imposter to apply impulse to
  130065. * @param force amount of force to be applied to the imposter
  130066. * @param contactPoint the location to apply the impulse on the imposter
  130067. */
  130068. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130069. /**
  130070. * Applies a force on the imposter
  130071. * @param impostor imposter to apply force
  130072. * @param force amount of force to be applied to the imposter
  130073. * @param contactPoint the location to apply the force on the imposter
  130074. */
  130075. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130076. /**
  130077. * Creates a physics body using the plugin
  130078. * @param impostor the imposter to create the physics body on
  130079. */
  130080. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130081. /**
  130082. * Removes the physics body from the imposter and disposes of the body's memory
  130083. * @param impostor imposter to remove the physics body from
  130084. */
  130085. removePhysicsBody(impostor: PhysicsImpostor): void;
  130086. /**
  130087. * Generates a joint
  130088. * @param impostorJoint the imposter joint to create the joint with
  130089. */
  130090. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130091. /**
  130092. * Removes a joint
  130093. * @param impostorJoint the imposter joint to remove the joint from
  130094. */
  130095. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130096. private _addMeshVerts;
  130097. /**
  130098. * Initialise the soft body vertices to match its object's (mesh) vertices
  130099. * Softbody vertices (nodes) are in world space and to match this
  130100. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130101. * @param impostor to create the softbody for
  130102. */
  130103. private _softVertexData;
  130104. /**
  130105. * Create an impostor's soft body
  130106. * @param impostor to create the softbody for
  130107. */
  130108. private _createSoftbody;
  130109. /**
  130110. * Create cloth for an impostor
  130111. * @param impostor to create the softbody for
  130112. */
  130113. private _createCloth;
  130114. /**
  130115. * Create rope for an impostor
  130116. * @param impostor to create the softbody for
  130117. */
  130118. private _createRope;
  130119. /**
  130120. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130121. * @param impostor to create the custom physics shape for
  130122. */
  130123. private _createCustom;
  130124. private _addHullVerts;
  130125. private _createShape;
  130126. /**
  130127. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130128. * @param impostor imposter containing the physics body and babylon object
  130129. */
  130130. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130131. /**
  130132. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130133. * @param impostor imposter containing the physics body and babylon object
  130134. * @param newPosition new position
  130135. * @param newRotation new rotation
  130136. */
  130137. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130138. /**
  130139. * If this plugin is supported
  130140. * @returns true if its supported
  130141. */
  130142. isSupported(): boolean;
  130143. /**
  130144. * Sets the linear velocity of the physics body
  130145. * @param impostor imposter to set the velocity on
  130146. * @param velocity velocity to set
  130147. */
  130148. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130149. /**
  130150. * Sets the angular velocity of the physics body
  130151. * @param impostor imposter to set the velocity on
  130152. * @param velocity velocity to set
  130153. */
  130154. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130155. /**
  130156. * gets the linear velocity
  130157. * @param impostor imposter to get linear velocity from
  130158. * @returns linear velocity
  130159. */
  130160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130161. /**
  130162. * gets the angular velocity
  130163. * @param impostor imposter to get angular velocity from
  130164. * @returns angular velocity
  130165. */
  130166. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130167. /**
  130168. * Sets the mass of physics body
  130169. * @param impostor imposter to set the mass on
  130170. * @param mass mass to set
  130171. */
  130172. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130173. /**
  130174. * Gets the mass of the physics body
  130175. * @param impostor imposter to get the mass from
  130176. * @returns mass
  130177. */
  130178. getBodyMass(impostor: PhysicsImpostor): number;
  130179. /**
  130180. * Gets friction of the impostor
  130181. * @param impostor impostor to get friction from
  130182. * @returns friction value
  130183. */
  130184. getBodyFriction(impostor: PhysicsImpostor): number;
  130185. /**
  130186. * Sets friction of the impostor
  130187. * @param impostor impostor to set friction on
  130188. * @param friction friction value
  130189. */
  130190. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130191. /**
  130192. * Gets restitution of the impostor
  130193. * @param impostor impostor to get restitution from
  130194. * @returns restitution value
  130195. */
  130196. getBodyRestitution(impostor: PhysicsImpostor): number;
  130197. /**
  130198. * Sets resitution of the impostor
  130199. * @param impostor impostor to set resitution on
  130200. * @param restitution resitution value
  130201. */
  130202. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130203. /**
  130204. * Gets pressure inside the impostor
  130205. * @param impostor impostor to get pressure from
  130206. * @returns pressure value
  130207. */
  130208. getBodyPressure(impostor: PhysicsImpostor): number;
  130209. /**
  130210. * Sets pressure inside a soft body impostor
  130211. * Cloth and rope must remain 0 pressure
  130212. * @param impostor impostor to set pressure on
  130213. * @param pressure pressure value
  130214. */
  130215. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130216. /**
  130217. * Gets stiffness of the impostor
  130218. * @param impostor impostor to get stiffness from
  130219. * @returns pressure value
  130220. */
  130221. getBodyStiffness(impostor: PhysicsImpostor): number;
  130222. /**
  130223. * Sets stiffness of the impostor
  130224. * @param impostor impostor to set stiffness on
  130225. * @param stiffness stiffness value from 0 to 1
  130226. */
  130227. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130228. /**
  130229. * Gets velocityIterations of the impostor
  130230. * @param impostor impostor to get velocity iterations from
  130231. * @returns velocityIterations value
  130232. */
  130233. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130234. /**
  130235. * Sets velocityIterations of the impostor
  130236. * @param impostor impostor to set velocity iterations on
  130237. * @param velocityIterations velocityIterations value
  130238. */
  130239. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130240. /**
  130241. * Gets positionIterations of the impostor
  130242. * @param impostor impostor to get position iterations from
  130243. * @returns positionIterations value
  130244. */
  130245. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130246. /**
  130247. * Sets positionIterations of the impostor
  130248. * @param impostor impostor to set position on
  130249. * @param positionIterations positionIterations value
  130250. */
  130251. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130252. /**
  130253. * Append an anchor to a cloth object
  130254. * @param impostor is the cloth impostor to add anchor to
  130255. * @param otherImpostor is the rigid impostor to anchor to
  130256. * @param width ratio across width from 0 to 1
  130257. * @param height ratio up height from 0 to 1
  130258. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130259. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130260. */
  130261. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130262. /**
  130263. * Append an hook to a rope object
  130264. * @param impostor is the rope impostor to add hook to
  130265. * @param otherImpostor is the rigid impostor to hook to
  130266. * @param length ratio along the rope from 0 to 1
  130267. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130269. */
  130270. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130271. /**
  130272. * Sleeps the physics body and stops it from being active
  130273. * @param impostor impostor to sleep
  130274. */
  130275. sleepBody(impostor: PhysicsImpostor): void;
  130276. /**
  130277. * Activates the physics body
  130278. * @param impostor impostor to activate
  130279. */
  130280. wakeUpBody(impostor: PhysicsImpostor): void;
  130281. /**
  130282. * Updates the distance parameters of the joint
  130283. * @param joint joint to update
  130284. * @param maxDistance maximum distance of the joint
  130285. * @param minDistance minimum distance of the joint
  130286. */
  130287. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130288. /**
  130289. * Sets a motor on the joint
  130290. * @param joint joint to set motor on
  130291. * @param speed speed of the motor
  130292. * @param maxForce maximum force of the motor
  130293. * @param motorIndex index of the motor
  130294. */
  130295. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130296. /**
  130297. * Sets the motors limit
  130298. * @param joint joint to set limit on
  130299. * @param upperLimit upper limit
  130300. * @param lowerLimit lower limit
  130301. */
  130302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130303. /**
  130304. * Syncs the position and rotation of a mesh with the impostor
  130305. * @param mesh mesh to sync
  130306. * @param impostor impostor to update the mesh with
  130307. */
  130308. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130309. /**
  130310. * Gets the radius of the impostor
  130311. * @param impostor impostor to get radius from
  130312. * @returns the radius
  130313. */
  130314. getRadius(impostor: PhysicsImpostor): number;
  130315. /**
  130316. * Gets the box size of the impostor
  130317. * @param impostor impostor to get box size from
  130318. * @param result the resulting box size
  130319. */
  130320. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130321. /**
  130322. * Disposes of the impostor
  130323. */
  130324. dispose(): void;
  130325. /**
  130326. * Does a raycast in the physics world
  130327. * @param from when should the ray start?
  130328. * @param to when should the ray end?
  130329. * @returns PhysicsRaycastResult
  130330. */
  130331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130332. }
  130333. }
  130334. declare module BABYLON {
  130335. interface AbstractScene {
  130336. /**
  130337. * The list of reflection probes added to the scene
  130338. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130339. */
  130340. reflectionProbes: Array<ReflectionProbe>;
  130341. /**
  130342. * Removes the given reflection probe from this scene.
  130343. * @param toRemove The reflection probe to remove
  130344. * @returns The index of the removed reflection probe
  130345. */
  130346. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130347. /**
  130348. * Adds the given reflection probe to this scene.
  130349. * @param newReflectionProbe The reflection probe to add
  130350. */
  130351. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130352. }
  130353. /**
  130354. * Class used to generate realtime reflection / refraction cube textures
  130355. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130356. */
  130357. export class ReflectionProbe {
  130358. /** defines the name of the probe */
  130359. name: string;
  130360. private _scene;
  130361. private _renderTargetTexture;
  130362. private _projectionMatrix;
  130363. private _viewMatrix;
  130364. private _target;
  130365. private _add;
  130366. private _attachedMesh;
  130367. private _invertYAxis;
  130368. /** Gets or sets probe position (center of the cube map) */
  130369. position: Vector3;
  130370. /**
  130371. * Creates a new reflection probe
  130372. * @param name defines the name of the probe
  130373. * @param size defines the texture resolution (for each face)
  130374. * @param scene defines the hosting scene
  130375. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130376. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130377. */
  130378. constructor(
  130379. /** defines the name of the probe */
  130380. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130381. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130382. get samples(): number;
  130383. set samples(value: number);
  130384. /** Gets or sets the refresh rate to use (on every frame by default) */
  130385. get refreshRate(): number;
  130386. set refreshRate(value: number);
  130387. /**
  130388. * Gets the hosting scene
  130389. * @returns a Scene
  130390. */
  130391. getScene(): Scene;
  130392. /** Gets the internal CubeTexture used to render to */
  130393. get cubeTexture(): RenderTargetTexture;
  130394. /** Gets the list of meshes to render */
  130395. get renderList(): Nullable<AbstractMesh[]>;
  130396. /**
  130397. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130398. * @param mesh defines the mesh to attach to
  130399. */
  130400. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130401. /**
  130402. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130403. * @param renderingGroupId The rendering group id corresponding to its index
  130404. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130405. */
  130406. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130407. /**
  130408. * Clean all associated resources
  130409. */
  130410. dispose(): void;
  130411. /**
  130412. * Converts the reflection probe information to a readable string for debug purpose.
  130413. * @param fullDetails Supports for multiple levels of logging within scene loading
  130414. * @returns the human readable reflection probe info
  130415. */
  130416. toString(fullDetails?: boolean): string;
  130417. /**
  130418. * Get the class name of the relfection probe.
  130419. * @returns "ReflectionProbe"
  130420. */
  130421. getClassName(): string;
  130422. /**
  130423. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130424. * @returns The JSON representation of the texture
  130425. */
  130426. serialize(): any;
  130427. /**
  130428. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130429. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130430. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130431. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130432. * @returns The parsed reflection probe if successful
  130433. */
  130434. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130435. }
  130436. }
  130437. declare module BABYLON {
  130438. /** @hidden */
  130439. export var _BabylonLoaderRegistered: boolean;
  130440. /**
  130441. * Helps setting up some configuration for the babylon file loader.
  130442. */
  130443. export class BabylonFileLoaderConfiguration {
  130444. /**
  130445. * The loader does not allow injecting custom physix engine into the plugins.
  130446. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130447. * So you could set this variable to your engine import to make it work.
  130448. */
  130449. static LoaderInjectedPhysicsEngine: any;
  130450. }
  130451. }
  130452. declare module BABYLON {
  130453. /**
  130454. * The Physically based simple base material of BJS.
  130455. *
  130456. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130457. * It is used as the base class for both the specGloss and metalRough conventions.
  130458. */
  130459. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130460. /**
  130461. * Number of Simultaneous lights allowed on the material.
  130462. */
  130463. maxSimultaneousLights: number;
  130464. /**
  130465. * If sets to true, disables all the lights affecting the material.
  130466. */
  130467. disableLighting: boolean;
  130468. /**
  130469. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130470. */
  130471. environmentTexture: BaseTexture;
  130472. /**
  130473. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130474. */
  130475. invertNormalMapX: boolean;
  130476. /**
  130477. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130478. */
  130479. invertNormalMapY: boolean;
  130480. /**
  130481. * Normal map used in the model.
  130482. */
  130483. normalTexture: BaseTexture;
  130484. /**
  130485. * Emissivie color used to self-illuminate the model.
  130486. */
  130487. emissiveColor: Color3;
  130488. /**
  130489. * Emissivie texture used to self-illuminate the model.
  130490. */
  130491. emissiveTexture: BaseTexture;
  130492. /**
  130493. * Occlusion Channel Strenght.
  130494. */
  130495. occlusionStrength: number;
  130496. /**
  130497. * Occlusion Texture of the material (adding extra occlusion effects).
  130498. */
  130499. occlusionTexture: BaseTexture;
  130500. /**
  130501. * Defines the alpha limits in alpha test mode.
  130502. */
  130503. alphaCutOff: number;
  130504. /**
  130505. * Gets the current double sided mode.
  130506. */
  130507. get doubleSided(): boolean;
  130508. /**
  130509. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130510. */
  130511. set doubleSided(value: boolean);
  130512. /**
  130513. * Stores the pre-calculated light information of a mesh in a texture.
  130514. */
  130515. lightmapTexture: BaseTexture;
  130516. /**
  130517. * If true, the light map contains occlusion information instead of lighting info.
  130518. */
  130519. useLightmapAsShadowmap: boolean;
  130520. /**
  130521. * Instantiates a new PBRMaterial instance.
  130522. *
  130523. * @param name The material name
  130524. * @param scene The scene the material will be use in.
  130525. */
  130526. constructor(name: string, scene: Scene);
  130527. getClassName(): string;
  130528. }
  130529. }
  130530. declare module BABYLON {
  130531. /**
  130532. * The PBR material of BJS following the metal roughness convention.
  130533. *
  130534. * This fits to the PBR convention in the GLTF definition:
  130535. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130536. */
  130537. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130538. /**
  130539. * The base color has two different interpretations depending on the value of metalness.
  130540. * When the material is a metal, the base color is the specific measured reflectance value
  130541. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130542. * of the material.
  130543. */
  130544. baseColor: Color3;
  130545. /**
  130546. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130547. * well as opacity information in the alpha channel.
  130548. */
  130549. baseTexture: BaseTexture;
  130550. /**
  130551. * Specifies the metallic scalar value of the material.
  130552. * Can also be used to scale the metalness values of the metallic texture.
  130553. */
  130554. metallic: number;
  130555. /**
  130556. * Specifies the roughness scalar value of the material.
  130557. * Can also be used to scale the roughness values of the metallic texture.
  130558. */
  130559. roughness: number;
  130560. /**
  130561. * Texture containing both the metallic value in the B channel and the
  130562. * roughness value in the G channel to keep better precision.
  130563. */
  130564. metallicRoughnessTexture: BaseTexture;
  130565. /**
  130566. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130567. *
  130568. * @param name The material name
  130569. * @param scene The scene the material will be use in.
  130570. */
  130571. constructor(name: string, scene: Scene);
  130572. /**
  130573. * Return the currrent class name of the material.
  130574. */
  130575. getClassName(): string;
  130576. /**
  130577. * Makes a duplicate of the current material.
  130578. * @param name - name to use for the new material.
  130579. */
  130580. clone(name: string): PBRMetallicRoughnessMaterial;
  130581. /**
  130582. * Serialize the material to a parsable JSON object.
  130583. */
  130584. serialize(): any;
  130585. /**
  130586. * Parses a JSON object correponding to the serialize function.
  130587. */
  130588. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130589. }
  130590. }
  130591. declare module BABYLON {
  130592. /**
  130593. * The PBR material of BJS following the specular glossiness convention.
  130594. *
  130595. * This fits to the PBR convention in the GLTF definition:
  130596. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130597. */
  130598. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130599. /**
  130600. * Specifies the diffuse color of the material.
  130601. */
  130602. diffuseColor: Color3;
  130603. /**
  130604. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130605. * channel.
  130606. */
  130607. diffuseTexture: BaseTexture;
  130608. /**
  130609. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130610. */
  130611. specularColor: Color3;
  130612. /**
  130613. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130614. */
  130615. glossiness: number;
  130616. /**
  130617. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130618. */
  130619. specularGlossinessTexture: BaseTexture;
  130620. /**
  130621. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130622. *
  130623. * @param name The material name
  130624. * @param scene The scene the material will be use in.
  130625. */
  130626. constructor(name: string, scene: Scene);
  130627. /**
  130628. * Return the currrent class name of the material.
  130629. */
  130630. getClassName(): string;
  130631. /**
  130632. * Makes a duplicate of the current material.
  130633. * @param name - name to use for the new material.
  130634. */
  130635. clone(name: string): PBRSpecularGlossinessMaterial;
  130636. /**
  130637. * Serialize the material to a parsable JSON object.
  130638. */
  130639. serialize(): any;
  130640. /**
  130641. * Parses a JSON object correponding to the serialize function.
  130642. */
  130643. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130644. }
  130645. }
  130646. declare module BABYLON {
  130647. /**
  130648. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130649. * It can help converting any input color in a desired output one. This can then be used to create effects
  130650. * from sepia, black and white to sixties or futuristic rendering...
  130651. *
  130652. * The only supported format is currently 3dl.
  130653. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130654. */
  130655. export class ColorGradingTexture extends BaseTexture {
  130656. /**
  130657. * The current texture matrix. (will always be identity in color grading texture)
  130658. */
  130659. private _textureMatrix;
  130660. /**
  130661. * The texture URL.
  130662. */
  130663. url: string;
  130664. /**
  130665. * Empty line regex stored for GC.
  130666. */
  130667. private static _noneEmptyLineRegex;
  130668. private _engine;
  130669. /**
  130670. * Instantiates a ColorGradingTexture from the following parameters.
  130671. *
  130672. * @param url The location of the color gradind data (currently only supporting 3dl)
  130673. * @param scene The scene the texture will be used in
  130674. */
  130675. constructor(url: string, scene: Scene);
  130676. /**
  130677. * Returns the texture matrix used in most of the material.
  130678. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130679. */
  130680. getTextureMatrix(): Matrix;
  130681. /**
  130682. * Occurs when the file being loaded is a .3dl LUT file.
  130683. */
  130684. private load3dlTexture;
  130685. /**
  130686. * Starts the loading process of the texture.
  130687. */
  130688. private loadTexture;
  130689. /**
  130690. * Clones the color gradind texture.
  130691. */
  130692. clone(): ColorGradingTexture;
  130693. /**
  130694. * Called during delayed load for textures.
  130695. */
  130696. delayLoad(): void;
  130697. /**
  130698. * Parses a color grading texture serialized by Babylon.
  130699. * @param parsedTexture The texture information being parsedTexture
  130700. * @param scene The scene to load the texture in
  130701. * @param rootUrl The root url of the data assets to load
  130702. * @return A color gradind texture
  130703. */
  130704. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130705. /**
  130706. * Serializes the LUT texture to json format.
  130707. */
  130708. serialize(): any;
  130709. }
  130710. }
  130711. declare module BABYLON {
  130712. /**
  130713. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130714. */
  130715. export class EquiRectangularCubeTexture extends BaseTexture {
  130716. /** The six faces of the cube. */
  130717. private static _FacesMapping;
  130718. private _noMipmap;
  130719. private _onLoad;
  130720. private _onError;
  130721. /** The size of the cubemap. */
  130722. private _size;
  130723. /** The buffer of the image. */
  130724. private _buffer;
  130725. /** The width of the input image. */
  130726. private _width;
  130727. /** The height of the input image. */
  130728. private _height;
  130729. /** The URL to the image. */
  130730. url: string;
  130731. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130732. coordinatesMode: number;
  130733. /**
  130734. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130735. * @param url The location of the image
  130736. * @param scene The scene the texture will be used in
  130737. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130738. * @param noMipmap Forces to not generate the mipmap if true
  130739. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130740. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130741. * @param onLoad — defines a callback called when texture is loaded
  130742. * @param onError — defines a callback called if there is an error
  130743. */
  130744. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130745. /**
  130746. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130747. */
  130748. private loadImage;
  130749. /**
  130750. * Convert the image buffer into a cubemap and create a CubeTexture.
  130751. */
  130752. private loadTexture;
  130753. /**
  130754. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130755. * @param buffer The ArrayBuffer that should be converted.
  130756. * @returns The buffer as Float32Array.
  130757. */
  130758. private getFloat32ArrayFromArrayBuffer;
  130759. /**
  130760. * Get the current class name of the texture useful for serialization or dynamic coding.
  130761. * @returns "EquiRectangularCubeTexture"
  130762. */
  130763. getClassName(): string;
  130764. /**
  130765. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130766. * @returns A clone of the current EquiRectangularCubeTexture.
  130767. */
  130768. clone(): EquiRectangularCubeTexture;
  130769. }
  130770. }
  130771. declare module BABYLON {
  130772. /**
  130773. * Based on jsTGALoader - Javascript loader for TGA file
  130774. * By Vincent Thibault
  130775. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130776. */
  130777. export class TGATools {
  130778. private static _TYPE_INDEXED;
  130779. private static _TYPE_RGB;
  130780. private static _TYPE_GREY;
  130781. private static _TYPE_RLE_INDEXED;
  130782. private static _TYPE_RLE_RGB;
  130783. private static _TYPE_RLE_GREY;
  130784. private static _ORIGIN_MASK;
  130785. private static _ORIGIN_SHIFT;
  130786. private static _ORIGIN_BL;
  130787. private static _ORIGIN_BR;
  130788. private static _ORIGIN_UL;
  130789. private static _ORIGIN_UR;
  130790. /**
  130791. * Gets the header of a TGA file
  130792. * @param data defines the TGA data
  130793. * @returns the header
  130794. */
  130795. static GetTGAHeader(data: Uint8Array): any;
  130796. /**
  130797. * Uploads TGA content to a Babylon Texture
  130798. * @hidden
  130799. */
  130800. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130801. /** @hidden */
  130802. 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;
  130803. /** @hidden */
  130804. 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;
  130805. /** @hidden */
  130806. 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;
  130807. /** @hidden */
  130808. 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;
  130809. /** @hidden */
  130810. 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;
  130811. /** @hidden */
  130812. 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;
  130813. }
  130814. }
  130815. declare module BABYLON {
  130816. /**
  130817. * Implementation of the TGA Texture Loader.
  130818. * @hidden
  130819. */
  130820. export class _TGATextureLoader implements IInternalTextureLoader {
  130821. /**
  130822. * Defines wether the loader supports cascade loading the different faces.
  130823. */
  130824. readonly supportCascades: boolean;
  130825. /**
  130826. * This returns if the loader support the current file information.
  130827. * @param extension defines the file extension of the file being loaded
  130828. * @returns true if the loader can load the specified file
  130829. */
  130830. canLoad(extension: string): boolean;
  130831. /**
  130832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130833. * @param data contains the texture data
  130834. * @param texture defines the BabylonJS internal texture
  130835. * @param createPolynomials will be true if polynomials have been requested
  130836. * @param onLoad defines the callback to trigger once the texture is ready
  130837. * @param onError defines the callback to trigger in case of error
  130838. */
  130839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130840. /**
  130841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130842. * @param data contains the texture data
  130843. * @param texture defines the BabylonJS internal texture
  130844. * @param callback defines the method to call once ready to upload
  130845. */
  130846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130847. }
  130848. }
  130849. declare module BABYLON {
  130850. /**
  130851. * Info about the .basis files
  130852. */
  130853. class BasisFileInfo {
  130854. /**
  130855. * If the file has alpha
  130856. */
  130857. hasAlpha: boolean;
  130858. /**
  130859. * Info about each image of the basis file
  130860. */
  130861. images: Array<{
  130862. levels: Array<{
  130863. width: number;
  130864. height: number;
  130865. transcodedPixels: ArrayBufferView;
  130866. }>;
  130867. }>;
  130868. }
  130869. /**
  130870. * Result of transcoding a basis file
  130871. */
  130872. class TranscodeResult {
  130873. /**
  130874. * Info about the .basis file
  130875. */
  130876. fileInfo: BasisFileInfo;
  130877. /**
  130878. * Format to use when loading the file
  130879. */
  130880. format: number;
  130881. }
  130882. /**
  130883. * Configuration options for the Basis transcoder
  130884. */
  130885. export class BasisTranscodeConfiguration {
  130886. /**
  130887. * Supported compression formats used to determine the supported output format of the transcoder
  130888. */
  130889. supportedCompressionFormats?: {
  130890. /**
  130891. * etc1 compression format
  130892. */
  130893. etc1?: boolean;
  130894. /**
  130895. * s3tc compression format
  130896. */
  130897. s3tc?: boolean;
  130898. /**
  130899. * pvrtc compression format
  130900. */
  130901. pvrtc?: boolean;
  130902. /**
  130903. * etc2 compression format
  130904. */
  130905. etc2?: boolean;
  130906. };
  130907. /**
  130908. * If mipmap levels should be loaded for transcoded images (Default: true)
  130909. */
  130910. loadMipmapLevels?: boolean;
  130911. /**
  130912. * Index of a single image to load (Default: all images)
  130913. */
  130914. loadSingleImage?: number;
  130915. }
  130916. /**
  130917. * Used to load .Basis files
  130918. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130919. */
  130920. export class BasisTools {
  130921. private static _IgnoreSupportedFormats;
  130922. /**
  130923. * URL to use when loading the basis transcoder
  130924. */
  130925. static JSModuleURL: string;
  130926. /**
  130927. * URL to use when loading the wasm module for the transcoder
  130928. */
  130929. static WasmModuleURL: string;
  130930. /**
  130931. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130932. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130933. * @returns internal format corresponding to the Basis format
  130934. */
  130935. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130936. private static _WorkerPromise;
  130937. private static _Worker;
  130938. private static _actionId;
  130939. private static _CreateWorkerAsync;
  130940. /**
  130941. * Transcodes a loaded image file to compressed pixel data
  130942. * @param data image data to transcode
  130943. * @param config configuration options for the transcoding
  130944. * @returns a promise resulting in the transcoded image
  130945. */
  130946. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130947. /**
  130948. * Loads a texture from the transcode result
  130949. * @param texture texture load to
  130950. * @param transcodeResult the result of transcoding the basis file to load from
  130951. */
  130952. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130953. }
  130954. }
  130955. declare module BABYLON {
  130956. /**
  130957. * Loader for .basis file format
  130958. */
  130959. export class _BasisTextureLoader implements IInternalTextureLoader {
  130960. /**
  130961. * Defines whether the loader supports cascade loading the different faces.
  130962. */
  130963. readonly supportCascades: boolean;
  130964. /**
  130965. * This returns if the loader support the current file information.
  130966. * @param extension defines the file extension of the file being loaded
  130967. * @returns true if the loader can load the specified file
  130968. */
  130969. canLoad(extension: string): boolean;
  130970. /**
  130971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130972. * @param data contains the texture data
  130973. * @param texture defines the BabylonJS internal texture
  130974. * @param createPolynomials will be true if polynomials have been requested
  130975. * @param onLoad defines the callback to trigger once the texture is ready
  130976. * @param onError defines the callback to trigger in case of error
  130977. */
  130978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130979. /**
  130980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130981. * @param data contains the texture data
  130982. * @param texture defines the BabylonJS internal texture
  130983. * @param callback defines the method to call once ready to upload
  130984. */
  130985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130986. }
  130987. }
  130988. declare module BABYLON {
  130989. /**
  130990. * 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.
  130991. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130992. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130993. */
  130994. export class CustomProceduralTexture extends ProceduralTexture {
  130995. private _animate;
  130996. private _time;
  130997. private _config;
  130998. private _texturePath;
  130999. /**
  131000. * Instantiates a new Custom Procedural Texture.
  131001. * 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.
  131002. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  131003. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  131004. * @param name Define the name of the texture
  131005. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  131006. * @param size Define the size of the texture to create
  131007. * @param scene Define the scene the texture belongs to
  131008. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  131009. * @param generateMipMaps Define if the texture should creates mip maps or not
  131010. */
  131011. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131012. private _loadJson;
  131013. /**
  131014. * Is the texture ready to be used ? (rendered at least once)
  131015. * @returns true if ready, otherwise, false.
  131016. */
  131017. isReady(): boolean;
  131018. /**
  131019. * Render the texture to its associated render target.
  131020. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  131021. */
  131022. render(useCameraPostProcess?: boolean): void;
  131023. /**
  131024. * Update the list of dependant textures samplers in the shader.
  131025. */
  131026. updateTextures(): void;
  131027. /**
  131028. * Update the uniform values of the procedural texture in the shader.
  131029. */
  131030. updateShaderUniforms(): void;
  131031. /**
  131032. * Define if the texture animates or not.
  131033. */
  131034. get animate(): boolean;
  131035. set animate(value: boolean);
  131036. }
  131037. }
  131038. declare module BABYLON {
  131039. /** @hidden */
  131040. export var noisePixelShader: {
  131041. name: string;
  131042. shader: string;
  131043. };
  131044. }
  131045. declare module BABYLON {
  131046. /**
  131047. * Class used to generate noise procedural textures
  131048. */
  131049. export class NoiseProceduralTexture extends ProceduralTexture {
  131050. private _time;
  131051. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131052. brightness: number;
  131053. /** Defines the number of octaves to process */
  131054. octaves: number;
  131055. /** Defines the level of persistence (0.8 by default) */
  131056. persistence: number;
  131057. /** Gets or sets animation speed factor (default is 1) */
  131058. animationSpeedFactor: number;
  131059. /**
  131060. * Creates a new NoiseProceduralTexture
  131061. * @param name defines the name fo the texture
  131062. * @param size defines the size of the texture (default is 256)
  131063. * @param scene defines the hosting scene
  131064. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131065. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131066. */
  131067. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131068. private _updateShaderUniforms;
  131069. protected _getDefines(): string;
  131070. /** Generate the current state of the procedural texture */
  131071. render(useCameraPostProcess?: boolean): void;
  131072. /**
  131073. * Serializes this noise procedural texture
  131074. * @returns a serialized noise procedural texture object
  131075. */
  131076. serialize(): any;
  131077. /**
  131078. * Clone the texture.
  131079. * @returns the cloned texture
  131080. */
  131081. clone(): NoiseProceduralTexture;
  131082. /**
  131083. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131084. * @param parsedTexture defines parsed texture data
  131085. * @param scene defines the current scene
  131086. * @param rootUrl defines the root URL containing noise procedural texture information
  131087. * @returns a parsed NoiseProceduralTexture
  131088. */
  131089. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131090. }
  131091. }
  131092. declare module BABYLON {
  131093. /**
  131094. * Raw cube texture where the raw buffers are passed in
  131095. */
  131096. export class RawCubeTexture extends CubeTexture {
  131097. /**
  131098. * Creates a cube texture where the raw buffers are passed in.
  131099. * @param scene defines the scene the texture is attached to
  131100. * @param data defines the array of data to use to create each face
  131101. * @param size defines the size of the textures
  131102. * @param format defines the format of the data
  131103. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131104. * @param generateMipMaps defines if the engine should generate the mip levels
  131105. * @param invertY defines if data must be stored with Y axis inverted
  131106. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131107. * @param compression defines the compression used (null by default)
  131108. */
  131109. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131110. /**
  131111. * Updates the raw cube texture.
  131112. * @param data defines the data to store
  131113. * @param format defines the data format
  131114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131115. * @param invertY defines if data must be stored with Y axis inverted
  131116. * @param compression defines the compression used (null by default)
  131117. * @param level defines which level of the texture to update
  131118. */
  131119. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131120. /**
  131121. * Updates a raw cube texture with RGBD encoded data.
  131122. * @param data defines the array of data [mipmap][face] to use to create each face
  131123. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131124. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131125. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131126. * @returns a promsie that resolves when the operation is complete
  131127. */
  131128. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131129. /**
  131130. * Clones the raw cube texture.
  131131. * @return a new cube texture
  131132. */
  131133. clone(): CubeTexture;
  131134. /** @hidden */
  131135. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131136. }
  131137. }
  131138. declare module BABYLON {
  131139. /**
  131140. * Class used to store 3D textures containing user data
  131141. */
  131142. export class RawTexture3D extends Texture {
  131143. /** Gets or sets the texture format to use */
  131144. format: number;
  131145. private _engine;
  131146. /**
  131147. * Create a new RawTexture3D
  131148. * @param data defines the data of the texture
  131149. * @param width defines the width of the texture
  131150. * @param height defines the height of the texture
  131151. * @param depth defines the depth of the texture
  131152. * @param format defines the texture format to use
  131153. * @param scene defines the hosting scene
  131154. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131155. * @param invertY defines if texture must be stored with Y axis inverted
  131156. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131157. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131158. */
  131159. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131160. /** Gets or sets the texture format to use */
  131161. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131162. /**
  131163. * Update the texture with new data
  131164. * @param data defines the data to store in the texture
  131165. */
  131166. update(data: ArrayBufferView): void;
  131167. }
  131168. }
  131169. declare module BABYLON {
  131170. /**
  131171. * Class used to store 2D array textures containing user data
  131172. */
  131173. export class RawTexture2DArray extends Texture {
  131174. /** Gets or sets the texture format to use */
  131175. format: number;
  131176. private _engine;
  131177. /**
  131178. * Create a new RawTexture2DArray
  131179. * @param data defines the data of the texture
  131180. * @param width defines the width of the texture
  131181. * @param height defines the height of the texture
  131182. * @param depth defines the number of layers of the texture
  131183. * @param format defines the texture format to use
  131184. * @param scene defines the hosting scene
  131185. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131186. * @param invertY defines if texture must be stored with Y axis inverted
  131187. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131188. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131189. */
  131190. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131191. /** Gets or sets the texture format to use */
  131192. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131193. /**
  131194. * Update the texture with new data
  131195. * @param data defines the data to store in the texture
  131196. */
  131197. update(data: ArrayBufferView): void;
  131198. }
  131199. }
  131200. declare module BABYLON {
  131201. /**
  131202. * Creates a refraction texture used by refraction channel of the standard material.
  131203. * It is like a mirror but to see through a material.
  131204. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131205. */
  131206. export class RefractionTexture extends RenderTargetTexture {
  131207. /**
  131208. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131209. * 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.
  131210. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131211. */
  131212. refractionPlane: Plane;
  131213. /**
  131214. * Define how deep under the surface we should see.
  131215. */
  131216. depth: number;
  131217. /**
  131218. * Creates a refraction texture used by refraction channel of the standard material.
  131219. * It is like a mirror but to see through a material.
  131220. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131221. * @param name Define the texture name
  131222. * @param size Define the size of the underlying texture
  131223. * @param scene Define the scene the refraction belongs to
  131224. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131225. */
  131226. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131227. /**
  131228. * Clone the refraction texture.
  131229. * @returns the cloned texture
  131230. */
  131231. clone(): RefractionTexture;
  131232. /**
  131233. * Serialize the texture to a JSON representation you could use in Parse later on
  131234. * @returns the serialized JSON representation
  131235. */
  131236. serialize(): any;
  131237. }
  131238. }
  131239. declare module BABYLON {
  131240. /**
  131241. * Defines the options related to the creation of an HtmlElementTexture
  131242. */
  131243. export interface IHtmlElementTextureOptions {
  131244. /**
  131245. * Defines wether mip maps should be created or not.
  131246. */
  131247. generateMipMaps?: boolean;
  131248. /**
  131249. * Defines the sampling mode of the texture.
  131250. */
  131251. samplingMode?: number;
  131252. /**
  131253. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131254. */
  131255. engine: Nullable<ThinEngine>;
  131256. /**
  131257. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131258. */
  131259. scene: Nullable<Scene>;
  131260. }
  131261. /**
  131262. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131263. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131264. * is automatically managed.
  131265. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131266. * in your application.
  131267. *
  131268. * As the update is not automatic, you need to call them manually.
  131269. */
  131270. export class HtmlElementTexture extends BaseTexture {
  131271. /**
  131272. * The texture URL.
  131273. */
  131274. element: HTMLVideoElement | HTMLCanvasElement;
  131275. private static readonly DefaultOptions;
  131276. private _textureMatrix;
  131277. private _engine;
  131278. private _isVideo;
  131279. private _generateMipMaps;
  131280. private _samplingMode;
  131281. /**
  131282. * Instantiates a HtmlElementTexture from the following parameters.
  131283. *
  131284. * @param name Defines the name of the texture
  131285. * @param element Defines the video or canvas the texture is filled with
  131286. * @param options Defines the other none mandatory texture creation options
  131287. */
  131288. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131289. private _createInternalTexture;
  131290. /**
  131291. * Returns the texture matrix used in most of the material.
  131292. */
  131293. getTextureMatrix(): Matrix;
  131294. /**
  131295. * Updates the content of the texture.
  131296. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131297. */
  131298. update(invertY?: Nullable<boolean>): void;
  131299. }
  131300. }
  131301. declare module BABYLON {
  131302. /**
  131303. * Defines the basic options interface of a TexturePacker Frame
  131304. */
  131305. export interface ITexturePackerFrame {
  131306. /**
  131307. * The frame ID
  131308. */
  131309. id: number;
  131310. /**
  131311. * The frames Scale
  131312. */
  131313. scale: Vector2;
  131314. /**
  131315. * The Frames offset
  131316. */
  131317. offset: Vector2;
  131318. }
  131319. /**
  131320. * This is a support class for frame Data on texture packer sets.
  131321. */
  131322. export class TexturePackerFrame implements ITexturePackerFrame {
  131323. /**
  131324. * The frame ID
  131325. */
  131326. id: number;
  131327. /**
  131328. * The frames Scale
  131329. */
  131330. scale: Vector2;
  131331. /**
  131332. * The Frames offset
  131333. */
  131334. offset: Vector2;
  131335. /**
  131336. * Initializes a texture package frame.
  131337. * @param id The numerical frame identifier
  131338. * @param scale Scalar Vector2 for UV frame
  131339. * @param offset Vector2 for the frame position in UV units.
  131340. * @returns TexturePackerFrame
  131341. */
  131342. constructor(id: number, scale: Vector2, offset: Vector2);
  131343. }
  131344. }
  131345. declare module BABYLON {
  131346. /**
  131347. * Defines the basic options interface of a TexturePacker
  131348. */
  131349. export interface ITexturePackerOptions {
  131350. /**
  131351. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131352. */
  131353. map?: string[];
  131354. /**
  131355. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131356. */
  131357. uvsIn?: string;
  131358. /**
  131359. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131360. */
  131361. uvsOut?: string;
  131362. /**
  131363. * number representing the layout style. Defaults to LAYOUT_STRIP
  131364. */
  131365. layout?: number;
  131366. /**
  131367. * number of columns if using custom column count layout(2). This defaults to 4.
  131368. */
  131369. colnum?: number;
  131370. /**
  131371. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131372. */
  131373. updateInputMeshes?: boolean;
  131374. /**
  131375. * boolean flag to dispose all the source textures. Defaults to true.
  131376. */
  131377. disposeSources?: boolean;
  131378. /**
  131379. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131380. */
  131381. fillBlanks?: boolean;
  131382. /**
  131383. * string value representing the context fill style color. Defaults to 'black'.
  131384. */
  131385. customFillColor?: string;
  131386. /**
  131387. * Width and Height Value of each Frame in the TexturePacker Sets
  131388. */
  131389. frameSize?: number;
  131390. /**
  131391. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131392. */
  131393. paddingRatio?: number;
  131394. /**
  131395. * Number that declares the fill method for the padding gutter.
  131396. */
  131397. paddingMode?: number;
  131398. /**
  131399. * If in SUBUV_COLOR padding mode what color to use.
  131400. */
  131401. paddingColor?: Color3 | Color4;
  131402. }
  131403. /**
  131404. * Defines the basic interface of a TexturePacker JSON File
  131405. */
  131406. export interface ITexturePackerJSON {
  131407. /**
  131408. * The frame ID
  131409. */
  131410. name: string;
  131411. /**
  131412. * The base64 channel data
  131413. */
  131414. sets: any;
  131415. /**
  131416. * The options of the Packer
  131417. */
  131418. options: ITexturePackerOptions;
  131419. /**
  131420. * The frame data of the Packer
  131421. */
  131422. frames: Array<number>;
  131423. }
  131424. /**
  131425. * This is a support class that generates a series of packed texture sets.
  131426. * @see https://doc.babylonjs.com/babylon101/materials
  131427. */
  131428. export class TexturePacker {
  131429. /** Packer Layout Constant 0 */
  131430. static readonly LAYOUT_STRIP: number;
  131431. /** Packer Layout Constant 1 */
  131432. static readonly LAYOUT_POWER2: number;
  131433. /** Packer Layout Constant 2 */
  131434. static readonly LAYOUT_COLNUM: number;
  131435. /** Packer Layout Constant 0 */
  131436. static readonly SUBUV_WRAP: number;
  131437. /** Packer Layout Constant 1 */
  131438. static readonly SUBUV_EXTEND: number;
  131439. /** Packer Layout Constant 2 */
  131440. static readonly SUBUV_COLOR: number;
  131441. /** The Name of the Texture Package */
  131442. name: string;
  131443. /** The scene scope of the TexturePacker */
  131444. scene: Scene;
  131445. /** The Meshes to target */
  131446. meshes: AbstractMesh[];
  131447. /** Arguments passed with the Constructor */
  131448. options: ITexturePackerOptions;
  131449. /** The promise that is started upon initialization */
  131450. promise: Nullable<Promise<TexturePacker | string>>;
  131451. /** The Container object for the channel sets that are generated */
  131452. sets: object;
  131453. /** The Container array for the frames that are generated */
  131454. frames: TexturePackerFrame[];
  131455. /** The expected number of textures the system is parsing. */
  131456. private _expecting;
  131457. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131458. private _paddingValue;
  131459. /**
  131460. * Initializes a texture package series from an array of meshes or a single mesh.
  131461. * @param name The name of the package
  131462. * @param meshes The target meshes to compose the package from
  131463. * @param options The arguments that texture packer should follow while building.
  131464. * @param scene The scene which the textures are scoped to.
  131465. * @returns TexturePacker
  131466. */
  131467. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131468. /**
  131469. * Starts the package process
  131470. * @param resolve The promises resolution function
  131471. * @returns TexturePacker
  131472. */
  131473. private _createFrames;
  131474. /**
  131475. * Calculates the Size of the Channel Sets
  131476. * @returns Vector2
  131477. */
  131478. private _calculateSize;
  131479. /**
  131480. * Calculates the UV data for the frames.
  131481. * @param baseSize the base frameSize
  131482. * @param padding the base frame padding
  131483. * @param dtSize size of the Dynamic Texture for that channel
  131484. * @param dtUnits is 1/dtSize
  131485. * @param update flag to update the input meshes
  131486. */
  131487. private _calculateMeshUVFrames;
  131488. /**
  131489. * Calculates the frames Offset.
  131490. * @param index of the frame
  131491. * @returns Vector2
  131492. */
  131493. private _getFrameOffset;
  131494. /**
  131495. * Updates a Mesh to the frame data
  131496. * @param mesh that is the target
  131497. * @param frameID or the frame index
  131498. */
  131499. private _updateMeshUV;
  131500. /**
  131501. * Updates a Meshes materials to use the texture packer channels
  131502. * @param m is the mesh to target
  131503. * @param force all channels on the packer to be set.
  131504. */
  131505. private _updateTextureReferences;
  131506. /**
  131507. * Public method to set a Mesh to a frame
  131508. * @param m that is the target
  131509. * @param frameID or the frame index
  131510. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131511. */
  131512. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131513. /**
  131514. * Starts the async promise to compile the texture packer.
  131515. * @returns Promise<void>
  131516. */
  131517. processAsync(): Promise<void>;
  131518. /**
  131519. * Disposes all textures associated with this packer
  131520. */
  131521. dispose(): void;
  131522. /**
  131523. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131524. * @param imageType is the image type to use.
  131525. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131526. */
  131527. download(imageType?: string, quality?: number): void;
  131528. /**
  131529. * Public method to load a texturePacker JSON file.
  131530. * @param data of the JSON file in string format.
  131531. */
  131532. updateFromJSON(data: string): void;
  131533. }
  131534. }
  131535. declare module BABYLON {
  131536. /**
  131537. * Enum used to define the target of a block
  131538. */
  131539. export enum NodeMaterialBlockTargets {
  131540. /** Vertex shader */
  131541. Vertex = 1,
  131542. /** Fragment shader */
  131543. Fragment = 2,
  131544. /** Neutral */
  131545. Neutral = 4,
  131546. /** Vertex and Fragment */
  131547. VertexAndFragment = 3
  131548. }
  131549. }
  131550. declare module BABYLON {
  131551. /**
  131552. * Defines the kind of connection point for node based material
  131553. */
  131554. export enum NodeMaterialBlockConnectionPointTypes {
  131555. /** Float */
  131556. Float = 1,
  131557. /** Int */
  131558. Int = 2,
  131559. /** Vector2 */
  131560. Vector2 = 4,
  131561. /** Vector3 */
  131562. Vector3 = 8,
  131563. /** Vector4 */
  131564. Vector4 = 16,
  131565. /** Color3 */
  131566. Color3 = 32,
  131567. /** Color4 */
  131568. Color4 = 64,
  131569. /** Matrix */
  131570. Matrix = 128,
  131571. /** Detect type based on connection */
  131572. AutoDetect = 1024,
  131573. /** Output type that will be defined by input type */
  131574. BasedOnInput = 2048
  131575. }
  131576. }
  131577. declare module BABYLON {
  131578. /**
  131579. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131580. */
  131581. export enum NodeMaterialBlockConnectionPointMode {
  131582. /** Value is an uniform */
  131583. Uniform = 0,
  131584. /** Value is a mesh attribute */
  131585. Attribute = 1,
  131586. /** Value is a varying between vertex and fragment shaders */
  131587. Varying = 2,
  131588. /** Mode is undefined */
  131589. Undefined = 3
  131590. }
  131591. }
  131592. declare module BABYLON {
  131593. /**
  131594. * Enum used to define system values e.g. values automatically provided by the system
  131595. */
  131596. export enum NodeMaterialSystemValues {
  131597. /** World */
  131598. World = 1,
  131599. /** View */
  131600. View = 2,
  131601. /** Projection */
  131602. Projection = 3,
  131603. /** ViewProjection */
  131604. ViewProjection = 4,
  131605. /** WorldView */
  131606. WorldView = 5,
  131607. /** WorldViewProjection */
  131608. WorldViewProjection = 6,
  131609. /** CameraPosition */
  131610. CameraPosition = 7,
  131611. /** Fog Color */
  131612. FogColor = 8,
  131613. /** Delta time */
  131614. DeltaTime = 9
  131615. }
  131616. }
  131617. declare module BABYLON {
  131618. /**
  131619. * Root class for all node material optimizers
  131620. */
  131621. export class NodeMaterialOptimizer {
  131622. /**
  131623. * Function used to optimize a NodeMaterial graph
  131624. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131625. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131626. */
  131627. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131628. }
  131629. }
  131630. declare module BABYLON {
  131631. /**
  131632. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131633. */
  131634. export class TransformBlock extends NodeMaterialBlock {
  131635. /**
  131636. * Defines the value to use to complement W value to transform it to a Vector4
  131637. */
  131638. complementW: number;
  131639. /**
  131640. * Defines the value to use to complement z value to transform it to a Vector4
  131641. */
  131642. complementZ: number;
  131643. /**
  131644. * Creates a new TransformBlock
  131645. * @param name defines the block name
  131646. */
  131647. constructor(name: string);
  131648. /**
  131649. * Gets the current class name
  131650. * @returns the class name
  131651. */
  131652. getClassName(): string;
  131653. /**
  131654. * Gets the vector input
  131655. */
  131656. get vector(): NodeMaterialConnectionPoint;
  131657. /**
  131658. * Gets the output component
  131659. */
  131660. get output(): NodeMaterialConnectionPoint;
  131661. /**
  131662. * Gets the xyz output component
  131663. */
  131664. get xyz(): NodeMaterialConnectionPoint;
  131665. /**
  131666. * Gets the matrix transform input
  131667. */
  131668. get transform(): NodeMaterialConnectionPoint;
  131669. protected _buildBlock(state: NodeMaterialBuildState): this;
  131670. serialize(): any;
  131671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131672. protected _dumpPropertiesCode(): string;
  131673. }
  131674. }
  131675. declare module BABYLON {
  131676. /**
  131677. * Block used to output the vertex position
  131678. */
  131679. export class VertexOutputBlock extends NodeMaterialBlock {
  131680. /**
  131681. * Creates a new VertexOutputBlock
  131682. * @param name defines the block name
  131683. */
  131684. constructor(name: string);
  131685. /**
  131686. * Gets the current class name
  131687. * @returns the class name
  131688. */
  131689. getClassName(): string;
  131690. /**
  131691. * Gets the vector input component
  131692. */
  131693. get vector(): NodeMaterialConnectionPoint;
  131694. protected _buildBlock(state: NodeMaterialBuildState): this;
  131695. }
  131696. }
  131697. declare module BABYLON {
  131698. /**
  131699. * Block used to output the final color
  131700. */
  131701. export class FragmentOutputBlock extends NodeMaterialBlock {
  131702. /**
  131703. * Create a new FragmentOutputBlock
  131704. * @param name defines the block name
  131705. */
  131706. constructor(name: string);
  131707. /**
  131708. * Gets the current class name
  131709. * @returns the class name
  131710. */
  131711. getClassName(): string;
  131712. /**
  131713. * Gets the rgba input component
  131714. */
  131715. get rgba(): NodeMaterialConnectionPoint;
  131716. /**
  131717. * Gets the rgb input component
  131718. */
  131719. get rgb(): NodeMaterialConnectionPoint;
  131720. /**
  131721. * Gets the a input component
  131722. */
  131723. get a(): NodeMaterialConnectionPoint;
  131724. protected _buildBlock(state: NodeMaterialBuildState): this;
  131725. }
  131726. }
  131727. declare module BABYLON {
  131728. /**
  131729. * Block used to read a reflection texture from a sampler
  131730. */
  131731. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131732. private _define3DName;
  131733. private _defineCubicName;
  131734. private _defineExplicitName;
  131735. private _defineProjectionName;
  131736. private _defineLocalCubicName;
  131737. private _defineSphericalName;
  131738. private _definePlanarName;
  131739. private _defineEquirectangularName;
  131740. private _defineMirroredEquirectangularFixedName;
  131741. private _defineEquirectangularFixedName;
  131742. private _defineSkyboxName;
  131743. private _cubeSamplerName;
  131744. private _2DSamplerName;
  131745. private _positionUVWName;
  131746. private _directionWName;
  131747. private _reflectionCoordsName;
  131748. private _reflection2DCoordsName;
  131749. private _reflectionColorName;
  131750. private _reflectionMatrixName;
  131751. /**
  131752. * Gets or sets the texture associated with the node
  131753. */
  131754. texture: Nullable<BaseTexture>;
  131755. /**
  131756. * Create a new TextureBlock
  131757. * @param name defines the block name
  131758. */
  131759. constructor(name: string);
  131760. /**
  131761. * Gets the current class name
  131762. * @returns the class name
  131763. */
  131764. getClassName(): string;
  131765. /**
  131766. * Gets the world position input component
  131767. */
  131768. get position(): NodeMaterialConnectionPoint;
  131769. /**
  131770. * Gets the world position input component
  131771. */
  131772. get worldPosition(): NodeMaterialConnectionPoint;
  131773. /**
  131774. * Gets the world normal input component
  131775. */
  131776. get worldNormal(): NodeMaterialConnectionPoint;
  131777. /**
  131778. * Gets the world input component
  131779. */
  131780. get world(): NodeMaterialConnectionPoint;
  131781. /**
  131782. * Gets the camera (or eye) position component
  131783. */
  131784. get cameraPosition(): NodeMaterialConnectionPoint;
  131785. /**
  131786. * Gets the view input component
  131787. */
  131788. get view(): NodeMaterialConnectionPoint;
  131789. /**
  131790. * Gets the rgb output component
  131791. */
  131792. get rgb(): NodeMaterialConnectionPoint;
  131793. /**
  131794. * Gets the r output component
  131795. */
  131796. get r(): NodeMaterialConnectionPoint;
  131797. /**
  131798. * Gets the g output component
  131799. */
  131800. get g(): NodeMaterialConnectionPoint;
  131801. /**
  131802. * Gets the b output component
  131803. */
  131804. get b(): NodeMaterialConnectionPoint;
  131805. autoConfigure(material: NodeMaterial): void;
  131806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131807. isReady(): boolean;
  131808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131809. private _injectVertexCode;
  131810. private _writeOutput;
  131811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131812. protected _dumpPropertiesCode(): string;
  131813. serialize(): any;
  131814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131815. }
  131816. }
  131817. declare module BABYLON {
  131818. /**
  131819. * Interface used to configure the node material editor
  131820. */
  131821. export interface INodeMaterialEditorOptions {
  131822. /** Define the URl to load node editor script */
  131823. editorURL?: string;
  131824. }
  131825. /** @hidden */
  131826. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131827. NORMAL: boolean;
  131828. TANGENT: boolean;
  131829. UV1: boolean;
  131830. /** BONES */
  131831. NUM_BONE_INFLUENCERS: number;
  131832. BonesPerMesh: number;
  131833. BONETEXTURE: boolean;
  131834. /** MORPH TARGETS */
  131835. MORPHTARGETS: boolean;
  131836. MORPHTARGETS_NORMAL: boolean;
  131837. MORPHTARGETS_TANGENT: boolean;
  131838. MORPHTARGETS_UV: boolean;
  131839. NUM_MORPH_INFLUENCERS: number;
  131840. /** IMAGE PROCESSING */
  131841. IMAGEPROCESSING: boolean;
  131842. VIGNETTE: boolean;
  131843. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131844. VIGNETTEBLENDMODEOPAQUE: boolean;
  131845. TONEMAPPING: boolean;
  131846. TONEMAPPING_ACES: boolean;
  131847. CONTRAST: boolean;
  131848. EXPOSURE: boolean;
  131849. COLORCURVES: boolean;
  131850. COLORGRADING: boolean;
  131851. COLORGRADING3D: boolean;
  131852. SAMPLER3DGREENDEPTH: boolean;
  131853. SAMPLER3DBGRMAP: boolean;
  131854. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131855. /** MISC. */
  131856. BUMPDIRECTUV: number;
  131857. constructor();
  131858. setValue(name: string, value: boolean): void;
  131859. }
  131860. /**
  131861. * Class used to configure NodeMaterial
  131862. */
  131863. export interface INodeMaterialOptions {
  131864. /**
  131865. * Defines if blocks should emit comments
  131866. */
  131867. emitComments: boolean;
  131868. }
  131869. /**
  131870. * Class used to create a node based material built by assembling shader blocks
  131871. */
  131872. export class NodeMaterial extends PushMaterial {
  131873. private static _BuildIdGenerator;
  131874. private _options;
  131875. private _vertexCompilationState;
  131876. private _fragmentCompilationState;
  131877. private _sharedData;
  131878. private _buildId;
  131879. private _buildWasSuccessful;
  131880. private _cachedWorldViewMatrix;
  131881. private _cachedWorldViewProjectionMatrix;
  131882. private _optimizers;
  131883. private _animationFrame;
  131884. /** Define the Url to load node editor script */
  131885. static EditorURL: string;
  131886. /** Define the Url to load snippets */
  131887. static SnippetUrl: string;
  131888. private BJSNODEMATERIALEDITOR;
  131889. /** Get the inspector from bundle or global */
  131890. private _getGlobalNodeMaterialEditor;
  131891. /**
  131892. * Snippet ID if the material was created from the snippet server
  131893. */
  131894. snippetId: string;
  131895. /**
  131896. * Gets or sets data used by visual editor
  131897. * @see https://nme.babylonjs.com
  131898. */
  131899. editorData: any;
  131900. /**
  131901. * 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)
  131902. */
  131903. ignoreAlpha: boolean;
  131904. /**
  131905. * Defines the maximum number of lights that can be used in the material
  131906. */
  131907. maxSimultaneousLights: number;
  131908. /**
  131909. * Observable raised when the material is built
  131910. */
  131911. onBuildObservable: Observable<NodeMaterial>;
  131912. /**
  131913. * Gets or sets the root nodes of the material vertex shader
  131914. */
  131915. _vertexOutputNodes: NodeMaterialBlock[];
  131916. /**
  131917. * Gets or sets the root nodes of the material fragment (pixel) shader
  131918. */
  131919. _fragmentOutputNodes: NodeMaterialBlock[];
  131920. /** Gets or sets options to control the node material overall behavior */
  131921. get options(): INodeMaterialOptions;
  131922. set options(options: INodeMaterialOptions);
  131923. /**
  131924. * Default configuration related to image processing available in the standard Material.
  131925. */
  131926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131927. /**
  131928. * Gets the image processing configuration used either in this material.
  131929. */
  131930. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131931. /**
  131932. * Sets the Default image processing configuration used either in the this material.
  131933. *
  131934. * If sets to null, the scene one is in use.
  131935. */
  131936. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131937. /**
  131938. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131939. */
  131940. attachedBlocks: NodeMaterialBlock[];
  131941. /**
  131942. * Create a new node based material
  131943. * @param name defines the material name
  131944. * @param scene defines the hosting scene
  131945. * @param options defines creation option
  131946. */
  131947. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131948. /**
  131949. * Gets the current class name of the material e.g. "NodeMaterial"
  131950. * @returns the class name
  131951. */
  131952. getClassName(): string;
  131953. /**
  131954. * Keep track of the image processing observer to allow dispose and replace.
  131955. */
  131956. private _imageProcessingObserver;
  131957. /**
  131958. * Attaches a new image processing configuration to the Standard Material.
  131959. * @param configuration
  131960. */
  131961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131962. /**
  131963. * Get a block by its name
  131964. * @param name defines the name of the block to retrieve
  131965. * @returns the required block or null if not found
  131966. */
  131967. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131968. /**
  131969. * Get a block by its name
  131970. * @param predicate defines the predicate used to find the good candidate
  131971. * @returns the required block or null if not found
  131972. */
  131973. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131974. /**
  131975. * Get an input block by its name
  131976. * @param predicate defines the predicate used to find the good candidate
  131977. * @returns the required input block or null if not found
  131978. */
  131979. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131980. /**
  131981. * Gets the list of input blocks attached to this material
  131982. * @returns an array of InputBlocks
  131983. */
  131984. getInputBlocks(): InputBlock[];
  131985. /**
  131986. * Adds a new optimizer to the list of optimizers
  131987. * @param optimizer defines the optimizers to add
  131988. * @returns the current material
  131989. */
  131990. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131991. /**
  131992. * Remove an optimizer from the list of optimizers
  131993. * @param optimizer defines the optimizers to remove
  131994. * @returns the current material
  131995. */
  131996. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131997. /**
  131998. * Add a new block to the list of output nodes
  131999. * @param node defines the node to add
  132000. * @returns the current material
  132001. */
  132002. addOutputNode(node: NodeMaterialBlock): this;
  132003. /**
  132004. * Remove a block from the list of root nodes
  132005. * @param node defines the node to remove
  132006. * @returns the current material
  132007. */
  132008. removeOutputNode(node: NodeMaterialBlock): this;
  132009. private _addVertexOutputNode;
  132010. private _removeVertexOutputNode;
  132011. private _addFragmentOutputNode;
  132012. private _removeFragmentOutputNode;
  132013. /**
  132014. * Specifies if the material will require alpha blending
  132015. * @returns a boolean specifying if alpha blending is needed
  132016. */
  132017. needAlphaBlending(): boolean;
  132018. /**
  132019. * Specifies if this material should be rendered in alpha test mode
  132020. * @returns a boolean specifying if an alpha test is needed.
  132021. */
  132022. needAlphaTesting(): boolean;
  132023. private _initializeBlock;
  132024. private _resetDualBlocks;
  132025. /**
  132026. * Remove a block from the current node material
  132027. * @param block defines the block to remove
  132028. */
  132029. removeBlock(block: NodeMaterialBlock): void;
  132030. /**
  132031. * Build the material and generates the inner effect
  132032. * @param verbose defines if the build should log activity
  132033. */
  132034. build(verbose?: boolean): void;
  132035. /**
  132036. * Runs an otpimization phase to try to improve the shader code
  132037. */
  132038. optimize(): void;
  132039. private _prepareDefinesForAttributes;
  132040. /**
  132041. * Get if the submesh is ready to be used and all its information available.
  132042. * Child classes can use it to update shaders
  132043. * @param mesh defines the mesh to check
  132044. * @param subMesh defines which submesh to check
  132045. * @param useInstances specifies that instances should be used
  132046. * @returns a boolean indicating that the submesh is ready or not
  132047. */
  132048. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132049. /**
  132050. * Get a string representing the shaders built by the current node graph
  132051. */
  132052. get compiledShaders(): string;
  132053. /**
  132054. * Binds the world matrix to the material
  132055. * @param world defines the world transformation matrix
  132056. */
  132057. bindOnlyWorldMatrix(world: Matrix): void;
  132058. /**
  132059. * Binds the submesh to this material by preparing the effect and shader to draw
  132060. * @param world defines the world transformation matrix
  132061. * @param mesh defines the mesh containing the submesh
  132062. * @param subMesh defines the submesh to bind the material to
  132063. */
  132064. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132065. /**
  132066. * Gets the active textures from the material
  132067. * @returns an array of textures
  132068. */
  132069. getActiveTextures(): BaseTexture[];
  132070. /**
  132071. * Gets the list of texture blocks
  132072. * @returns an array of texture blocks
  132073. */
  132074. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132075. /**
  132076. * Specifies if the material uses a texture
  132077. * @param texture defines the texture to check against the material
  132078. * @returns a boolean specifying if the material uses the texture
  132079. */
  132080. hasTexture(texture: BaseTexture): boolean;
  132081. /**
  132082. * Disposes the material
  132083. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132084. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132085. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132086. */
  132087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132088. /** Creates the node editor window. */
  132089. private _createNodeEditor;
  132090. /**
  132091. * Launch the node material editor
  132092. * @param config Define the configuration of the editor
  132093. * @return a promise fulfilled when the node editor is visible
  132094. */
  132095. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132096. /**
  132097. * Clear the current material
  132098. */
  132099. clear(): void;
  132100. /**
  132101. * Clear the current material and set it to a default state
  132102. */
  132103. setToDefault(): void;
  132104. /**
  132105. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132106. * @param url defines the url to load from
  132107. * @returns a promise that will fullfil when the material is fully loaded
  132108. */
  132109. loadAsync(url: string): Promise<void>;
  132110. private _gatherBlocks;
  132111. /**
  132112. * Generate a string containing the code declaration required to create an equivalent of this material
  132113. * @returns a string
  132114. */
  132115. generateCode(): string;
  132116. /**
  132117. * Serializes this material in a JSON representation
  132118. * @returns the serialized material object
  132119. */
  132120. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132121. private _restoreConnections;
  132122. /**
  132123. * Clear the current graph and load a new one from a serialization object
  132124. * @param source defines the JSON representation of the material
  132125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132126. */
  132127. loadFromSerialization(source: any, rootUrl?: string): void;
  132128. /**
  132129. * Makes a duplicate of the current material.
  132130. * @param name - name to use for the new material.
  132131. */
  132132. clone(name: string): NodeMaterial;
  132133. /**
  132134. * Creates a node material from parsed material data
  132135. * @param source defines the JSON representation of the material
  132136. * @param scene defines the hosting scene
  132137. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132138. * @returns a new node material
  132139. */
  132140. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132141. /**
  132142. * Creates a node material from a snippet saved in a remote file
  132143. * @param name defines the name of the material to create
  132144. * @param url defines the url to load from
  132145. * @param scene defines the hosting scene
  132146. * @returns a promise that will resolve to the new node material
  132147. */
  132148. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132149. /**
  132150. * Creates a node material from a snippet saved by the node material editor
  132151. * @param snippetId defines the snippet to load
  132152. * @param scene defines the hosting scene
  132153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132154. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132155. * @returns a promise that will resolve to the new node material
  132156. */
  132157. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132158. /**
  132159. * Creates a new node material set to default basic configuration
  132160. * @param name defines the name of the material
  132161. * @param scene defines the hosting scene
  132162. * @returns a new NodeMaterial
  132163. */
  132164. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132165. }
  132166. }
  132167. declare module BABYLON {
  132168. /**
  132169. * Block used to read a texture from a sampler
  132170. */
  132171. export class TextureBlock extends NodeMaterialBlock {
  132172. private _defineName;
  132173. private _linearDefineName;
  132174. private _tempTextureRead;
  132175. private _samplerName;
  132176. private _transformedUVName;
  132177. private _textureTransformName;
  132178. private _textureInfoName;
  132179. private _mainUVName;
  132180. private _mainUVDefineName;
  132181. /**
  132182. * Gets or sets the texture associated with the node
  132183. */
  132184. texture: Nullable<Texture>;
  132185. /**
  132186. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132187. */
  132188. convertToGammaSpace: boolean;
  132189. /**
  132190. * Create a new TextureBlock
  132191. * @param name defines the block name
  132192. */
  132193. constructor(name: string);
  132194. /**
  132195. * Gets the current class name
  132196. * @returns the class name
  132197. */
  132198. getClassName(): string;
  132199. /**
  132200. * Gets the uv input component
  132201. */
  132202. get uv(): NodeMaterialConnectionPoint;
  132203. /**
  132204. * Gets the rgba output component
  132205. */
  132206. get rgba(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the rgb output component
  132209. */
  132210. get rgb(): NodeMaterialConnectionPoint;
  132211. /**
  132212. * Gets the r output component
  132213. */
  132214. get r(): NodeMaterialConnectionPoint;
  132215. /**
  132216. * Gets the g output component
  132217. */
  132218. get g(): NodeMaterialConnectionPoint;
  132219. /**
  132220. * Gets the b output component
  132221. */
  132222. get b(): NodeMaterialConnectionPoint;
  132223. /**
  132224. * Gets the a output component
  132225. */
  132226. get a(): NodeMaterialConnectionPoint;
  132227. get target(): NodeMaterialBlockTargets;
  132228. autoConfigure(material: NodeMaterial): void;
  132229. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132231. isReady(): boolean;
  132232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132233. private get _isMixed();
  132234. private _injectVertexCode;
  132235. private _writeTextureRead;
  132236. private _writeOutput;
  132237. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132238. protected _dumpPropertiesCode(): string;
  132239. serialize(): any;
  132240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132241. }
  132242. }
  132243. declare module BABYLON {
  132244. /**
  132245. * Class used to store shared data between 2 NodeMaterialBuildState
  132246. */
  132247. export class NodeMaterialBuildStateSharedData {
  132248. /**
  132249. * Gets the list of emitted varyings
  132250. */
  132251. temps: string[];
  132252. /**
  132253. * Gets the list of emitted varyings
  132254. */
  132255. varyings: string[];
  132256. /**
  132257. * Gets the varying declaration string
  132258. */
  132259. varyingDeclaration: string;
  132260. /**
  132261. * Input blocks
  132262. */
  132263. inputBlocks: InputBlock[];
  132264. /**
  132265. * Input blocks
  132266. */
  132267. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132268. /**
  132269. * Bindable blocks (Blocks that need to set data to the effect)
  132270. */
  132271. bindableBlocks: NodeMaterialBlock[];
  132272. /**
  132273. * List of blocks that can provide a compilation fallback
  132274. */
  132275. blocksWithFallbacks: NodeMaterialBlock[];
  132276. /**
  132277. * List of blocks that can provide a define update
  132278. */
  132279. blocksWithDefines: NodeMaterialBlock[];
  132280. /**
  132281. * List of blocks that can provide a repeatable content
  132282. */
  132283. repeatableContentBlocks: NodeMaterialBlock[];
  132284. /**
  132285. * List of blocks that can provide a dynamic list of uniforms
  132286. */
  132287. dynamicUniformBlocks: NodeMaterialBlock[];
  132288. /**
  132289. * List of blocks that can block the isReady function for the material
  132290. */
  132291. blockingBlocks: NodeMaterialBlock[];
  132292. /**
  132293. * Gets the list of animated inputs
  132294. */
  132295. animatedInputs: InputBlock[];
  132296. /**
  132297. * Build Id used to avoid multiple recompilations
  132298. */
  132299. buildId: number;
  132300. /** List of emitted variables */
  132301. variableNames: {
  132302. [key: string]: number;
  132303. };
  132304. /** List of emitted defines */
  132305. defineNames: {
  132306. [key: string]: number;
  132307. };
  132308. /** Should emit comments? */
  132309. emitComments: boolean;
  132310. /** Emit build activity */
  132311. verbose: boolean;
  132312. /** Gets or sets the hosting scene */
  132313. scene: Scene;
  132314. /**
  132315. * Gets the compilation hints emitted at compilation time
  132316. */
  132317. hints: {
  132318. needWorldViewMatrix: boolean;
  132319. needWorldViewProjectionMatrix: boolean;
  132320. needAlphaBlending: boolean;
  132321. needAlphaTesting: boolean;
  132322. };
  132323. /**
  132324. * List of compilation checks
  132325. */
  132326. checks: {
  132327. emitVertex: boolean;
  132328. emitFragment: boolean;
  132329. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132330. };
  132331. /** Creates a new shared data */
  132332. constructor();
  132333. /**
  132334. * Emits console errors and exceptions if there is a failing check
  132335. */
  132336. emitErrors(): void;
  132337. }
  132338. }
  132339. declare module BABYLON {
  132340. /**
  132341. * Class used to store node based material build state
  132342. */
  132343. export class NodeMaterialBuildState {
  132344. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132345. supportUniformBuffers: boolean;
  132346. /**
  132347. * Gets the list of emitted attributes
  132348. */
  132349. attributes: string[];
  132350. /**
  132351. * Gets the list of emitted uniforms
  132352. */
  132353. uniforms: string[];
  132354. /**
  132355. * Gets the list of emitted constants
  132356. */
  132357. constants: string[];
  132358. /**
  132359. * Gets the list of emitted samplers
  132360. */
  132361. samplers: string[];
  132362. /**
  132363. * Gets the list of emitted functions
  132364. */
  132365. functions: {
  132366. [key: string]: string;
  132367. };
  132368. /**
  132369. * Gets the list of emitted extensions
  132370. */
  132371. extensions: {
  132372. [key: string]: string;
  132373. };
  132374. /**
  132375. * Gets the target of the compilation state
  132376. */
  132377. target: NodeMaterialBlockTargets;
  132378. /**
  132379. * Gets the list of emitted counters
  132380. */
  132381. counters: {
  132382. [key: string]: number;
  132383. };
  132384. /**
  132385. * Shared data between multiple NodeMaterialBuildState instances
  132386. */
  132387. sharedData: NodeMaterialBuildStateSharedData;
  132388. /** @hidden */
  132389. _vertexState: NodeMaterialBuildState;
  132390. /** @hidden */
  132391. _attributeDeclaration: string;
  132392. /** @hidden */
  132393. _uniformDeclaration: string;
  132394. /** @hidden */
  132395. _constantDeclaration: string;
  132396. /** @hidden */
  132397. _samplerDeclaration: string;
  132398. /** @hidden */
  132399. _varyingTransfer: string;
  132400. private _repeatableContentAnchorIndex;
  132401. /** @hidden */
  132402. _builtCompilationString: string;
  132403. /**
  132404. * Gets the emitted compilation strings
  132405. */
  132406. compilationString: string;
  132407. /**
  132408. * Finalize the compilation strings
  132409. * @param state defines the current compilation state
  132410. */
  132411. finalize(state: NodeMaterialBuildState): void;
  132412. /** @hidden */
  132413. get _repeatableContentAnchor(): string;
  132414. /** @hidden */
  132415. _getFreeVariableName(prefix: string): string;
  132416. /** @hidden */
  132417. _getFreeDefineName(prefix: string): string;
  132418. /** @hidden */
  132419. _excludeVariableName(name: string): void;
  132420. /** @hidden */
  132421. _emit2DSampler(name: string): void;
  132422. /** @hidden */
  132423. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132424. /** @hidden */
  132425. _emitExtension(name: string, extension: string): void;
  132426. /** @hidden */
  132427. _emitFunction(name: string, code: string, comments: string): void;
  132428. /** @hidden */
  132429. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132430. replaceStrings?: {
  132431. search: RegExp;
  132432. replace: string;
  132433. }[];
  132434. repeatKey?: string;
  132435. }): string;
  132436. /** @hidden */
  132437. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132438. repeatKey?: string;
  132439. removeAttributes?: boolean;
  132440. removeUniforms?: boolean;
  132441. removeVaryings?: boolean;
  132442. removeIfDef?: boolean;
  132443. replaceStrings?: {
  132444. search: RegExp;
  132445. replace: string;
  132446. }[];
  132447. }, storeKey?: string): void;
  132448. /** @hidden */
  132449. _registerTempVariable(name: string): boolean;
  132450. /** @hidden */
  132451. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132452. /** @hidden */
  132453. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132454. /** @hidden */
  132455. _emitFloat(value: number): string;
  132456. }
  132457. }
  132458. declare module BABYLON {
  132459. /**
  132460. * Defines a block that can be used inside a node based material
  132461. */
  132462. export class NodeMaterialBlock {
  132463. private _buildId;
  132464. private _buildTarget;
  132465. private _target;
  132466. private _isFinalMerger;
  132467. private _isInput;
  132468. protected _isUnique: boolean;
  132469. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132470. inputsAreExclusive: boolean;
  132471. /** @hidden */
  132472. _codeVariableName: string;
  132473. /** @hidden */
  132474. _inputs: NodeMaterialConnectionPoint[];
  132475. /** @hidden */
  132476. _outputs: NodeMaterialConnectionPoint[];
  132477. /** @hidden */
  132478. _preparationId: number;
  132479. /**
  132480. * Gets or sets the name of the block
  132481. */
  132482. name: string;
  132483. /**
  132484. * Gets or sets the unique id of the node
  132485. */
  132486. uniqueId: number;
  132487. /**
  132488. * Gets or sets the comments associated with this block
  132489. */
  132490. comments: string;
  132491. /**
  132492. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132493. */
  132494. get isUnique(): boolean;
  132495. /**
  132496. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132497. */
  132498. get isFinalMerger(): boolean;
  132499. /**
  132500. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132501. */
  132502. get isInput(): boolean;
  132503. /**
  132504. * Gets or sets the build Id
  132505. */
  132506. get buildId(): number;
  132507. set buildId(value: number);
  132508. /**
  132509. * Gets or sets the target of the block
  132510. */
  132511. get target(): NodeMaterialBlockTargets;
  132512. set target(value: NodeMaterialBlockTargets);
  132513. /**
  132514. * Gets the list of input points
  132515. */
  132516. get inputs(): NodeMaterialConnectionPoint[];
  132517. /** Gets the list of output points */
  132518. get outputs(): NodeMaterialConnectionPoint[];
  132519. /**
  132520. * Find an input by its name
  132521. * @param name defines the name of the input to look for
  132522. * @returns the input or null if not found
  132523. */
  132524. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132525. /**
  132526. * Find an output by its name
  132527. * @param name defines the name of the outputto look for
  132528. * @returns the output or null if not found
  132529. */
  132530. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132531. /**
  132532. * Creates a new NodeMaterialBlock
  132533. * @param name defines the block name
  132534. * @param target defines the target of that block (Vertex by default)
  132535. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132536. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132537. */
  132538. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132539. /**
  132540. * Initialize the block and prepare the context for build
  132541. * @param state defines the state that will be used for the build
  132542. */
  132543. initialize(state: NodeMaterialBuildState): void;
  132544. /**
  132545. * Bind data to effect. Will only be called for blocks with isBindable === true
  132546. * @param effect defines the effect to bind data to
  132547. * @param nodeMaterial defines the hosting NodeMaterial
  132548. * @param mesh defines the mesh that will be rendered
  132549. */
  132550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132551. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132552. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132553. protected _writeFloat(value: number): string;
  132554. /**
  132555. * Gets the current class name e.g. "NodeMaterialBlock"
  132556. * @returns the class name
  132557. */
  132558. getClassName(): string;
  132559. /**
  132560. * Register a new input. Must be called inside a block constructor
  132561. * @param name defines the connection point name
  132562. * @param type defines the connection point type
  132563. * @param isOptional defines a boolean indicating that this input can be omitted
  132564. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132565. * @returns the current block
  132566. */
  132567. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132568. /**
  132569. * Register a new output. Must be called inside a block constructor
  132570. * @param name defines the connection point name
  132571. * @param type defines the connection point type
  132572. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132573. * @returns the current block
  132574. */
  132575. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132576. /**
  132577. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132578. * @param forOutput defines an optional connection point to check compatibility with
  132579. * @returns the first available input or null
  132580. */
  132581. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132582. /**
  132583. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132584. * @param forBlock defines an optional block to check compatibility with
  132585. * @returns the first available input or null
  132586. */
  132587. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132588. /**
  132589. * Gets the sibling of the given output
  132590. * @param current defines the current output
  132591. * @returns the next output in the list or null
  132592. */
  132593. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132594. /**
  132595. * Connect current block with another block
  132596. * @param other defines the block to connect with
  132597. * @param options define the various options to help pick the right connections
  132598. * @returns the current block
  132599. */
  132600. connectTo(other: NodeMaterialBlock, options?: {
  132601. input?: string;
  132602. output?: string;
  132603. outputSwizzle?: string;
  132604. }): this | undefined;
  132605. protected _buildBlock(state: NodeMaterialBuildState): void;
  132606. /**
  132607. * Add uniforms, samplers and uniform buffers at compilation time
  132608. * @param state defines the state to update
  132609. * @param nodeMaterial defines the node material requesting the update
  132610. * @param defines defines the material defines to update
  132611. * @param uniformBuffers defines the list of uniform buffer names
  132612. */
  132613. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132614. /**
  132615. * Add potential fallbacks if shader compilation fails
  132616. * @param mesh defines the mesh to be rendered
  132617. * @param fallbacks defines the current prioritized list of fallbacks
  132618. */
  132619. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132620. /**
  132621. * Initialize defines for shader compilation
  132622. * @param mesh defines the mesh to be rendered
  132623. * @param nodeMaterial defines the node material requesting the update
  132624. * @param defines defines the material defines to update
  132625. * @param useInstances specifies that instances should be used
  132626. */
  132627. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132628. /**
  132629. * Update defines for shader compilation
  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. */
  132635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132636. /**
  132637. * Lets the block try to connect some inputs automatically
  132638. * @param material defines the hosting NodeMaterial
  132639. */
  132640. autoConfigure(material: NodeMaterial): void;
  132641. /**
  132642. * Function called when a block is declared as repeatable content generator
  132643. * @param vertexShaderState defines the current compilation state for the vertex shader
  132644. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132645. * @param mesh defines the mesh to be rendered
  132646. * @param defines defines the material defines to update
  132647. */
  132648. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132649. /**
  132650. * Checks if the block is ready
  132651. * @param mesh defines the mesh to be rendered
  132652. * @param nodeMaterial defines the node material requesting the update
  132653. * @param defines defines the material defines to update
  132654. * @param useInstances specifies that instances should be used
  132655. * @returns true if the block is ready
  132656. */
  132657. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132658. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132659. private _processBuild;
  132660. /**
  132661. * Compile the current node and generate the shader code
  132662. * @param state defines the current compilation state (uniforms, samplers, current string)
  132663. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132664. * @returns true if already built
  132665. */
  132666. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132667. protected _inputRename(name: string): string;
  132668. protected _outputRename(name: string): string;
  132669. protected _dumpPropertiesCode(): string;
  132670. /** @hidden */
  132671. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132672. /** @hidden */
  132673. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132674. /**
  132675. * Clone the current block to a new identical block
  132676. * @param scene defines the hosting scene
  132677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132678. * @returns a copy of the current block
  132679. */
  132680. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132681. /**
  132682. * Serializes this block in a JSON representation
  132683. * @returns the serialized block object
  132684. */
  132685. serialize(): any;
  132686. /** @hidden */
  132687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132688. /**
  132689. * Release resources
  132690. */
  132691. dispose(): void;
  132692. }
  132693. }
  132694. declare module BABYLON {
  132695. /**
  132696. * Enum defining the type of animations supported by InputBlock
  132697. */
  132698. export enum AnimatedInputBlockTypes {
  132699. /** No animation */
  132700. None = 0,
  132701. /** Time based animation. Will only work for floats */
  132702. Time = 1
  132703. }
  132704. }
  132705. declare module BABYLON {
  132706. /**
  132707. * Block used to expose an input value
  132708. */
  132709. export class InputBlock extends NodeMaterialBlock {
  132710. private _mode;
  132711. private _associatedVariableName;
  132712. private _storedValue;
  132713. private _valueCallback;
  132714. private _type;
  132715. private _animationType;
  132716. /** Gets or set a value used to limit the range of float values */
  132717. min: number;
  132718. /** Gets or set a value used to limit the range of float values */
  132719. max: number;
  132720. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132721. isBoolean: boolean;
  132722. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132723. matrixMode: number;
  132724. /** @hidden */
  132725. _systemValue: Nullable<NodeMaterialSystemValues>;
  132726. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132727. visibleInInspector: boolean;
  132728. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132729. isConstant: boolean;
  132730. /** Gets or sets the group to use to display this block in the Inspector */
  132731. groupInInspector: string;
  132732. /** Gets an observable raised when the value is changed */
  132733. onValueChangedObservable: Observable<InputBlock>;
  132734. /**
  132735. * Gets or sets the connection point type (default is float)
  132736. */
  132737. get type(): NodeMaterialBlockConnectionPointTypes;
  132738. /**
  132739. * Creates a new InputBlock
  132740. * @param name defines the block name
  132741. * @param target defines the target of that block (Vertex by default)
  132742. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132743. */
  132744. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132745. /**
  132746. * Gets the output component
  132747. */
  132748. get output(): NodeMaterialConnectionPoint;
  132749. /**
  132750. * Set the source of this connection point to a vertex attribute
  132751. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132752. * @returns the current connection point
  132753. */
  132754. setAsAttribute(attributeName?: string): InputBlock;
  132755. /**
  132756. * Set the source of this connection point to a system value
  132757. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132758. * @returns the current connection point
  132759. */
  132760. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132761. /**
  132762. * Gets or sets the value of that point.
  132763. * Please note that this value will be ignored if valueCallback is defined
  132764. */
  132765. get value(): any;
  132766. set value(value: any);
  132767. /**
  132768. * Gets or sets a callback used to get the value of that point.
  132769. * Please note that setting this value will force the connection point to ignore the value property
  132770. */
  132771. get valueCallback(): () => any;
  132772. set valueCallback(value: () => any);
  132773. /**
  132774. * Gets or sets the associated variable name in the shader
  132775. */
  132776. get associatedVariableName(): string;
  132777. set associatedVariableName(value: string);
  132778. /** Gets or sets the type of animation applied to the input */
  132779. get animationType(): AnimatedInputBlockTypes;
  132780. set animationType(value: AnimatedInputBlockTypes);
  132781. /**
  132782. * Gets a boolean indicating that this connection point not defined yet
  132783. */
  132784. get isUndefined(): boolean;
  132785. /**
  132786. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132787. * In this case the connection point name must be the name of the uniform to use.
  132788. * Can only be set on inputs
  132789. */
  132790. get isUniform(): boolean;
  132791. set isUniform(value: boolean);
  132792. /**
  132793. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132794. * In this case the connection point name must be the name of the attribute to use
  132795. * Can only be set on inputs
  132796. */
  132797. get isAttribute(): boolean;
  132798. set isAttribute(value: boolean);
  132799. /**
  132800. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132801. * Can only be set on exit points
  132802. */
  132803. get isVarying(): boolean;
  132804. set isVarying(value: boolean);
  132805. /**
  132806. * Gets a boolean indicating that the current connection point is a system value
  132807. */
  132808. get isSystemValue(): boolean;
  132809. /**
  132810. * Gets or sets the current well known value or null if not defined as a system value
  132811. */
  132812. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132813. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132814. /**
  132815. * Gets the current class name
  132816. * @returns the class name
  132817. */
  132818. getClassName(): string;
  132819. /**
  132820. * Animate the input if animationType !== None
  132821. * @param scene defines the rendering scene
  132822. */
  132823. animate(scene: Scene): void;
  132824. private _emitDefine;
  132825. initialize(state: NodeMaterialBuildState): void;
  132826. /**
  132827. * Set the input block to its default value (based on its type)
  132828. */
  132829. setDefaultValue(): void;
  132830. private _emitConstant;
  132831. private _emit;
  132832. /** @hidden */
  132833. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132834. /** @hidden */
  132835. _transmit(effect: Effect, scene: Scene): void;
  132836. protected _buildBlock(state: NodeMaterialBuildState): void;
  132837. protected _dumpPropertiesCode(): string;
  132838. dispose(): void;
  132839. serialize(): any;
  132840. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132841. }
  132842. }
  132843. declare module BABYLON {
  132844. /**
  132845. * Enum used to define the compatibility state between two connection points
  132846. */
  132847. export enum NodeMaterialConnectionPointCompatibilityStates {
  132848. /** Points are compatibles */
  132849. Compatible = 0,
  132850. /** Points are incompatible because of their types */
  132851. TypeIncompatible = 1,
  132852. /** Points are incompatible because of their targets (vertex vs fragment) */
  132853. TargetIncompatible = 2
  132854. }
  132855. /**
  132856. * Defines the direction of a connection point
  132857. */
  132858. export enum NodeMaterialConnectionPointDirection {
  132859. /** Input */
  132860. Input = 0,
  132861. /** Output */
  132862. Output = 1
  132863. }
  132864. /**
  132865. * Defines a connection point for a block
  132866. */
  132867. export class NodeMaterialConnectionPoint {
  132868. /** @hidden */
  132869. _ownerBlock: NodeMaterialBlock;
  132870. /** @hidden */
  132871. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132872. private _endpoints;
  132873. private _associatedVariableName;
  132874. private _direction;
  132875. /** @hidden */
  132876. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132877. /** @hidden */
  132878. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132879. private _type;
  132880. /** @hidden */
  132881. _enforceAssociatedVariableName: boolean;
  132882. /** Gets the direction of the point */
  132883. get direction(): NodeMaterialConnectionPointDirection;
  132884. /**
  132885. * Gets or sets the additional types supported by this connection point
  132886. */
  132887. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132888. /**
  132889. * Gets or sets the additional types excluded by this connection point
  132890. */
  132891. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132892. /**
  132893. * Observable triggered when this point is connected
  132894. */
  132895. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132896. /**
  132897. * Gets or sets the associated variable name in the shader
  132898. */
  132899. get associatedVariableName(): string;
  132900. set associatedVariableName(value: string);
  132901. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132902. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132903. /**
  132904. * Gets or sets the connection point type (default is float)
  132905. */
  132906. get type(): NodeMaterialBlockConnectionPointTypes;
  132907. set type(value: NodeMaterialBlockConnectionPointTypes);
  132908. /**
  132909. * Gets or sets the connection point name
  132910. */
  132911. name: string;
  132912. /**
  132913. * Gets or sets a boolean indicating that this connection point can be omitted
  132914. */
  132915. isOptional: boolean;
  132916. /**
  132917. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132918. */
  132919. define: string;
  132920. /** @hidden */
  132921. _prioritizeVertex: boolean;
  132922. private _target;
  132923. /** Gets or sets the target of that connection point */
  132924. get target(): NodeMaterialBlockTargets;
  132925. set target(value: NodeMaterialBlockTargets);
  132926. /**
  132927. * Gets a boolean indicating that the current point is connected
  132928. */
  132929. get isConnected(): boolean;
  132930. /**
  132931. * Gets a boolean indicating that the current point is connected to an input block
  132932. */
  132933. get isConnectedToInputBlock(): boolean;
  132934. /**
  132935. * Gets a the connected input block (if any)
  132936. */
  132937. get connectInputBlock(): Nullable<InputBlock>;
  132938. /** Get the other side of the connection (if any) */
  132939. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132940. /** Get the block that owns this connection point */
  132941. get ownerBlock(): NodeMaterialBlock;
  132942. /** Get the block connected on the other side of this connection (if any) */
  132943. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132944. /** Get the block connected on the endpoints of this connection (if any) */
  132945. get connectedBlocks(): Array<NodeMaterialBlock>;
  132946. /** Gets the list of connected endpoints */
  132947. get endpoints(): NodeMaterialConnectionPoint[];
  132948. /** Gets a boolean indicating if that output point is connected to at least one input */
  132949. get hasEndpoints(): boolean;
  132950. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132951. get isConnectedInVertexShader(): boolean;
  132952. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132953. get isConnectedInFragmentShader(): boolean;
  132954. /**
  132955. * Creates a new connection point
  132956. * @param name defines the connection point name
  132957. * @param ownerBlock defines the block hosting this connection point
  132958. * @param direction defines the direction of the connection point
  132959. */
  132960. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132961. /**
  132962. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132963. * @returns the class name
  132964. */
  132965. getClassName(): string;
  132966. /**
  132967. * Gets a boolean indicating if the current point can be connected to another point
  132968. * @param connectionPoint defines the other connection point
  132969. * @returns a boolean
  132970. */
  132971. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132972. /**
  132973. * Gets a number indicating if the current point can be connected to another point
  132974. * @param connectionPoint defines the other connection point
  132975. * @returns a number defining the compatibility state
  132976. */
  132977. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132978. /**
  132979. * Connect this point to another connection point
  132980. * @param connectionPoint defines the other connection point
  132981. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132982. * @returns the current connection point
  132983. */
  132984. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132985. /**
  132986. * Disconnect this point from one of his endpoint
  132987. * @param endpoint defines the other connection point
  132988. * @returns the current connection point
  132989. */
  132990. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132991. /**
  132992. * Serializes this point in a JSON representation
  132993. * @returns the serialized point object
  132994. */
  132995. serialize(): any;
  132996. /**
  132997. * Release resources
  132998. */
  132999. dispose(): void;
  133000. }
  133001. }
  133002. declare module BABYLON {
  133003. /**
  133004. * Block used to add support for vertex skinning (bones)
  133005. */
  133006. export class BonesBlock extends NodeMaterialBlock {
  133007. /**
  133008. * Creates a new BonesBlock
  133009. * @param name defines the block name
  133010. */
  133011. constructor(name: string);
  133012. /**
  133013. * Initialize the block and prepare the context for build
  133014. * @param state defines the state that will be used for the build
  133015. */
  133016. initialize(state: NodeMaterialBuildState): void;
  133017. /**
  133018. * Gets the current class name
  133019. * @returns the class name
  133020. */
  133021. getClassName(): string;
  133022. /**
  133023. * Gets the matrix indices input component
  133024. */
  133025. get matricesIndices(): NodeMaterialConnectionPoint;
  133026. /**
  133027. * Gets the matrix weights input component
  133028. */
  133029. get matricesWeights(): NodeMaterialConnectionPoint;
  133030. /**
  133031. * Gets the extra matrix indices input component
  133032. */
  133033. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133034. /**
  133035. * Gets the extra matrix weights input component
  133036. */
  133037. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133038. /**
  133039. * Gets the world input component
  133040. */
  133041. get world(): NodeMaterialConnectionPoint;
  133042. /**
  133043. * Gets the output component
  133044. */
  133045. get output(): NodeMaterialConnectionPoint;
  133046. autoConfigure(material: NodeMaterial): void;
  133047. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133050. protected _buildBlock(state: NodeMaterialBuildState): this;
  133051. }
  133052. }
  133053. declare module BABYLON {
  133054. /**
  133055. * Block used to add support for instances
  133056. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133057. */
  133058. export class InstancesBlock extends NodeMaterialBlock {
  133059. /**
  133060. * Creates a new InstancesBlock
  133061. * @param name defines the block name
  133062. */
  133063. constructor(name: string);
  133064. /**
  133065. * Gets the current class name
  133066. * @returns the class name
  133067. */
  133068. getClassName(): string;
  133069. /**
  133070. * Gets the first world row input component
  133071. */
  133072. get world0(): NodeMaterialConnectionPoint;
  133073. /**
  133074. * Gets the second world row input component
  133075. */
  133076. get world1(): NodeMaterialConnectionPoint;
  133077. /**
  133078. * Gets the third world row input component
  133079. */
  133080. get world2(): NodeMaterialConnectionPoint;
  133081. /**
  133082. * Gets the forth world row input component
  133083. */
  133084. get world3(): NodeMaterialConnectionPoint;
  133085. /**
  133086. * Gets the world input component
  133087. */
  133088. get world(): NodeMaterialConnectionPoint;
  133089. /**
  133090. * Gets the output component
  133091. */
  133092. get output(): NodeMaterialConnectionPoint;
  133093. /**
  133094. * Gets the isntanceID component
  133095. */
  133096. get instanceID(): NodeMaterialConnectionPoint;
  133097. autoConfigure(material: NodeMaterial): void;
  133098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133099. protected _buildBlock(state: NodeMaterialBuildState): this;
  133100. }
  133101. }
  133102. declare module BABYLON {
  133103. /**
  133104. * Block used to add morph targets support to vertex shader
  133105. */
  133106. export class MorphTargetsBlock extends NodeMaterialBlock {
  133107. private _repeatableContentAnchor;
  133108. /**
  133109. * Create a new MorphTargetsBlock
  133110. * @param name defines the block name
  133111. */
  133112. constructor(name: string);
  133113. /**
  133114. * Gets the current class name
  133115. * @returns the class name
  133116. */
  133117. getClassName(): string;
  133118. /**
  133119. * Gets the position input component
  133120. */
  133121. get position(): NodeMaterialConnectionPoint;
  133122. /**
  133123. * Gets the normal input component
  133124. */
  133125. get normal(): NodeMaterialConnectionPoint;
  133126. /**
  133127. * Gets the tangent input component
  133128. */
  133129. get tangent(): NodeMaterialConnectionPoint;
  133130. /**
  133131. * Gets the tangent input component
  133132. */
  133133. get uv(): NodeMaterialConnectionPoint;
  133134. /**
  133135. * Gets the position output component
  133136. */
  133137. get positionOutput(): NodeMaterialConnectionPoint;
  133138. /**
  133139. * Gets the normal output component
  133140. */
  133141. get normalOutput(): NodeMaterialConnectionPoint;
  133142. /**
  133143. * Gets the tangent output component
  133144. */
  133145. get tangentOutput(): NodeMaterialConnectionPoint;
  133146. /**
  133147. * Gets the tangent output component
  133148. */
  133149. get uvOutput(): NodeMaterialConnectionPoint;
  133150. initialize(state: NodeMaterialBuildState): void;
  133151. autoConfigure(material: NodeMaterial): void;
  133152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133154. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133155. protected _buildBlock(state: NodeMaterialBuildState): this;
  133156. }
  133157. }
  133158. declare module BABYLON {
  133159. /**
  133160. * Block used to get data information from a light
  133161. */
  133162. export class LightInformationBlock extends NodeMaterialBlock {
  133163. private _lightDataUniformName;
  133164. private _lightColorUniformName;
  133165. private _lightTypeDefineName;
  133166. /**
  133167. * Gets or sets the light associated with this block
  133168. */
  133169. light: Nullable<Light>;
  133170. /**
  133171. * Creates a new LightInformationBlock
  133172. * @param name defines the block name
  133173. */
  133174. constructor(name: string);
  133175. /**
  133176. * Gets the current class name
  133177. * @returns the class name
  133178. */
  133179. getClassName(): string;
  133180. /**
  133181. * Gets the world position input component
  133182. */
  133183. get worldPosition(): NodeMaterialConnectionPoint;
  133184. /**
  133185. * Gets the direction output component
  133186. */
  133187. get direction(): NodeMaterialConnectionPoint;
  133188. /**
  133189. * Gets the direction output component
  133190. */
  133191. get color(): NodeMaterialConnectionPoint;
  133192. /**
  133193. * Gets the direction output component
  133194. */
  133195. get intensity(): NodeMaterialConnectionPoint;
  133196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133198. protected _buildBlock(state: NodeMaterialBuildState): this;
  133199. serialize(): any;
  133200. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133201. }
  133202. }
  133203. declare module BABYLON {
  133204. /**
  133205. * Block used to add image processing support to fragment shader
  133206. */
  133207. export class ImageProcessingBlock extends NodeMaterialBlock {
  133208. /**
  133209. * Create a new ImageProcessingBlock
  133210. * @param name defines the block name
  133211. */
  133212. constructor(name: string);
  133213. /**
  133214. * Gets the current class name
  133215. * @returns the class name
  133216. */
  133217. getClassName(): string;
  133218. /**
  133219. * Gets the color input component
  133220. */
  133221. get color(): NodeMaterialConnectionPoint;
  133222. /**
  133223. * Gets the output component
  133224. */
  133225. get output(): NodeMaterialConnectionPoint;
  133226. /**
  133227. * Initialize the block and prepare the context for build
  133228. * @param state defines the state that will be used for the build
  133229. */
  133230. initialize(state: NodeMaterialBuildState): void;
  133231. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133234. protected _buildBlock(state: NodeMaterialBuildState): this;
  133235. }
  133236. }
  133237. declare module BABYLON {
  133238. /**
  133239. * Block used to pertub normals based on a normal map
  133240. */
  133241. export class PerturbNormalBlock extends NodeMaterialBlock {
  133242. private _tangentSpaceParameterName;
  133243. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133244. invertX: boolean;
  133245. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133246. invertY: boolean;
  133247. /**
  133248. * Create a new PerturbNormalBlock
  133249. * @param name defines the block name
  133250. */
  133251. constructor(name: string);
  133252. /**
  133253. * Gets the current class name
  133254. * @returns the class name
  133255. */
  133256. getClassName(): string;
  133257. /**
  133258. * Gets the world position input component
  133259. */
  133260. get worldPosition(): NodeMaterialConnectionPoint;
  133261. /**
  133262. * Gets the world normal input component
  133263. */
  133264. get worldNormal(): NodeMaterialConnectionPoint;
  133265. /**
  133266. * Gets the world tangent input component
  133267. */
  133268. get worldTangent(): NodeMaterialConnectionPoint;
  133269. /**
  133270. * Gets the uv input component
  133271. */
  133272. get uv(): NodeMaterialConnectionPoint;
  133273. /**
  133274. * Gets the normal map color input component
  133275. */
  133276. get normalMapColor(): NodeMaterialConnectionPoint;
  133277. /**
  133278. * Gets the strength input component
  133279. */
  133280. get strength(): NodeMaterialConnectionPoint;
  133281. /**
  133282. * Gets the output component
  133283. */
  133284. get output(): NodeMaterialConnectionPoint;
  133285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133287. autoConfigure(material: NodeMaterial): void;
  133288. protected _buildBlock(state: NodeMaterialBuildState): this;
  133289. protected _dumpPropertiesCode(): string;
  133290. serialize(): any;
  133291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133292. }
  133293. }
  133294. declare module BABYLON {
  133295. /**
  133296. * Block used to discard a pixel if a value is smaller than a cutoff
  133297. */
  133298. export class DiscardBlock extends NodeMaterialBlock {
  133299. /**
  133300. * Create a new DiscardBlock
  133301. * @param name defines the block name
  133302. */
  133303. constructor(name: string);
  133304. /**
  133305. * Gets the current class name
  133306. * @returns the class name
  133307. */
  133308. getClassName(): string;
  133309. /**
  133310. * Gets the color input component
  133311. */
  133312. get value(): NodeMaterialConnectionPoint;
  133313. /**
  133314. * Gets the cutoff input component
  133315. */
  133316. get cutoff(): NodeMaterialConnectionPoint;
  133317. protected _buildBlock(state: NodeMaterialBuildState): this;
  133318. }
  133319. }
  133320. declare module BABYLON {
  133321. /**
  133322. * Block used to test if the fragment shader is front facing
  133323. */
  133324. export class FrontFacingBlock extends NodeMaterialBlock {
  133325. /**
  133326. * Creates a new FrontFacingBlock
  133327. * @param name defines the block name
  133328. */
  133329. constructor(name: string);
  133330. /**
  133331. * Gets the current class name
  133332. * @returns the class name
  133333. */
  133334. getClassName(): string;
  133335. /**
  133336. * Gets the output component
  133337. */
  133338. get output(): NodeMaterialConnectionPoint;
  133339. protected _buildBlock(state: NodeMaterialBuildState): this;
  133340. }
  133341. }
  133342. declare module BABYLON {
  133343. /**
  133344. * Block used to get the derivative value on x and y of a given input
  133345. */
  133346. export class DerivativeBlock extends NodeMaterialBlock {
  133347. /**
  133348. * Create a new DerivativeBlock
  133349. * @param name defines the block name
  133350. */
  133351. constructor(name: string);
  133352. /**
  133353. * Gets the current class name
  133354. * @returns the class name
  133355. */
  133356. getClassName(): string;
  133357. /**
  133358. * Gets the input component
  133359. */
  133360. get input(): NodeMaterialConnectionPoint;
  133361. /**
  133362. * Gets the derivative output on x
  133363. */
  133364. get dx(): NodeMaterialConnectionPoint;
  133365. /**
  133366. * Gets the derivative output on y
  133367. */
  133368. get dy(): NodeMaterialConnectionPoint;
  133369. protected _buildBlock(state: NodeMaterialBuildState): this;
  133370. }
  133371. }
  133372. declare module BABYLON {
  133373. /**
  133374. * Block used to add support for scene fog
  133375. */
  133376. export class FogBlock extends NodeMaterialBlock {
  133377. private _fogDistanceName;
  133378. private _fogParameters;
  133379. /**
  133380. * Create a new FogBlock
  133381. * @param name defines the block name
  133382. */
  133383. constructor(name: string);
  133384. /**
  133385. * Gets the current class name
  133386. * @returns the class name
  133387. */
  133388. getClassName(): string;
  133389. /**
  133390. * Gets the world position input component
  133391. */
  133392. get worldPosition(): NodeMaterialConnectionPoint;
  133393. /**
  133394. * Gets the view input component
  133395. */
  133396. get view(): NodeMaterialConnectionPoint;
  133397. /**
  133398. * Gets the color input component
  133399. */
  133400. get input(): NodeMaterialConnectionPoint;
  133401. /**
  133402. * Gets the fog color input component
  133403. */
  133404. get fogColor(): NodeMaterialConnectionPoint;
  133405. /**
  133406. * Gets the output component
  133407. */
  133408. get output(): NodeMaterialConnectionPoint;
  133409. autoConfigure(material: NodeMaterial): void;
  133410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133412. protected _buildBlock(state: NodeMaterialBuildState): this;
  133413. }
  133414. }
  133415. declare module BABYLON {
  133416. /**
  133417. * Block used to add light in the fragment shader
  133418. */
  133419. export class LightBlock extends NodeMaterialBlock {
  133420. private _lightId;
  133421. /**
  133422. * Gets or sets the light associated with this block
  133423. */
  133424. light: Nullable<Light>;
  133425. /**
  133426. * Create a new LightBlock
  133427. * @param name defines the block name
  133428. */
  133429. constructor(name: string);
  133430. /**
  133431. * Gets the current class name
  133432. * @returns the class name
  133433. */
  133434. getClassName(): string;
  133435. /**
  133436. * Gets the world position input component
  133437. */
  133438. get worldPosition(): NodeMaterialConnectionPoint;
  133439. /**
  133440. * Gets the world normal input component
  133441. */
  133442. get worldNormal(): NodeMaterialConnectionPoint;
  133443. /**
  133444. * Gets the camera (or eye) position component
  133445. */
  133446. get cameraPosition(): NodeMaterialConnectionPoint;
  133447. /**
  133448. * Gets the glossiness component
  133449. */
  133450. get glossiness(): NodeMaterialConnectionPoint;
  133451. /**
  133452. * Gets the glossinness power component
  133453. */
  133454. get glossPower(): NodeMaterialConnectionPoint;
  133455. /**
  133456. * Gets the diffuse color component
  133457. */
  133458. get diffuseColor(): NodeMaterialConnectionPoint;
  133459. /**
  133460. * Gets the specular color component
  133461. */
  133462. get specularColor(): NodeMaterialConnectionPoint;
  133463. /**
  133464. * Gets the diffuse output component
  133465. */
  133466. get diffuseOutput(): NodeMaterialConnectionPoint;
  133467. /**
  133468. * Gets the specular output component
  133469. */
  133470. get specularOutput(): NodeMaterialConnectionPoint;
  133471. /**
  133472. * Gets the shadow output component
  133473. */
  133474. get shadow(): NodeMaterialConnectionPoint;
  133475. autoConfigure(material: NodeMaterial): void;
  133476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133477. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133479. private _injectVertexCode;
  133480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133481. serialize(): any;
  133482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133483. }
  133484. }
  133485. declare module BABYLON {
  133486. /**
  133487. * Block used to multiply 2 values
  133488. */
  133489. export class MultiplyBlock extends NodeMaterialBlock {
  133490. /**
  133491. * Creates a new MultiplyBlock
  133492. * @param name defines the block name
  133493. */
  133494. constructor(name: string);
  133495. /**
  133496. * Gets the current class name
  133497. * @returns the class name
  133498. */
  133499. getClassName(): string;
  133500. /**
  133501. * Gets the left operand input component
  133502. */
  133503. get left(): NodeMaterialConnectionPoint;
  133504. /**
  133505. * Gets the right operand input component
  133506. */
  133507. get right(): NodeMaterialConnectionPoint;
  133508. /**
  133509. * Gets the output component
  133510. */
  133511. get output(): NodeMaterialConnectionPoint;
  133512. protected _buildBlock(state: NodeMaterialBuildState): this;
  133513. }
  133514. }
  133515. declare module BABYLON {
  133516. /**
  133517. * Block used to add 2 vectors
  133518. */
  133519. export class AddBlock extends NodeMaterialBlock {
  133520. /**
  133521. * Creates a new AddBlock
  133522. * @param name defines the block name
  133523. */
  133524. constructor(name: string);
  133525. /**
  133526. * Gets the current class name
  133527. * @returns the class name
  133528. */
  133529. getClassName(): string;
  133530. /**
  133531. * Gets the left operand input component
  133532. */
  133533. get left(): NodeMaterialConnectionPoint;
  133534. /**
  133535. * Gets the right operand input component
  133536. */
  133537. get right(): NodeMaterialConnectionPoint;
  133538. /**
  133539. * Gets the output component
  133540. */
  133541. get output(): NodeMaterialConnectionPoint;
  133542. protected _buildBlock(state: NodeMaterialBuildState): this;
  133543. }
  133544. }
  133545. declare module BABYLON {
  133546. /**
  133547. * Block used to scale a vector by a float
  133548. */
  133549. export class ScaleBlock extends NodeMaterialBlock {
  133550. /**
  133551. * Creates a new ScaleBlock
  133552. * @param name defines the block name
  133553. */
  133554. constructor(name: string);
  133555. /**
  133556. * Gets the current class name
  133557. * @returns the class name
  133558. */
  133559. getClassName(): string;
  133560. /**
  133561. * Gets the input component
  133562. */
  133563. get input(): NodeMaterialConnectionPoint;
  133564. /**
  133565. * Gets the factor input component
  133566. */
  133567. get factor(): NodeMaterialConnectionPoint;
  133568. /**
  133569. * Gets the output component
  133570. */
  133571. get output(): NodeMaterialConnectionPoint;
  133572. protected _buildBlock(state: NodeMaterialBuildState): this;
  133573. }
  133574. }
  133575. declare module BABYLON {
  133576. /**
  133577. * Block used to clamp a float
  133578. */
  133579. export class ClampBlock extends NodeMaterialBlock {
  133580. /** Gets or sets the minimum range */
  133581. minimum: number;
  133582. /** Gets or sets the maximum range */
  133583. maximum: number;
  133584. /**
  133585. * Creates a new ClampBlock
  133586. * @param name defines the block name
  133587. */
  133588. constructor(name: string);
  133589. /**
  133590. * Gets the current class name
  133591. * @returns the class name
  133592. */
  133593. getClassName(): string;
  133594. /**
  133595. * Gets the value input component
  133596. */
  133597. get value(): NodeMaterialConnectionPoint;
  133598. /**
  133599. * Gets the output component
  133600. */
  133601. get output(): NodeMaterialConnectionPoint;
  133602. protected _buildBlock(state: NodeMaterialBuildState): this;
  133603. protected _dumpPropertiesCode(): string;
  133604. serialize(): any;
  133605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133606. }
  133607. }
  133608. declare module BABYLON {
  133609. /**
  133610. * Block used to apply a cross product between 2 vectors
  133611. */
  133612. export class CrossBlock extends NodeMaterialBlock {
  133613. /**
  133614. * Creates a new CrossBlock
  133615. * @param name defines the block name
  133616. */
  133617. constructor(name: string);
  133618. /**
  133619. * Gets the current class name
  133620. * @returns the class name
  133621. */
  133622. getClassName(): string;
  133623. /**
  133624. * Gets the left operand input component
  133625. */
  133626. get left(): NodeMaterialConnectionPoint;
  133627. /**
  133628. * Gets the right operand input component
  133629. */
  133630. get right(): NodeMaterialConnectionPoint;
  133631. /**
  133632. * Gets the output component
  133633. */
  133634. get output(): NodeMaterialConnectionPoint;
  133635. protected _buildBlock(state: NodeMaterialBuildState): this;
  133636. }
  133637. }
  133638. declare module BABYLON {
  133639. /**
  133640. * Block used to apply a dot product between 2 vectors
  133641. */
  133642. export class DotBlock extends NodeMaterialBlock {
  133643. /**
  133644. * Creates a new DotBlock
  133645. * @param name defines the block name
  133646. */
  133647. constructor(name: string);
  133648. /**
  133649. * Gets the current class name
  133650. * @returns the class name
  133651. */
  133652. getClassName(): string;
  133653. /**
  133654. * Gets the left operand input component
  133655. */
  133656. get left(): NodeMaterialConnectionPoint;
  133657. /**
  133658. * Gets the right operand input component
  133659. */
  133660. get right(): NodeMaterialConnectionPoint;
  133661. /**
  133662. * Gets the output component
  133663. */
  133664. get output(): NodeMaterialConnectionPoint;
  133665. protected _buildBlock(state: NodeMaterialBuildState): this;
  133666. }
  133667. }
  133668. declare module BABYLON {
  133669. /**
  133670. * Block used to remap a float from a range to a new one
  133671. */
  133672. export class RemapBlock extends NodeMaterialBlock {
  133673. /**
  133674. * Gets or sets the source range
  133675. */
  133676. sourceRange: Vector2;
  133677. /**
  133678. * Gets or sets the target range
  133679. */
  133680. targetRange: Vector2;
  133681. /**
  133682. * Creates a new RemapBlock
  133683. * @param name defines the block name
  133684. */
  133685. constructor(name: string);
  133686. /**
  133687. * Gets the current class name
  133688. * @returns the class name
  133689. */
  133690. getClassName(): string;
  133691. /**
  133692. * Gets the input component
  133693. */
  133694. get input(): NodeMaterialConnectionPoint;
  133695. /**
  133696. * Gets the source min input component
  133697. */
  133698. get sourceMin(): NodeMaterialConnectionPoint;
  133699. /**
  133700. * Gets the source max input component
  133701. */
  133702. get sourceMax(): NodeMaterialConnectionPoint;
  133703. /**
  133704. * Gets the target min input component
  133705. */
  133706. get targetMin(): NodeMaterialConnectionPoint;
  133707. /**
  133708. * Gets the target max input component
  133709. */
  133710. get targetMax(): NodeMaterialConnectionPoint;
  133711. /**
  133712. * Gets the output component
  133713. */
  133714. get output(): NodeMaterialConnectionPoint;
  133715. protected _buildBlock(state: NodeMaterialBuildState): this;
  133716. protected _dumpPropertiesCode(): string;
  133717. serialize(): any;
  133718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133719. }
  133720. }
  133721. declare module BABYLON {
  133722. /**
  133723. * Block used to normalize a vector
  133724. */
  133725. export class NormalizeBlock extends NodeMaterialBlock {
  133726. /**
  133727. * Creates a new NormalizeBlock
  133728. * @param name defines the block name
  133729. */
  133730. constructor(name: string);
  133731. /**
  133732. * Gets the current class name
  133733. * @returns the class name
  133734. */
  133735. getClassName(): string;
  133736. /**
  133737. * Gets the input component
  133738. */
  133739. get input(): NodeMaterialConnectionPoint;
  133740. /**
  133741. * Gets the output component
  133742. */
  133743. get output(): NodeMaterialConnectionPoint;
  133744. protected _buildBlock(state: NodeMaterialBuildState): this;
  133745. }
  133746. }
  133747. declare module BABYLON {
  133748. /**
  133749. * Operations supported by the Trigonometry block
  133750. */
  133751. export enum TrigonometryBlockOperations {
  133752. /** Cos */
  133753. Cos = 0,
  133754. /** Sin */
  133755. Sin = 1,
  133756. /** Abs */
  133757. Abs = 2,
  133758. /** Exp */
  133759. Exp = 3,
  133760. /** Exp2 */
  133761. Exp2 = 4,
  133762. /** Round */
  133763. Round = 5,
  133764. /** Floor */
  133765. Floor = 6,
  133766. /** Ceiling */
  133767. Ceiling = 7,
  133768. /** Square root */
  133769. Sqrt = 8,
  133770. /** Log */
  133771. Log = 9,
  133772. /** Tangent */
  133773. Tan = 10,
  133774. /** Arc tangent */
  133775. ArcTan = 11,
  133776. /** Arc cosinus */
  133777. ArcCos = 12,
  133778. /** Arc sinus */
  133779. ArcSin = 13,
  133780. /** Fraction */
  133781. Fract = 14,
  133782. /** Sign */
  133783. Sign = 15,
  133784. /** To radians (from degrees) */
  133785. Radians = 16,
  133786. /** To degrees (from radians) */
  133787. Degrees = 17
  133788. }
  133789. /**
  133790. * Block used to apply trigonometry operation to floats
  133791. */
  133792. export class TrigonometryBlock extends NodeMaterialBlock {
  133793. /**
  133794. * Gets or sets the operation applied by the block
  133795. */
  133796. operation: TrigonometryBlockOperations;
  133797. /**
  133798. * Creates a new TrigonometryBlock
  133799. * @param name defines the block name
  133800. */
  133801. constructor(name: string);
  133802. /**
  133803. * Gets the current class name
  133804. * @returns the class name
  133805. */
  133806. getClassName(): string;
  133807. /**
  133808. * Gets the input component
  133809. */
  133810. get input(): NodeMaterialConnectionPoint;
  133811. /**
  133812. * Gets the output component
  133813. */
  133814. get output(): NodeMaterialConnectionPoint;
  133815. protected _buildBlock(state: NodeMaterialBuildState): this;
  133816. serialize(): any;
  133817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133818. protected _dumpPropertiesCode(): string;
  133819. }
  133820. }
  133821. declare module BABYLON {
  133822. /**
  133823. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133824. */
  133825. export class ColorMergerBlock extends NodeMaterialBlock {
  133826. /**
  133827. * Create a new ColorMergerBlock
  133828. * @param name defines the block name
  133829. */
  133830. constructor(name: string);
  133831. /**
  133832. * Gets the current class name
  133833. * @returns the class name
  133834. */
  133835. getClassName(): string;
  133836. /**
  133837. * Gets the rgb component (input)
  133838. */
  133839. get rgbIn(): NodeMaterialConnectionPoint;
  133840. /**
  133841. * Gets the r component (input)
  133842. */
  133843. get r(): NodeMaterialConnectionPoint;
  133844. /**
  133845. * Gets the g component (input)
  133846. */
  133847. get g(): NodeMaterialConnectionPoint;
  133848. /**
  133849. * Gets the b component (input)
  133850. */
  133851. get b(): NodeMaterialConnectionPoint;
  133852. /**
  133853. * Gets the a component (input)
  133854. */
  133855. get a(): NodeMaterialConnectionPoint;
  133856. /**
  133857. * Gets the rgba component (output)
  133858. */
  133859. get rgba(): NodeMaterialConnectionPoint;
  133860. /**
  133861. * Gets the rgb component (output)
  133862. */
  133863. get rgbOut(): NodeMaterialConnectionPoint;
  133864. /**
  133865. * Gets the rgb component (output)
  133866. * @deprecated Please use rgbOut instead.
  133867. */
  133868. get rgb(): NodeMaterialConnectionPoint;
  133869. protected _buildBlock(state: NodeMaterialBuildState): this;
  133870. }
  133871. }
  133872. declare module BABYLON {
  133873. /**
  133874. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133875. */
  133876. export class VectorMergerBlock extends NodeMaterialBlock {
  133877. /**
  133878. * Create a new VectorMergerBlock
  133879. * @param name defines the block name
  133880. */
  133881. constructor(name: string);
  133882. /**
  133883. * Gets the current class name
  133884. * @returns the class name
  133885. */
  133886. getClassName(): string;
  133887. /**
  133888. * Gets the xyz component (input)
  133889. */
  133890. get xyzIn(): NodeMaterialConnectionPoint;
  133891. /**
  133892. * Gets the xy component (input)
  133893. */
  133894. get xyIn(): NodeMaterialConnectionPoint;
  133895. /**
  133896. * Gets the x component (input)
  133897. */
  133898. get x(): NodeMaterialConnectionPoint;
  133899. /**
  133900. * Gets the y component (input)
  133901. */
  133902. get y(): NodeMaterialConnectionPoint;
  133903. /**
  133904. * Gets the z component (input)
  133905. */
  133906. get z(): NodeMaterialConnectionPoint;
  133907. /**
  133908. * Gets the w component (input)
  133909. */
  133910. get w(): NodeMaterialConnectionPoint;
  133911. /**
  133912. * Gets the xyzw component (output)
  133913. */
  133914. get xyzw(): NodeMaterialConnectionPoint;
  133915. /**
  133916. * Gets the xyz component (output)
  133917. */
  133918. get xyzOut(): NodeMaterialConnectionPoint;
  133919. /**
  133920. * Gets the xy component (output)
  133921. */
  133922. get xyOut(): NodeMaterialConnectionPoint;
  133923. /**
  133924. * Gets the xy component (output)
  133925. * @deprecated Please use xyOut instead.
  133926. */
  133927. get xy(): NodeMaterialConnectionPoint;
  133928. /**
  133929. * Gets the xyz component (output)
  133930. * @deprecated Please use xyzOut instead.
  133931. */
  133932. get xyz(): NodeMaterialConnectionPoint;
  133933. protected _buildBlock(state: NodeMaterialBuildState): this;
  133934. }
  133935. }
  133936. declare module BABYLON {
  133937. /**
  133938. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133939. */
  133940. export class ColorSplitterBlock extends NodeMaterialBlock {
  133941. /**
  133942. * Create a new ColorSplitterBlock
  133943. * @param name defines the block name
  133944. */
  133945. constructor(name: string);
  133946. /**
  133947. * Gets the current class name
  133948. * @returns the class name
  133949. */
  133950. getClassName(): string;
  133951. /**
  133952. * Gets the rgba component (input)
  133953. */
  133954. get rgba(): NodeMaterialConnectionPoint;
  133955. /**
  133956. * Gets the rgb component (input)
  133957. */
  133958. get rgbIn(): NodeMaterialConnectionPoint;
  133959. /**
  133960. * Gets the rgb component (output)
  133961. */
  133962. get rgbOut(): NodeMaterialConnectionPoint;
  133963. /**
  133964. * Gets the r component (output)
  133965. */
  133966. get r(): NodeMaterialConnectionPoint;
  133967. /**
  133968. * Gets the g component (output)
  133969. */
  133970. get g(): NodeMaterialConnectionPoint;
  133971. /**
  133972. * Gets the b component (output)
  133973. */
  133974. get b(): NodeMaterialConnectionPoint;
  133975. /**
  133976. * Gets the a component (output)
  133977. */
  133978. get a(): NodeMaterialConnectionPoint;
  133979. protected _inputRename(name: string): string;
  133980. protected _outputRename(name: string): string;
  133981. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133982. }
  133983. }
  133984. declare module BABYLON {
  133985. /**
  133986. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133987. */
  133988. export class VectorSplitterBlock extends NodeMaterialBlock {
  133989. /**
  133990. * Create a new VectorSplitterBlock
  133991. * @param name defines the block name
  133992. */
  133993. constructor(name: string);
  133994. /**
  133995. * Gets the current class name
  133996. * @returns the class name
  133997. */
  133998. getClassName(): string;
  133999. /**
  134000. * Gets the xyzw component (input)
  134001. */
  134002. get xyzw(): NodeMaterialConnectionPoint;
  134003. /**
  134004. * Gets the xyz component (input)
  134005. */
  134006. get xyzIn(): NodeMaterialConnectionPoint;
  134007. /**
  134008. * Gets the xy component (input)
  134009. */
  134010. get xyIn(): NodeMaterialConnectionPoint;
  134011. /**
  134012. * Gets the xyz component (output)
  134013. */
  134014. get xyzOut(): NodeMaterialConnectionPoint;
  134015. /**
  134016. * Gets the xy component (output)
  134017. */
  134018. get xyOut(): NodeMaterialConnectionPoint;
  134019. /**
  134020. * Gets the x component (output)
  134021. */
  134022. get x(): NodeMaterialConnectionPoint;
  134023. /**
  134024. * Gets the y component (output)
  134025. */
  134026. get y(): NodeMaterialConnectionPoint;
  134027. /**
  134028. * Gets the z component (output)
  134029. */
  134030. get z(): NodeMaterialConnectionPoint;
  134031. /**
  134032. * Gets the w component (output)
  134033. */
  134034. get w(): NodeMaterialConnectionPoint;
  134035. protected _inputRename(name: string): string;
  134036. protected _outputRename(name: string): string;
  134037. protected _buildBlock(state: NodeMaterialBuildState): this;
  134038. }
  134039. }
  134040. declare module BABYLON {
  134041. /**
  134042. * Block used to lerp between 2 values
  134043. */
  134044. export class LerpBlock extends NodeMaterialBlock {
  134045. /**
  134046. * Creates a new LerpBlock
  134047. * @param name defines the block name
  134048. */
  134049. constructor(name: string);
  134050. /**
  134051. * Gets the current class name
  134052. * @returns the class name
  134053. */
  134054. getClassName(): string;
  134055. /**
  134056. * Gets the left operand input component
  134057. */
  134058. get left(): NodeMaterialConnectionPoint;
  134059. /**
  134060. * Gets the right operand input component
  134061. */
  134062. get right(): NodeMaterialConnectionPoint;
  134063. /**
  134064. * Gets the gradient operand input component
  134065. */
  134066. get gradient(): NodeMaterialConnectionPoint;
  134067. /**
  134068. * Gets the output component
  134069. */
  134070. get output(): NodeMaterialConnectionPoint;
  134071. protected _buildBlock(state: NodeMaterialBuildState): this;
  134072. }
  134073. }
  134074. declare module BABYLON {
  134075. /**
  134076. * Block used to divide 2 vectors
  134077. */
  134078. export class DivideBlock extends NodeMaterialBlock {
  134079. /**
  134080. * Creates a new DivideBlock
  134081. * @param name defines the block name
  134082. */
  134083. constructor(name: string);
  134084. /**
  134085. * Gets the current class name
  134086. * @returns the class name
  134087. */
  134088. getClassName(): string;
  134089. /**
  134090. * Gets the left operand input component
  134091. */
  134092. get left(): NodeMaterialConnectionPoint;
  134093. /**
  134094. * Gets the right operand input component
  134095. */
  134096. get right(): NodeMaterialConnectionPoint;
  134097. /**
  134098. * Gets the output component
  134099. */
  134100. get output(): NodeMaterialConnectionPoint;
  134101. protected _buildBlock(state: NodeMaterialBuildState): this;
  134102. }
  134103. }
  134104. declare module BABYLON {
  134105. /**
  134106. * Block used to subtract 2 vectors
  134107. */
  134108. export class SubtractBlock extends NodeMaterialBlock {
  134109. /**
  134110. * Creates a new SubtractBlock
  134111. * @param name defines the block name
  134112. */
  134113. constructor(name: string);
  134114. /**
  134115. * Gets the current class name
  134116. * @returns the class name
  134117. */
  134118. getClassName(): string;
  134119. /**
  134120. * Gets the left operand input component
  134121. */
  134122. get left(): NodeMaterialConnectionPoint;
  134123. /**
  134124. * Gets the right operand input component
  134125. */
  134126. get right(): NodeMaterialConnectionPoint;
  134127. /**
  134128. * Gets the output component
  134129. */
  134130. get output(): NodeMaterialConnectionPoint;
  134131. protected _buildBlock(state: NodeMaterialBuildState): this;
  134132. }
  134133. }
  134134. declare module BABYLON {
  134135. /**
  134136. * Block used to step a value
  134137. */
  134138. export class StepBlock extends NodeMaterialBlock {
  134139. /**
  134140. * Creates a new StepBlock
  134141. * @param name defines the block name
  134142. */
  134143. constructor(name: string);
  134144. /**
  134145. * Gets the current class name
  134146. * @returns the class name
  134147. */
  134148. getClassName(): string;
  134149. /**
  134150. * Gets the value operand input component
  134151. */
  134152. get value(): NodeMaterialConnectionPoint;
  134153. /**
  134154. * Gets the edge operand input component
  134155. */
  134156. get edge(): NodeMaterialConnectionPoint;
  134157. /**
  134158. * Gets the output component
  134159. */
  134160. get output(): NodeMaterialConnectionPoint;
  134161. protected _buildBlock(state: NodeMaterialBuildState): this;
  134162. }
  134163. }
  134164. declare module BABYLON {
  134165. /**
  134166. * Block used to get the opposite (1 - x) of a value
  134167. */
  134168. export class OneMinusBlock extends NodeMaterialBlock {
  134169. /**
  134170. * Creates a new OneMinusBlock
  134171. * @param name defines the block name
  134172. */
  134173. constructor(name: string);
  134174. /**
  134175. * Gets the current class name
  134176. * @returns the class name
  134177. */
  134178. getClassName(): string;
  134179. /**
  134180. * Gets the input component
  134181. */
  134182. get input(): NodeMaterialConnectionPoint;
  134183. /**
  134184. * Gets the output component
  134185. */
  134186. get output(): NodeMaterialConnectionPoint;
  134187. protected _buildBlock(state: NodeMaterialBuildState): this;
  134188. }
  134189. }
  134190. declare module BABYLON {
  134191. /**
  134192. * Block used to get the view direction
  134193. */
  134194. export class ViewDirectionBlock extends NodeMaterialBlock {
  134195. /**
  134196. * Creates a new ViewDirectionBlock
  134197. * @param name defines the block name
  134198. */
  134199. constructor(name: string);
  134200. /**
  134201. * Gets the current class name
  134202. * @returns the class name
  134203. */
  134204. getClassName(): string;
  134205. /**
  134206. * Gets the world position component
  134207. */
  134208. get worldPosition(): NodeMaterialConnectionPoint;
  134209. /**
  134210. * Gets the camera position component
  134211. */
  134212. get cameraPosition(): NodeMaterialConnectionPoint;
  134213. /**
  134214. * Gets the output component
  134215. */
  134216. get output(): NodeMaterialConnectionPoint;
  134217. autoConfigure(material: NodeMaterial): void;
  134218. protected _buildBlock(state: NodeMaterialBuildState): this;
  134219. }
  134220. }
  134221. declare module BABYLON {
  134222. /**
  134223. * Block used to compute fresnel value
  134224. */
  134225. export class FresnelBlock extends NodeMaterialBlock {
  134226. /**
  134227. * Create a new FresnelBlock
  134228. * @param name defines the block name
  134229. */
  134230. constructor(name: string);
  134231. /**
  134232. * Gets the current class name
  134233. * @returns the class name
  134234. */
  134235. getClassName(): string;
  134236. /**
  134237. * Gets the world normal input component
  134238. */
  134239. get worldNormal(): NodeMaterialConnectionPoint;
  134240. /**
  134241. * Gets the view direction input component
  134242. */
  134243. get viewDirection(): NodeMaterialConnectionPoint;
  134244. /**
  134245. * Gets the bias input component
  134246. */
  134247. get bias(): NodeMaterialConnectionPoint;
  134248. /**
  134249. * Gets the camera (or eye) position component
  134250. */
  134251. get power(): NodeMaterialConnectionPoint;
  134252. /**
  134253. * Gets the fresnel output component
  134254. */
  134255. get fresnel(): NodeMaterialConnectionPoint;
  134256. autoConfigure(material: NodeMaterial): void;
  134257. protected _buildBlock(state: NodeMaterialBuildState): this;
  134258. }
  134259. }
  134260. declare module BABYLON {
  134261. /**
  134262. * Block used to get the max of 2 values
  134263. */
  134264. export class MaxBlock extends NodeMaterialBlock {
  134265. /**
  134266. * Creates a new MaxBlock
  134267. * @param name defines the block name
  134268. */
  134269. constructor(name: string);
  134270. /**
  134271. * Gets the current class name
  134272. * @returns the class name
  134273. */
  134274. getClassName(): string;
  134275. /**
  134276. * Gets the left operand input component
  134277. */
  134278. get left(): NodeMaterialConnectionPoint;
  134279. /**
  134280. * Gets the right operand input component
  134281. */
  134282. get right(): NodeMaterialConnectionPoint;
  134283. /**
  134284. * Gets the output component
  134285. */
  134286. get output(): NodeMaterialConnectionPoint;
  134287. protected _buildBlock(state: NodeMaterialBuildState): this;
  134288. }
  134289. }
  134290. declare module BABYLON {
  134291. /**
  134292. * Block used to get the min of 2 values
  134293. */
  134294. export class MinBlock extends NodeMaterialBlock {
  134295. /**
  134296. * Creates a new MinBlock
  134297. * @param name defines the block name
  134298. */
  134299. constructor(name: string);
  134300. /**
  134301. * Gets the current class name
  134302. * @returns the class name
  134303. */
  134304. getClassName(): string;
  134305. /**
  134306. * Gets the left operand input component
  134307. */
  134308. get left(): NodeMaterialConnectionPoint;
  134309. /**
  134310. * Gets the right operand input component
  134311. */
  134312. get right(): NodeMaterialConnectionPoint;
  134313. /**
  134314. * Gets the output component
  134315. */
  134316. get output(): NodeMaterialConnectionPoint;
  134317. protected _buildBlock(state: NodeMaterialBuildState): this;
  134318. }
  134319. }
  134320. declare module BABYLON {
  134321. /**
  134322. * Block used to get the distance between 2 values
  134323. */
  134324. export class DistanceBlock extends NodeMaterialBlock {
  134325. /**
  134326. * Creates a new DistanceBlock
  134327. * @param name defines the block name
  134328. */
  134329. constructor(name: string);
  134330. /**
  134331. * Gets the current class name
  134332. * @returns the class name
  134333. */
  134334. getClassName(): string;
  134335. /**
  134336. * Gets the left operand input component
  134337. */
  134338. get left(): NodeMaterialConnectionPoint;
  134339. /**
  134340. * Gets the right operand input component
  134341. */
  134342. get right(): NodeMaterialConnectionPoint;
  134343. /**
  134344. * Gets the output component
  134345. */
  134346. get output(): NodeMaterialConnectionPoint;
  134347. protected _buildBlock(state: NodeMaterialBuildState): this;
  134348. }
  134349. }
  134350. declare module BABYLON {
  134351. /**
  134352. * Block used to get the length of a vector
  134353. */
  134354. export class LengthBlock extends NodeMaterialBlock {
  134355. /**
  134356. * Creates a new LengthBlock
  134357. * @param name defines the block name
  134358. */
  134359. constructor(name: string);
  134360. /**
  134361. * Gets the current class name
  134362. * @returns the class name
  134363. */
  134364. getClassName(): string;
  134365. /**
  134366. * Gets the value input component
  134367. */
  134368. get value(): NodeMaterialConnectionPoint;
  134369. /**
  134370. * Gets the output component
  134371. */
  134372. get output(): NodeMaterialConnectionPoint;
  134373. protected _buildBlock(state: NodeMaterialBuildState): this;
  134374. }
  134375. }
  134376. declare module BABYLON {
  134377. /**
  134378. * Block used to get negative version of a value (i.e. x * -1)
  134379. */
  134380. export class NegateBlock extends NodeMaterialBlock {
  134381. /**
  134382. * Creates a new NegateBlock
  134383. * @param name defines the block name
  134384. */
  134385. constructor(name: string);
  134386. /**
  134387. * Gets the current class name
  134388. * @returns the class name
  134389. */
  134390. getClassName(): string;
  134391. /**
  134392. * Gets the value input component
  134393. */
  134394. get value(): NodeMaterialConnectionPoint;
  134395. /**
  134396. * Gets the output component
  134397. */
  134398. get output(): NodeMaterialConnectionPoint;
  134399. protected _buildBlock(state: NodeMaterialBuildState): this;
  134400. }
  134401. }
  134402. declare module BABYLON {
  134403. /**
  134404. * Block used to get the value of the first parameter raised to the power of the second
  134405. */
  134406. export class PowBlock extends NodeMaterialBlock {
  134407. /**
  134408. * Creates a new PowBlock
  134409. * @param name defines the block name
  134410. */
  134411. constructor(name: string);
  134412. /**
  134413. * Gets the current class name
  134414. * @returns the class name
  134415. */
  134416. getClassName(): string;
  134417. /**
  134418. * Gets the value operand input component
  134419. */
  134420. get value(): NodeMaterialConnectionPoint;
  134421. /**
  134422. * Gets the power operand input component
  134423. */
  134424. get power(): NodeMaterialConnectionPoint;
  134425. /**
  134426. * Gets the output component
  134427. */
  134428. get output(): NodeMaterialConnectionPoint;
  134429. protected _buildBlock(state: NodeMaterialBuildState): this;
  134430. }
  134431. }
  134432. declare module BABYLON {
  134433. /**
  134434. * Block used to get a random number
  134435. */
  134436. export class RandomNumberBlock extends NodeMaterialBlock {
  134437. /**
  134438. * Creates a new RandomNumberBlock
  134439. * @param name defines the block name
  134440. */
  134441. constructor(name: string);
  134442. /**
  134443. * Gets the current class name
  134444. * @returns the class name
  134445. */
  134446. getClassName(): string;
  134447. /**
  134448. * Gets the seed input component
  134449. */
  134450. get seed(): NodeMaterialConnectionPoint;
  134451. /**
  134452. * Gets the output component
  134453. */
  134454. get output(): NodeMaterialConnectionPoint;
  134455. protected _buildBlock(state: NodeMaterialBuildState): this;
  134456. }
  134457. }
  134458. declare module BABYLON {
  134459. /**
  134460. * Block used to compute arc tangent of 2 values
  134461. */
  134462. export class ArcTan2Block extends NodeMaterialBlock {
  134463. /**
  134464. * Creates a new ArcTan2Block
  134465. * @param name defines the block name
  134466. */
  134467. constructor(name: string);
  134468. /**
  134469. * Gets the current class name
  134470. * @returns the class name
  134471. */
  134472. getClassName(): string;
  134473. /**
  134474. * Gets the x operand input component
  134475. */
  134476. get x(): NodeMaterialConnectionPoint;
  134477. /**
  134478. * Gets the y operand input component
  134479. */
  134480. get y(): NodeMaterialConnectionPoint;
  134481. /**
  134482. * Gets the output component
  134483. */
  134484. get output(): NodeMaterialConnectionPoint;
  134485. protected _buildBlock(state: NodeMaterialBuildState): this;
  134486. }
  134487. }
  134488. declare module BABYLON {
  134489. /**
  134490. * Block used to smooth step a value
  134491. */
  134492. export class SmoothStepBlock extends NodeMaterialBlock {
  134493. /**
  134494. * Creates a new SmoothStepBlock
  134495. * @param name defines the block name
  134496. */
  134497. constructor(name: string);
  134498. /**
  134499. * Gets the current class name
  134500. * @returns the class name
  134501. */
  134502. getClassName(): string;
  134503. /**
  134504. * Gets the value operand input component
  134505. */
  134506. get value(): NodeMaterialConnectionPoint;
  134507. /**
  134508. * Gets the first edge operand input component
  134509. */
  134510. get edge0(): NodeMaterialConnectionPoint;
  134511. /**
  134512. * Gets the second edge operand input component
  134513. */
  134514. get edge1(): NodeMaterialConnectionPoint;
  134515. /**
  134516. * Gets the output component
  134517. */
  134518. get output(): NodeMaterialConnectionPoint;
  134519. protected _buildBlock(state: NodeMaterialBuildState): this;
  134520. }
  134521. }
  134522. declare module BABYLON {
  134523. /**
  134524. * Block used to get the reciprocal (1 / x) of a value
  134525. */
  134526. export class ReciprocalBlock extends NodeMaterialBlock {
  134527. /**
  134528. * Creates a new ReciprocalBlock
  134529. * @param name defines the block name
  134530. */
  134531. constructor(name: string);
  134532. /**
  134533. * Gets the current class name
  134534. * @returns the class name
  134535. */
  134536. getClassName(): string;
  134537. /**
  134538. * Gets the input component
  134539. */
  134540. get input(): NodeMaterialConnectionPoint;
  134541. /**
  134542. * Gets the output component
  134543. */
  134544. get output(): NodeMaterialConnectionPoint;
  134545. protected _buildBlock(state: NodeMaterialBuildState): this;
  134546. }
  134547. }
  134548. declare module BABYLON {
  134549. /**
  134550. * Block used to replace a color by another one
  134551. */
  134552. export class ReplaceColorBlock extends NodeMaterialBlock {
  134553. /**
  134554. * Creates a new ReplaceColorBlock
  134555. * @param name defines the block name
  134556. */
  134557. constructor(name: string);
  134558. /**
  134559. * Gets the current class name
  134560. * @returns the class name
  134561. */
  134562. getClassName(): string;
  134563. /**
  134564. * Gets the value input component
  134565. */
  134566. get value(): NodeMaterialConnectionPoint;
  134567. /**
  134568. * Gets the reference input component
  134569. */
  134570. get reference(): NodeMaterialConnectionPoint;
  134571. /**
  134572. * Gets the distance input component
  134573. */
  134574. get distance(): NodeMaterialConnectionPoint;
  134575. /**
  134576. * Gets the replacement input component
  134577. */
  134578. get replacement(): NodeMaterialConnectionPoint;
  134579. /**
  134580. * Gets the output component
  134581. */
  134582. get output(): NodeMaterialConnectionPoint;
  134583. protected _buildBlock(state: NodeMaterialBuildState): this;
  134584. }
  134585. }
  134586. declare module BABYLON {
  134587. /**
  134588. * Block used to posterize a value
  134589. * @see https://en.wikipedia.org/wiki/Posterization
  134590. */
  134591. export class PosterizeBlock extends NodeMaterialBlock {
  134592. /**
  134593. * Creates a new PosterizeBlock
  134594. * @param name defines the block name
  134595. */
  134596. constructor(name: string);
  134597. /**
  134598. * Gets the current class name
  134599. * @returns the class name
  134600. */
  134601. getClassName(): string;
  134602. /**
  134603. * Gets the value input component
  134604. */
  134605. get value(): NodeMaterialConnectionPoint;
  134606. /**
  134607. * Gets the steps input component
  134608. */
  134609. get steps(): NodeMaterialConnectionPoint;
  134610. /**
  134611. * Gets the output component
  134612. */
  134613. get output(): NodeMaterialConnectionPoint;
  134614. protected _buildBlock(state: NodeMaterialBuildState): this;
  134615. }
  134616. }
  134617. declare module BABYLON {
  134618. /**
  134619. * Operations supported by the Wave block
  134620. */
  134621. export enum WaveBlockKind {
  134622. /** SawTooth */
  134623. SawTooth = 0,
  134624. /** Square */
  134625. Square = 1,
  134626. /** Triangle */
  134627. Triangle = 2
  134628. }
  134629. /**
  134630. * Block used to apply wave operation to floats
  134631. */
  134632. export class WaveBlock extends NodeMaterialBlock {
  134633. /**
  134634. * Gets or sets the kibnd of wave to be applied by the block
  134635. */
  134636. kind: WaveBlockKind;
  134637. /**
  134638. * Creates a new WaveBlock
  134639. * @param name defines the block name
  134640. */
  134641. constructor(name: string);
  134642. /**
  134643. * Gets the current class name
  134644. * @returns the class name
  134645. */
  134646. getClassName(): string;
  134647. /**
  134648. * Gets the input component
  134649. */
  134650. get input(): NodeMaterialConnectionPoint;
  134651. /**
  134652. * Gets the output component
  134653. */
  134654. get output(): NodeMaterialConnectionPoint;
  134655. protected _buildBlock(state: NodeMaterialBuildState): this;
  134656. serialize(): any;
  134657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134658. }
  134659. }
  134660. declare module BABYLON {
  134661. /**
  134662. * Class used to store a color step for the GradientBlock
  134663. */
  134664. export class GradientBlockColorStep {
  134665. /**
  134666. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134667. */
  134668. step: number;
  134669. /**
  134670. * Gets or sets the color associated with this step
  134671. */
  134672. color: Color3;
  134673. /**
  134674. * Creates a new GradientBlockColorStep
  134675. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134676. * @param color defines the color associated with this step
  134677. */
  134678. constructor(
  134679. /**
  134680. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134681. */
  134682. step: number,
  134683. /**
  134684. * Gets or sets the color associated with this step
  134685. */
  134686. color: Color3);
  134687. }
  134688. /**
  134689. * Block used to return a color from a gradient based on an input value between 0 and 1
  134690. */
  134691. export class GradientBlock extends NodeMaterialBlock {
  134692. /**
  134693. * Gets or sets the list of color steps
  134694. */
  134695. colorSteps: GradientBlockColorStep[];
  134696. /**
  134697. * Creates a new GradientBlock
  134698. * @param name defines the block name
  134699. */
  134700. constructor(name: string);
  134701. /**
  134702. * Gets the current class name
  134703. * @returns the class name
  134704. */
  134705. getClassName(): string;
  134706. /**
  134707. * Gets the gradient input component
  134708. */
  134709. get gradient(): NodeMaterialConnectionPoint;
  134710. /**
  134711. * Gets the output component
  134712. */
  134713. get output(): NodeMaterialConnectionPoint;
  134714. private _writeColorConstant;
  134715. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134716. serialize(): any;
  134717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134718. protected _dumpPropertiesCode(): string;
  134719. }
  134720. }
  134721. declare module BABYLON {
  134722. /**
  134723. * Block used to normalize lerp between 2 values
  134724. */
  134725. export class NLerpBlock extends NodeMaterialBlock {
  134726. /**
  134727. * Creates a new NLerpBlock
  134728. * @param name defines the block name
  134729. */
  134730. constructor(name: string);
  134731. /**
  134732. * Gets the current class name
  134733. * @returns the class name
  134734. */
  134735. getClassName(): string;
  134736. /**
  134737. * Gets the left operand input component
  134738. */
  134739. get left(): NodeMaterialConnectionPoint;
  134740. /**
  134741. * Gets the right operand input component
  134742. */
  134743. get right(): NodeMaterialConnectionPoint;
  134744. /**
  134745. * Gets the gradient operand input component
  134746. */
  134747. get gradient(): NodeMaterialConnectionPoint;
  134748. /**
  134749. * Gets the output component
  134750. */
  134751. get output(): NodeMaterialConnectionPoint;
  134752. protected _buildBlock(state: NodeMaterialBuildState): this;
  134753. }
  134754. }
  134755. declare module BABYLON {
  134756. /**
  134757. * block used to Generate a Worley Noise 3D Noise Pattern
  134758. */
  134759. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134760. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134761. manhattanDistance: boolean;
  134762. /**
  134763. * Creates a new WorleyNoise3DBlock
  134764. * @param name defines the block name
  134765. */
  134766. constructor(name: string);
  134767. /**
  134768. * Gets the current class name
  134769. * @returns the class name
  134770. */
  134771. getClassName(): string;
  134772. /**
  134773. * Gets the seed input component
  134774. */
  134775. get seed(): NodeMaterialConnectionPoint;
  134776. /**
  134777. * Gets the jitter input component
  134778. */
  134779. get jitter(): NodeMaterialConnectionPoint;
  134780. /**
  134781. * Gets the output component
  134782. */
  134783. get output(): NodeMaterialConnectionPoint;
  134784. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134785. /**
  134786. * Exposes the properties to the UI?
  134787. */
  134788. protected _dumpPropertiesCode(): string;
  134789. /**
  134790. * Exposes the properties to the Seralize?
  134791. */
  134792. serialize(): any;
  134793. /**
  134794. * Exposes the properties to the deseralize?
  134795. */
  134796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134797. }
  134798. }
  134799. declare module BABYLON {
  134800. /**
  134801. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134802. */
  134803. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134804. /**
  134805. * Creates a new SimplexPerlin3DBlock
  134806. * @param name defines the block name
  134807. */
  134808. constructor(name: string);
  134809. /**
  134810. * Gets the current class name
  134811. * @returns the class name
  134812. */
  134813. getClassName(): string;
  134814. /**
  134815. * Gets the seed operand input component
  134816. */
  134817. get seed(): NodeMaterialConnectionPoint;
  134818. /**
  134819. * Gets the output component
  134820. */
  134821. get output(): NodeMaterialConnectionPoint;
  134822. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134823. }
  134824. }
  134825. declare module BABYLON {
  134826. /**
  134827. * Block used to blend normals
  134828. */
  134829. export class NormalBlendBlock extends NodeMaterialBlock {
  134830. /**
  134831. * Creates a new NormalBlendBlock
  134832. * @param name defines the block name
  134833. */
  134834. constructor(name: string);
  134835. /**
  134836. * Gets the current class name
  134837. * @returns the class name
  134838. */
  134839. getClassName(): string;
  134840. /**
  134841. * Gets the first input component
  134842. */
  134843. get normalMap0(): NodeMaterialConnectionPoint;
  134844. /**
  134845. * Gets the second input component
  134846. */
  134847. get normalMap1(): NodeMaterialConnectionPoint;
  134848. /**
  134849. * Gets the output component
  134850. */
  134851. get output(): NodeMaterialConnectionPoint;
  134852. protected _buildBlock(state: NodeMaterialBuildState): this;
  134853. }
  134854. }
  134855. declare module BABYLON {
  134856. /**
  134857. * Block used to rotate a 2d vector by a given angle
  134858. */
  134859. export class Rotate2dBlock extends NodeMaterialBlock {
  134860. /**
  134861. * Creates a new Rotate2dBlock
  134862. * @param name defines the block name
  134863. */
  134864. constructor(name: string);
  134865. /**
  134866. * Gets the current class name
  134867. * @returns the class name
  134868. */
  134869. getClassName(): string;
  134870. /**
  134871. * Gets the input vector
  134872. */
  134873. get input(): NodeMaterialConnectionPoint;
  134874. /**
  134875. * Gets the input angle
  134876. */
  134877. get angle(): NodeMaterialConnectionPoint;
  134878. /**
  134879. * Gets the output component
  134880. */
  134881. get output(): NodeMaterialConnectionPoint;
  134882. autoConfigure(material: NodeMaterial): void;
  134883. protected _buildBlock(state: NodeMaterialBuildState): this;
  134884. }
  134885. }
  134886. declare module BABYLON {
  134887. /**
  134888. * Block used to get the reflected vector from a direction and a normal
  134889. */
  134890. export class ReflectBlock extends NodeMaterialBlock {
  134891. /**
  134892. * Creates a new ReflectBlock
  134893. * @param name defines the block name
  134894. */
  134895. constructor(name: string);
  134896. /**
  134897. * Gets the current class name
  134898. * @returns the class name
  134899. */
  134900. getClassName(): string;
  134901. /**
  134902. * Gets the incident component
  134903. */
  134904. get incident(): NodeMaterialConnectionPoint;
  134905. /**
  134906. * Gets the normal component
  134907. */
  134908. get normal(): NodeMaterialConnectionPoint;
  134909. /**
  134910. * Gets the output component
  134911. */
  134912. get output(): NodeMaterialConnectionPoint;
  134913. protected _buildBlock(state: NodeMaterialBuildState): this;
  134914. }
  134915. }
  134916. declare module BABYLON {
  134917. /**
  134918. * Block used to get the refracted vector from a direction and a normal
  134919. */
  134920. export class RefractBlock extends NodeMaterialBlock {
  134921. /**
  134922. * Creates a new RefractBlock
  134923. * @param name defines the block name
  134924. */
  134925. constructor(name: string);
  134926. /**
  134927. * Gets the current class name
  134928. * @returns the class name
  134929. */
  134930. getClassName(): string;
  134931. /**
  134932. * Gets the incident component
  134933. */
  134934. get incident(): NodeMaterialConnectionPoint;
  134935. /**
  134936. * Gets the normal component
  134937. */
  134938. get normal(): NodeMaterialConnectionPoint;
  134939. /**
  134940. * Gets the index of refraction component
  134941. */
  134942. get ior(): NodeMaterialConnectionPoint;
  134943. /**
  134944. * Gets the output component
  134945. */
  134946. get output(): NodeMaterialConnectionPoint;
  134947. protected _buildBlock(state: NodeMaterialBuildState): this;
  134948. }
  134949. }
  134950. declare module BABYLON {
  134951. /**
  134952. * Block used to desaturate a color
  134953. */
  134954. export class DesaturateBlock extends NodeMaterialBlock {
  134955. /**
  134956. * Creates a new DesaturateBlock
  134957. * @param name defines the block name
  134958. */
  134959. constructor(name: string);
  134960. /**
  134961. * Gets the current class name
  134962. * @returns the class name
  134963. */
  134964. getClassName(): string;
  134965. /**
  134966. * Gets the color operand input component
  134967. */
  134968. get color(): NodeMaterialConnectionPoint;
  134969. /**
  134970. * Gets the level operand input component
  134971. */
  134972. get level(): NodeMaterialConnectionPoint;
  134973. /**
  134974. * Gets the output component
  134975. */
  134976. get output(): NodeMaterialConnectionPoint;
  134977. protected _buildBlock(state: NodeMaterialBuildState): this;
  134978. }
  134979. }
  134980. declare module BABYLON {
  134981. /**
  134982. * Effect Render Options
  134983. */
  134984. export interface IEffectRendererOptions {
  134985. /**
  134986. * Defines the vertices positions.
  134987. */
  134988. positions?: number[];
  134989. /**
  134990. * Defines the indices.
  134991. */
  134992. indices?: number[];
  134993. }
  134994. /**
  134995. * Helper class to render one or more effects.
  134996. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  134997. */
  134998. export class EffectRenderer {
  134999. private engine;
  135000. private static _DefaultOptions;
  135001. private _vertexBuffers;
  135002. private _indexBuffer;
  135003. private _fullscreenViewport;
  135004. /**
  135005. * Creates an effect renderer
  135006. * @param engine the engine to use for rendering
  135007. * @param options defines the options of the effect renderer
  135008. */
  135009. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135010. /**
  135011. * Sets the current viewport in normalized coordinates 0-1
  135012. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135013. */
  135014. setViewport(viewport?: Viewport): void;
  135015. /**
  135016. * Binds the embedded attributes buffer to the effect.
  135017. * @param effect Defines the effect to bind the attributes for
  135018. */
  135019. bindBuffers(effect: Effect): void;
  135020. /**
  135021. * Sets the current effect wrapper to use during draw.
  135022. * The effect needs to be ready before calling this api.
  135023. * This also sets the default full screen position attribute.
  135024. * @param effectWrapper Defines the effect to draw with
  135025. */
  135026. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135027. /**
  135028. * Draws a full screen quad.
  135029. */
  135030. draw(): void;
  135031. private isRenderTargetTexture;
  135032. /**
  135033. * renders one or more effects to a specified texture
  135034. * @param effectWrapper the effect to renderer
  135035. * @param outputTexture texture to draw to, if null it will render to the screen.
  135036. */
  135037. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135038. /**
  135039. * Disposes of the effect renderer
  135040. */
  135041. dispose(): void;
  135042. }
  135043. /**
  135044. * Options to create an EffectWrapper
  135045. */
  135046. interface EffectWrapperCreationOptions {
  135047. /**
  135048. * Engine to use to create the effect
  135049. */
  135050. engine: ThinEngine;
  135051. /**
  135052. * Fragment shader for the effect
  135053. */
  135054. fragmentShader: string;
  135055. /**
  135056. * Vertex shader for the effect
  135057. */
  135058. vertexShader?: string;
  135059. /**
  135060. * Attributes to use in the shader
  135061. */
  135062. attributeNames?: Array<string>;
  135063. /**
  135064. * Uniforms to use in the shader
  135065. */
  135066. uniformNames?: Array<string>;
  135067. /**
  135068. * Texture sampler names to use in the shader
  135069. */
  135070. samplerNames?: Array<string>;
  135071. /**
  135072. * The friendly name of the effect displayed in Spector.
  135073. */
  135074. name?: string;
  135075. }
  135076. /**
  135077. * Wraps an effect to be used for rendering
  135078. */
  135079. export class EffectWrapper {
  135080. /**
  135081. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135082. */
  135083. onApplyObservable: Observable<{}>;
  135084. /**
  135085. * The underlying effect
  135086. */
  135087. effect: Effect;
  135088. /**
  135089. * Creates an effect to be renderer
  135090. * @param creationOptions options to create the effect
  135091. */
  135092. constructor(creationOptions: EffectWrapperCreationOptions);
  135093. /**
  135094. * Disposes of the effect wrapper
  135095. */
  135096. dispose(): void;
  135097. }
  135098. }
  135099. declare module BABYLON {
  135100. /**
  135101. * Helper class to push actions to a pool of workers.
  135102. */
  135103. export class WorkerPool implements IDisposable {
  135104. private _workerInfos;
  135105. private _pendingActions;
  135106. /**
  135107. * Constructor
  135108. * @param workers Array of workers to use for actions
  135109. */
  135110. constructor(workers: Array<Worker>);
  135111. /**
  135112. * Terminates all workers and clears any pending actions.
  135113. */
  135114. dispose(): void;
  135115. /**
  135116. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135117. * pended until a worker has completed its action.
  135118. * @param action The action to perform. Call onComplete when the action is complete.
  135119. */
  135120. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135121. private _execute;
  135122. }
  135123. }
  135124. declare module BABYLON {
  135125. /**
  135126. * Configuration for Draco compression
  135127. */
  135128. export interface IDracoCompressionConfiguration {
  135129. /**
  135130. * Configuration for the decoder.
  135131. */
  135132. decoder: {
  135133. /**
  135134. * The url to the WebAssembly module.
  135135. */
  135136. wasmUrl?: string;
  135137. /**
  135138. * The url to the WebAssembly binary.
  135139. */
  135140. wasmBinaryUrl?: string;
  135141. /**
  135142. * The url to the fallback JavaScript module.
  135143. */
  135144. fallbackUrl?: string;
  135145. };
  135146. }
  135147. /**
  135148. * Draco compression (https://google.github.io/draco/)
  135149. *
  135150. * This class wraps the Draco module.
  135151. *
  135152. * **Encoder**
  135153. *
  135154. * The encoder is not currently implemented.
  135155. *
  135156. * **Decoder**
  135157. *
  135158. * 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.
  135159. *
  135160. * To update the configuration, use the following code:
  135161. * ```javascript
  135162. * DracoCompression.Configuration = {
  135163. * decoder: {
  135164. * wasmUrl: "<url to the WebAssembly library>",
  135165. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135166. * fallbackUrl: "<url to the fallback JavaScript library>",
  135167. * }
  135168. * };
  135169. * ```
  135170. *
  135171. * 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.
  135172. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135173. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135174. *
  135175. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135176. * ```javascript
  135177. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135178. * ```
  135179. *
  135180. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135181. */
  135182. export class DracoCompression implements IDisposable {
  135183. private _workerPoolPromise?;
  135184. private _decoderModulePromise?;
  135185. /**
  135186. * The configuration. Defaults to the following urls:
  135187. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135188. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135189. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135190. */
  135191. static Configuration: IDracoCompressionConfiguration;
  135192. /**
  135193. * Returns true if the decoder configuration is available.
  135194. */
  135195. static get DecoderAvailable(): boolean;
  135196. /**
  135197. * Default number of workers to create when creating the draco compression object.
  135198. */
  135199. static DefaultNumWorkers: number;
  135200. private static GetDefaultNumWorkers;
  135201. private static _Default;
  135202. /**
  135203. * Default instance for the draco compression object.
  135204. */
  135205. static get Default(): DracoCompression;
  135206. /**
  135207. * Constructor
  135208. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135209. */
  135210. constructor(numWorkers?: number);
  135211. /**
  135212. * Stop all async operations and release resources.
  135213. */
  135214. dispose(): void;
  135215. /**
  135216. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135217. * @returns a promise that resolves when ready
  135218. */
  135219. whenReadyAsync(): Promise<void>;
  135220. /**
  135221. * Decode Draco compressed mesh data to vertex data.
  135222. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135223. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135224. * @returns A promise that resolves with the decoded vertex data
  135225. */
  135226. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135227. [kind: string]: number;
  135228. }): Promise<VertexData>;
  135229. }
  135230. }
  135231. declare module BABYLON {
  135232. /**
  135233. * Class for building Constructive Solid Geometry
  135234. */
  135235. export class CSG {
  135236. private polygons;
  135237. /**
  135238. * The world matrix
  135239. */
  135240. matrix: Matrix;
  135241. /**
  135242. * Stores the position
  135243. */
  135244. position: Vector3;
  135245. /**
  135246. * Stores the rotation
  135247. */
  135248. rotation: Vector3;
  135249. /**
  135250. * Stores the rotation quaternion
  135251. */
  135252. rotationQuaternion: Nullable<Quaternion>;
  135253. /**
  135254. * Stores the scaling vector
  135255. */
  135256. scaling: Vector3;
  135257. /**
  135258. * Convert the Mesh to CSG
  135259. * @param mesh The Mesh to convert to CSG
  135260. * @returns A new CSG from the Mesh
  135261. */
  135262. static FromMesh(mesh: Mesh): CSG;
  135263. /**
  135264. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135265. * @param polygons Polygons used to construct a CSG solid
  135266. */
  135267. private static FromPolygons;
  135268. /**
  135269. * Clones, or makes a deep copy, of the CSG
  135270. * @returns A new CSG
  135271. */
  135272. clone(): CSG;
  135273. /**
  135274. * Unions this CSG with another CSG
  135275. * @param csg The CSG to union against this CSG
  135276. * @returns The unioned CSG
  135277. */
  135278. union(csg: CSG): CSG;
  135279. /**
  135280. * Unions this CSG with another CSG in place
  135281. * @param csg The CSG to union against this CSG
  135282. */
  135283. unionInPlace(csg: CSG): void;
  135284. /**
  135285. * Subtracts this CSG with another CSG
  135286. * @param csg The CSG to subtract against this CSG
  135287. * @returns A new CSG
  135288. */
  135289. subtract(csg: CSG): CSG;
  135290. /**
  135291. * Subtracts this CSG with another CSG in place
  135292. * @param csg The CSG to subtact against this CSG
  135293. */
  135294. subtractInPlace(csg: CSG): void;
  135295. /**
  135296. * Intersect this CSG with another CSG
  135297. * @param csg The CSG to intersect against this CSG
  135298. * @returns A new CSG
  135299. */
  135300. intersect(csg: CSG): CSG;
  135301. /**
  135302. * Intersects this CSG with another CSG in place
  135303. * @param csg The CSG to intersect against this CSG
  135304. */
  135305. intersectInPlace(csg: CSG): void;
  135306. /**
  135307. * Return a new CSG solid with solid and empty space switched. This solid is
  135308. * not modified.
  135309. * @returns A new CSG solid with solid and empty space switched
  135310. */
  135311. inverse(): CSG;
  135312. /**
  135313. * Inverses the CSG in place
  135314. */
  135315. inverseInPlace(): void;
  135316. /**
  135317. * This is used to keep meshes transformations so they can be restored
  135318. * when we build back a Babylon Mesh
  135319. * NB : All CSG operations are performed in world coordinates
  135320. * @param csg The CSG to copy the transform attributes from
  135321. * @returns This CSG
  135322. */
  135323. copyTransformAttributes(csg: CSG): CSG;
  135324. /**
  135325. * Build Raw mesh from CSG
  135326. * Coordinates here are in world space
  135327. * @param name The name of the mesh geometry
  135328. * @param scene The Scene
  135329. * @param keepSubMeshes Specifies if the submeshes should be kept
  135330. * @returns A new Mesh
  135331. */
  135332. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135333. /**
  135334. * Build Mesh from CSG taking material and transforms into account
  135335. * @param name The name of the Mesh
  135336. * @param material The material of the Mesh
  135337. * @param scene The Scene
  135338. * @param keepSubMeshes Specifies if submeshes should be kept
  135339. * @returns The new Mesh
  135340. */
  135341. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135342. }
  135343. }
  135344. declare module BABYLON {
  135345. /**
  135346. * Class used to create a trail following a mesh
  135347. */
  135348. export class TrailMesh extends Mesh {
  135349. private _generator;
  135350. private _autoStart;
  135351. private _running;
  135352. private _diameter;
  135353. private _length;
  135354. private _sectionPolygonPointsCount;
  135355. private _sectionVectors;
  135356. private _sectionNormalVectors;
  135357. private _beforeRenderObserver;
  135358. /**
  135359. * @constructor
  135360. * @param name The value used by scene.getMeshByName() to do a lookup.
  135361. * @param generator The mesh or transform node to generate a trail.
  135362. * @param scene The scene to add this mesh to.
  135363. * @param diameter Diameter of trailing mesh. Default is 1.
  135364. * @param length Length of trailing mesh. Default is 60.
  135365. * @param autoStart Automatically start trailing mesh. Default true.
  135366. */
  135367. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135368. /**
  135369. * "TrailMesh"
  135370. * @returns "TrailMesh"
  135371. */
  135372. getClassName(): string;
  135373. private _createMesh;
  135374. /**
  135375. * Start trailing mesh.
  135376. */
  135377. start(): void;
  135378. /**
  135379. * Stop trailing mesh.
  135380. */
  135381. stop(): void;
  135382. /**
  135383. * Update trailing mesh geometry.
  135384. */
  135385. update(): void;
  135386. /**
  135387. * Returns a new TrailMesh object.
  135388. * @param name is a string, the name given to the new mesh
  135389. * @param newGenerator use new generator object for cloned trail mesh
  135390. * @returns a new mesh
  135391. */
  135392. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135393. /**
  135394. * Serializes this trail mesh
  135395. * @param serializationObject object to write serialization to
  135396. */
  135397. serialize(serializationObject: any): void;
  135398. /**
  135399. * Parses a serialized trail mesh
  135400. * @param parsedMesh the serialized mesh
  135401. * @param scene the scene to create the trail mesh in
  135402. * @returns the created trail mesh
  135403. */
  135404. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135405. }
  135406. }
  135407. declare module BABYLON {
  135408. /**
  135409. * Class containing static functions to help procedurally build meshes
  135410. */
  135411. export class TiledBoxBuilder {
  135412. /**
  135413. * Creates a box mesh
  135414. * 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)
  135415. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135419. * @param name defines the name of the mesh
  135420. * @param options defines the options used to create the mesh
  135421. * @param scene defines the hosting scene
  135422. * @returns the box mesh
  135423. */
  135424. static CreateTiledBox(name: string, options: {
  135425. pattern?: number;
  135426. width?: number;
  135427. height?: number;
  135428. depth?: number;
  135429. tileSize?: number;
  135430. tileWidth?: number;
  135431. tileHeight?: number;
  135432. alignHorizontal?: number;
  135433. alignVertical?: number;
  135434. faceUV?: Vector4[];
  135435. faceColors?: Color4[];
  135436. sideOrientation?: number;
  135437. updatable?: boolean;
  135438. }, scene?: Nullable<Scene>): Mesh;
  135439. }
  135440. }
  135441. declare module BABYLON {
  135442. /**
  135443. * Class containing static functions to help procedurally build meshes
  135444. */
  135445. export class TorusKnotBuilder {
  135446. /**
  135447. * Creates a torus knot mesh
  135448. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135449. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135450. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135451. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135455. * @param name defines the name of the mesh
  135456. * @param options defines the options used to create the mesh
  135457. * @param scene defines the hosting scene
  135458. * @returns the torus knot mesh
  135459. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135460. */
  135461. static CreateTorusKnot(name: string, options: {
  135462. radius?: number;
  135463. tube?: number;
  135464. radialSegments?: number;
  135465. tubularSegments?: number;
  135466. p?: number;
  135467. q?: number;
  135468. updatable?: boolean;
  135469. sideOrientation?: number;
  135470. frontUVs?: Vector4;
  135471. backUVs?: Vector4;
  135472. }, scene: any): Mesh;
  135473. }
  135474. }
  135475. declare module BABYLON {
  135476. /**
  135477. * Polygon
  135478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135479. */
  135480. export class Polygon {
  135481. /**
  135482. * Creates a rectangle
  135483. * @param xmin bottom X coord
  135484. * @param ymin bottom Y coord
  135485. * @param xmax top X coord
  135486. * @param ymax top Y coord
  135487. * @returns points that make the resulting rectation
  135488. */
  135489. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135490. /**
  135491. * Creates a circle
  135492. * @param radius radius of circle
  135493. * @param cx scale in x
  135494. * @param cy scale in y
  135495. * @param numberOfSides number of sides that make up the circle
  135496. * @returns points that make the resulting circle
  135497. */
  135498. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135499. /**
  135500. * Creates a polygon from input string
  135501. * @param input Input polygon data
  135502. * @returns the parsed points
  135503. */
  135504. static Parse(input: string): Vector2[];
  135505. /**
  135506. * Starts building a polygon from x and y coordinates
  135507. * @param x x coordinate
  135508. * @param y y coordinate
  135509. * @returns the started path2
  135510. */
  135511. static StartingAt(x: number, y: number): Path2;
  135512. }
  135513. /**
  135514. * Builds a polygon
  135515. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135516. */
  135517. export class PolygonMeshBuilder {
  135518. private _points;
  135519. private _outlinepoints;
  135520. private _holes;
  135521. private _name;
  135522. private _scene;
  135523. private _epoints;
  135524. private _eholes;
  135525. private _addToepoint;
  135526. /**
  135527. * Babylon reference to the earcut plugin.
  135528. */
  135529. bjsEarcut: any;
  135530. /**
  135531. * Creates a PolygonMeshBuilder
  135532. * @param name name of the builder
  135533. * @param contours Path of the polygon
  135534. * @param scene scene to add to when creating the mesh
  135535. * @param earcutInjection can be used to inject your own earcut reference
  135536. */
  135537. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135538. /**
  135539. * Adds a whole within the polygon
  135540. * @param hole Array of points defining the hole
  135541. * @returns this
  135542. */
  135543. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135544. /**
  135545. * Creates the polygon
  135546. * @param updatable If the mesh should be updatable
  135547. * @param depth The depth of the mesh created
  135548. * @returns the created mesh
  135549. */
  135550. build(updatable?: boolean, depth?: number): Mesh;
  135551. /**
  135552. * Creates the polygon
  135553. * @param depth The depth of the mesh created
  135554. * @returns the created VertexData
  135555. */
  135556. buildVertexData(depth?: number): VertexData;
  135557. /**
  135558. * Adds a side to the polygon
  135559. * @param positions points that make the polygon
  135560. * @param normals normals of the polygon
  135561. * @param uvs uvs of the polygon
  135562. * @param indices indices of the polygon
  135563. * @param bounds bounds of the polygon
  135564. * @param points points of the polygon
  135565. * @param depth depth of the polygon
  135566. * @param flip flip of the polygon
  135567. */
  135568. private addSide;
  135569. }
  135570. }
  135571. declare module BABYLON {
  135572. /**
  135573. * Class containing static functions to help procedurally build meshes
  135574. */
  135575. export class PolygonBuilder {
  135576. /**
  135577. * Creates a polygon mesh
  135578. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135579. * * 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
  135580. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135583. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 CreatePolygon(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. * Creates an extruded polygon mesh, with depth in the Y direction.
  135603. * * 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)
  135604. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135605. * @param name defines the name of the mesh
  135606. * @param options defines the options used to create the mesh
  135607. * @param scene defines the hosting scene
  135608. * @param earcutInjection can be used to inject your own earcut reference
  135609. * @returns the polygon mesh
  135610. */
  135611. static ExtrudePolygon(name: string, options: {
  135612. shape: Vector3[];
  135613. holes?: Vector3[][];
  135614. depth?: number;
  135615. faceUV?: Vector4[];
  135616. faceColors?: Color4[];
  135617. updatable?: boolean;
  135618. sideOrientation?: number;
  135619. frontUVs?: Vector4;
  135620. backUVs?: Vector4;
  135621. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135622. }
  135623. }
  135624. declare module BABYLON {
  135625. /**
  135626. * Class containing static functions to help procedurally build meshes
  135627. */
  135628. export class LatheBuilder {
  135629. /**
  135630. * Creates lathe mesh.
  135631. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135632. * * 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
  135633. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135634. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135635. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135636. * * 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
  135637. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135638. * * 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
  135639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135643. * @param name defines the name of the mesh
  135644. * @param options defines the options used to create the mesh
  135645. * @param scene defines the hosting scene
  135646. * @returns the lathe mesh
  135647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135648. */
  135649. static CreateLathe(name: string, options: {
  135650. shape: Vector3[];
  135651. radius?: number;
  135652. tessellation?: number;
  135653. clip?: number;
  135654. arc?: number;
  135655. closed?: boolean;
  135656. updatable?: boolean;
  135657. sideOrientation?: number;
  135658. frontUVs?: Vector4;
  135659. backUVs?: Vector4;
  135660. cap?: number;
  135661. invertUV?: boolean;
  135662. }, scene?: Nullable<Scene>): Mesh;
  135663. }
  135664. }
  135665. declare module BABYLON {
  135666. /**
  135667. * Class containing static functions to help procedurally build meshes
  135668. */
  135669. export class TiledPlaneBuilder {
  135670. /**
  135671. * Creates a tiled plane mesh
  135672. * * The parameter `pattern` will, depending on value, do nothing or
  135673. * * * flip (reflect about central vertical) alternate tiles across and up
  135674. * * * flip every tile on alternate rows
  135675. * * * rotate (180 degs) alternate tiles across and up
  135676. * * * rotate every tile on alternate rows
  135677. * * * flip and rotate alternate tiles across and up
  135678. * * * flip and rotate every tile on alternate rows
  135679. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135680. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135683. * * 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)
  135684. * * 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)
  135685. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135686. * @param name defines the name of the mesh
  135687. * @param options defines the options used to create the mesh
  135688. * @param scene defines the hosting scene
  135689. * @returns the box mesh
  135690. */
  135691. static CreateTiledPlane(name: string, options: {
  135692. pattern?: number;
  135693. tileSize?: number;
  135694. tileWidth?: number;
  135695. tileHeight?: number;
  135696. size?: number;
  135697. width?: number;
  135698. height?: number;
  135699. alignHorizontal?: number;
  135700. alignVertical?: number;
  135701. sideOrientation?: number;
  135702. frontUVs?: Vector4;
  135703. backUVs?: Vector4;
  135704. updatable?: boolean;
  135705. }, scene?: Nullable<Scene>): Mesh;
  135706. }
  135707. }
  135708. declare module BABYLON {
  135709. /**
  135710. * Class containing static functions to help procedurally build meshes
  135711. */
  135712. export class TubeBuilder {
  135713. /**
  135714. * Creates a tube mesh.
  135715. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135716. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135717. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135718. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135719. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135720. * * 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)
  135721. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135722. * * 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
  135723. * * 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
  135724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135728. * @param name defines the name of the mesh
  135729. * @param options defines the options used to create the mesh
  135730. * @param scene defines the hosting scene
  135731. * @returns the tube mesh
  135732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135733. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135734. */
  135735. static CreateTube(name: string, options: {
  135736. path: Vector3[];
  135737. radius?: number;
  135738. tessellation?: number;
  135739. radiusFunction?: {
  135740. (i: number, distance: number): number;
  135741. };
  135742. cap?: number;
  135743. arc?: number;
  135744. updatable?: boolean;
  135745. sideOrientation?: number;
  135746. frontUVs?: Vector4;
  135747. backUVs?: Vector4;
  135748. instance?: Mesh;
  135749. invertUV?: boolean;
  135750. }, scene?: Nullable<Scene>): Mesh;
  135751. }
  135752. }
  135753. declare module BABYLON {
  135754. /**
  135755. * Class containing static functions to help procedurally build meshes
  135756. */
  135757. export class IcoSphereBuilder {
  135758. /**
  135759. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135760. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135761. * * 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`)
  135762. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135763. * * 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
  135764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135767. * @param name defines the name of the mesh
  135768. * @param options defines the options used to create the mesh
  135769. * @param scene defines the hosting scene
  135770. * @returns the icosahedron mesh
  135771. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135772. */
  135773. static CreateIcoSphere(name: string, options: {
  135774. radius?: number;
  135775. radiusX?: number;
  135776. radiusY?: number;
  135777. radiusZ?: number;
  135778. flat?: boolean;
  135779. subdivisions?: number;
  135780. sideOrientation?: number;
  135781. frontUVs?: Vector4;
  135782. backUVs?: Vector4;
  135783. updatable?: boolean;
  135784. }, scene?: Nullable<Scene>): Mesh;
  135785. }
  135786. }
  135787. declare module BABYLON {
  135788. /**
  135789. * Class containing static functions to help procedurally build meshes
  135790. */
  135791. export class DecalBuilder {
  135792. /**
  135793. * Creates a decal mesh.
  135794. * 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
  135795. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135796. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135797. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135798. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135799. * @param name defines the name of the mesh
  135800. * @param sourceMesh defines the mesh where the decal must be applied
  135801. * @param options defines the options used to create the mesh
  135802. * @param scene defines the hosting scene
  135803. * @returns the decal mesh
  135804. * @see https://doc.babylonjs.com/how_to/decals
  135805. */
  135806. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135807. position?: Vector3;
  135808. normal?: Vector3;
  135809. size?: Vector3;
  135810. angle?: number;
  135811. }): Mesh;
  135812. }
  135813. }
  135814. declare module BABYLON {
  135815. /**
  135816. * Class containing static functions to help procedurally build meshes
  135817. */
  135818. export class MeshBuilder {
  135819. /**
  135820. * Creates a box mesh
  135821. * * The parameter `size` sets the size (float) of each box side (default 1)
  135822. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135823. * * 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)
  135824. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135828. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135829. * @param name defines the name of the mesh
  135830. * @param options defines the options used to create the mesh
  135831. * @param scene defines the hosting scene
  135832. * @returns the box mesh
  135833. */
  135834. static CreateBox(name: string, options: {
  135835. size?: number;
  135836. width?: number;
  135837. height?: number;
  135838. depth?: number;
  135839. faceUV?: Vector4[];
  135840. faceColors?: Color4[];
  135841. sideOrientation?: number;
  135842. frontUVs?: Vector4;
  135843. backUVs?: Vector4;
  135844. wrap?: boolean;
  135845. topBaseAt?: number;
  135846. bottomBaseAt?: number;
  135847. updatable?: boolean;
  135848. }, scene?: Nullable<Scene>): Mesh;
  135849. /**
  135850. * Creates a tiled box mesh
  135851. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135853. * @param name defines the name of the mesh
  135854. * @param options defines the options used to create the mesh
  135855. * @param scene defines the hosting scene
  135856. * @returns the tiled box mesh
  135857. */
  135858. static CreateTiledBox(name: string, options: {
  135859. pattern?: number;
  135860. size?: number;
  135861. width?: number;
  135862. height?: number;
  135863. depth: number;
  135864. tileSize?: number;
  135865. tileWidth?: number;
  135866. tileHeight?: number;
  135867. faceUV?: Vector4[];
  135868. faceColors?: Color4[];
  135869. alignHorizontal?: number;
  135870. alignVertical?: number;
  135871. sideOrientation?: number;
  135872. updatable?: boolean;
  135873. }, scene?: Nullable<Scene>): Mesh;
  135874. /**
  135875. * Creates a sphere mesh
  135876. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135877. * * 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`)
  135878. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135879. * * 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
  135880. * * 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)
  135881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135884. * @param name defines the name of the mesh
  135885. * @param options defines the options used to create the mesh
  135886. * @param scene defines the hosting scene
  135887. * @returns the sphere mesh
  135888. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135889. */
  135890. static CreateSphere(name: string, options: {
  135891. segments?: number;
  135892. diameter?: number;
  135893. diameterX?: number;
  135894. diameterY?: number;
  135895. diameterZ?: number;
  135896. arc?: number;
  135897. slice?: number;
  135898. sideOrientation?: number;
  135899. frontUVs?: Vector4;
  135900. backUVs?: Vector4;
  135901. updatable?: boolean;
  135902. }, scene?: Nullable<Scene>): Mesh;
  135903. /**
  135904. * Creates a plane polygonal mesh. By default, this is a disc
  135905. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135906. * * 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
  135907. * * 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
  135908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135911. * @param name defines the name of the mesh
  135912. * @param options defines the options used to create the mesh
  135913. * @param scene defines the hosting scene
  135914. * @returns the plane polygonal mesh
  135915. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135916. */
  135917. static CreateDisc(name: string, options: {
  135918. radius?: number;
  135919. tessellation?: number;
  135920. arc?: number;
  135921. updatable?: boolean;
  135922. sideOrientation?: number;
  135923. frontUVs?: Vector4;
  135924. backUVs?: Vector4;
  135925. }, scene?: Nullable<Scene>): Mesh;
  135926. /**
  135927. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135928. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135929. * * 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`)
  135930. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135931. * * 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
  135932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135935. * @param name defines the name of the mesh
  135936. * @param options defines the options used to create the mesh
  135937. * @param scene defines the hosting scene
  135938. * @returns the icosahedron mesh
  135939. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135940. */
  135941. static CreateIcoSphere(name: string, options: {
  135942. radius?: number;
  135943. radiusX?: number;
  135944. radiusY?: number;
  135945. radiusZ?: number;
  135946. flat?: boolean;
  135947. subdivisions?: number;
  135948. sideOrientation?: number;
  135949. frontUVs?: Vector4;
  135950. backUVs?: Vector4;
  135951. updatable?: boolean;
  135952. }, scene?: Nullable<Scene>): Mesh;
  135953. /**
  135954. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135955. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135956. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135957. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135958. * * 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
  135959. * * 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
  135960. * * 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
  135961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135964. * * 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
  135965. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135966. * * 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
  135967. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135969. * @param name defines the name of the mesh
  135970. * @param options defines the options used to create the mesh
  135971. * @param scene defines the hosting scene
  135972. * @returns the ribbon mesh
  135973. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135975. */
  135976. static CreateRibbon(name: string, options: {
  135977. pathArray: Vector3[][];
  135978. closeArray?: boolean;
  135979. closePath?: boolean;
  135980. offset?: number;
  135981. updatable?: boolean;
  135982. sideOrientation?: number;
  135983. frontUVs?: Vector4;
  135984. backUVs?: Vector4;
  135985. instance?: Mesh;
  135986. invertUV?: boolean;
  135987. uvs?: Vector2[];
  135988. colors?: Color4[];
  135989. }, scene?: Nullable<Scene>): Mesh;
  135990. /**
  135991. * Creates a cylinder or a cone mesh
  135992. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135993. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135994. * * 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.
  135995. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135996. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135997. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135998. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135999. * * 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).
  136000. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  136001. * * 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).
  136002. * * 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
  136003. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  136004. * * 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
  136005. * * 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.
  136006. * * If `enclose` is false, a ring surface is one element.
  136007. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  136008. * * 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
  136009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136012. * @param name defines the name of the mesh
  136013. * @param options defines the options used to create the mesh
  136014. * @param scene defines the hosting scene
  136015. * @returns the cylinder mesh
  136016. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  136017. */
  136018. static CreateCylinder(name: string, options: {
  136019. height?: number;
  136020. diameterTop?: number;
  136021. diameterBottom?: number;
  136022. diameter?: number;
  136023. tessellation?: number;
  136024. subdivisions?: number;
  136025. arc?: number;
  136026. faceColors?: Color4[];
  136027. faceUV?: Vector4[];
  136028. updatable?: boolean;
  136029. hasRings?: boolean;
  136030. enclose?: boolean;
  136031. cap?: number;
  136032. sideOrientation?: number;
  136033. frontUVs?: Vector4;
  136034. backUVs?: Vector4;
  136035. }, scene?: Nullable<Scene>): Mesh;
  136036. /**
  136037. * Creates a torus mesh
  136038. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136039. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136040. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136044. * @param name defines the name of the mesh
  136045. * @param options defines the options used to create the mesh
  136046. * @param scene defines the hosting scene
  136047. * @returns the torus mesh
  136048. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136049. */
  136050. static CreateTorus(name: string, options: {
  136051. diameter?: number;
  136052. thickness?: number;
  136053. tessellation?: number;
  136054. updatable?: boolean;
  136055. sideOrientation?: number;
  136056. frontUVs?: Vector4;
  136057. backUVs?: Vector4;
  136058. }, scene?: Nullable<Scene>): Mesh;
  136059. /**
  136060. * Creates a torus knot mesh
  136061. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136062. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136063. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136064. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136068. * @param name defines the name of the mesh
  136069. * @param options defines the options used to create the mesh
  136070. * @param scene defines the hosting scene
  136071. * @returns the torus knot mesh
  136072. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136073. */
  136074. static CreateTorusKnot(name: string, options: {
  136075. radius?: number;
  136076. tube?: number;
  136077. radialSegments?: number;
  136078. tubularSegments?: number;
  136079. p?: number;
  136080. q?: number;
  136081. updatable?: boolean;
  136082. sideOrientation?: number;
  136083. frontUVs?: Vector4;
  136084. backUVs?: Vector4;
  136085. }, scene?: Nullable<Scene>): Mesh;
  136086. /**
  136087. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136088. * * 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
  136089. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136090. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136091. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136092. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136093. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136094. * * 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
  136095. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136098. * @param name defines the name of the new line system
  136099. * @param options defines the options used to create the line system
  136100. * @param scene defines the hosting scene
  136101. * @returns a new line system mesh
  136102. */
  136103. static CreateLineSystem(name: string, options: {
  136104. lines: Vector3[][];
  136105. updatable?: boolean;
  136106. instance?: Nullable<LinesMesh>;
  136107. colors?: Nullable<Color4[][]>;
  136108. useVertexAlpha?: boolean;
  136109. }, scene: Nullable<Scene>): LinesMesh;
  136110. /**
  136111. * Creates a line mesh
  136112. * 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
  136113. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136114. * * The parameter `points` is an array successive Vector3
  136115. * * 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
  136116. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136117. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136118. * * When updating an instance, remember that only point positions can change, not the number of points
  136119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136121. * @param name defines the name of the new line system
  136122. * @param options defines the options used to create the line system
  136123. * @param scene defines the hosting scene
  136124. * @returns a new line mesh
  136125. */
  136126. static CreateLines(name: string, options: {
  136127. points: Vector3[];
  136128. updatable?: boolean;
  136129. instance?: Nullable<LinesMesh>;
  136130. colors?: Color4[];
  136131. useVertexAlpha?: boolean;
  136132. }, scene?: Nullable<Scene>): LinesMesh;
  136133. /**
  136134. * Creates a dashed line mesh
  136135. * * 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
  136136. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136137. * * The parameter `points` is an array successive Vector3
  136138. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136139. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136140. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136141. * * 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
  136142. * * When updating an instance, remember that only point positions can change, not the number of points
  136143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136144. * @param name defines the name of the mesh
  136145. * @param options defines the options used to create the mesh
  136146. * @param scene defines the hosting scene
  136147. * @returns the dashed line mesh
  136148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136149. */
  136150. static CreateDashedLines(name: string, options: {
  136151. points: Vector3[];
  136152. dashSize?: number;
  136153. gapSize?: number;
  136154. dashNb?: number;
  136155. updatable?: boolean;
  136156. instance?: LinesMesh;
  136157. }, scene?: Nullable<Scene>): LinesMesh;
  136158. /**
  136159. * 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.
  136160. * * 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.
  136161. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136162. * * 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.
  136163. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136164. * * 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
  136165. * * 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
  136166. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136171. * @param name defines the name of the mesh
  136172. * @param options defines the options used to create the mesh
  136173. * @param scene defines the hosting scene
  136174. * @returns the extruded shape mesh
  136175. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136177. */
  136178. static ExtrudeShape(name: string, options: {
  136179. shape: Vector3[];
  136180. path: Vector3[];
  136181. scale?: number;
  136182. rotation?: number;
  136183. cap?: number;
  136184. updatable?: boolean;
  136185. sideOrientation?: number;
  136186. frontUVs?: Vector4;
  136187. backUVs?: Vector4;
  136188. instance?: Mesh;
  136189. invertUV?: boolean;
  136190. }, scene?: Nullable<Scene>): Mesh;
  136191. /**
  136192. * Creates an custom extruded shape mesh.
  136193. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136194. * * 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.
  136195. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136196. * * 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
  136197. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136198. * * 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
  136199. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136200. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136201. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136202. * * 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
  136203. * * 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
  136204. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136209. * @param name defines the name of the mesh
  136210. * @param options defines the options used to create the mesh
  136211. * @param scene defines the hosting scene
  136212. * @returns the custom extruded shape mesh
  136213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136214. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136216. */
  136217. static ExtrudeShapeCustom(name: string, options: {
  136218. shape: Vector3[];
  136219. path: Vector3[];
  136220. scaleFunction?: any;
  136221. rotationFunction?: any;
  136222. ribbonCloseArray?: boolean;
  136223. ribbonClosePath?: boolean;
  136224. cap?: number;
  136225. updatable?: boolean;
  136226. sideOrientation?: number;
  136227. frontUVs?: Vector4;
  136228. backUVs?: Vector4;
  136229. instance?: Mesh;
  136230. invertUV?: boolean;
  136231. }, scene?: Nullable<Scene>): Mesh;
  136232. /**
  136233. * Creates lathe mesh.
  136234. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136235. * * 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
  136236. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136237. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136238. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136239. * * 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
  136240. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136241. * * 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
  136242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136246. * @param name defines the name of the mesh
  136247. * @param options defines the options used to create the mesh
  136248. * @param scene defines the hosting scene
  136249. * @returns the lathe mesh
  136250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136251. */
  136252. static CreateLathe(name: string, options: {
  136253. shape: Vector3[];
  136254. radius?: number;
  136255. tessellation?: number;
  136256. clip?: number;
  136257. arc?: number;
  136258. closed?: boolean;
  136259. updatable?: boolean;
  136260. sideOrientation?: number;
  136261. frontUVs?: Vector4;
  136262. backUVs?: Vector4;
  136263. cap?: number;
  136264. invertUV?: boolean;
  136265. }, scene?: Nullable<Scene>): Mesh;
  136266. /**
  136267. * Creates a tiled plane mesh
  136268. * * You can set a limited pattern arrangement with the tiles
  136269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136272. * @param name defines the name of the mesh
  136273. * @param options defines the options used to create the mesh
  136274. * @param scene defines the hosting scene
  136275. * @returns the plane mesh
  136276. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136277. */
  136278. static CreateTiledPlane(name: string, options: {
  136279. pattern?: number;
  136280. tileSize?: number;
  136281. tileWidth?: number;
  136282. tileHeight?: number;
  136283. size?: number;
  136284. width?: number;
  136285. height?: number;
  136286. alignHorizontal?: number;
  136287. alignVertical?: number;
  136288. sideOrientation?: number;
  136289. frontUVs?: Vector4;
  136290. backUVs?: Vector4;
  136291. updatable?: boolean;
  136292. }, scene?: Nullable<Scene>): Mesh;
  136293. /**
  136294. * Creates a plane mesh
  136295. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136296. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136297. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  136305. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136306. */
  136307. static CreatePlane(name: string, options: {
  136308. size?: number;
  136309. width?: number;
  136310. height?: number;
  136311. sideOrientation?: number;
  136312. frontUVs?: Vector4;
  136313. backUVs?: Vector4;
  136314. updatable?: boolean;
  136315. sourcePlane?: Plane;
  136316. }, scene?: Nullable<Scene>): Mesh;
  136317. /**
  136318. * Creates a ground mesh
  136319. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136320. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  136326. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136327. */
  136328. static CreateGround(name: string, options: {
  136329. width?: number;
  136330. height?: number;
  136331. subdivisions?: number;
  136332. subdivisionsX?: number;
  136333. subdivisionsY?: number;
  136334. updatable?: boolean;
  136335. }, scene?: Nullable<Scene>): Mesh;
  136336. /**
  136337. * Creates a tiled ground mesh
  136338. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136339. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136340. * * 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
  136341. * * 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
  136342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136343. * @param name defines the name of the mesh
  136344. * @param options defines the options used to create the mesh
  136345. * @param scene defines the hosting scene
  136346. * @returns the tiled ground mesh
  136347. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136348. */
  136349. static CreateTiledGround(name: string, options: {
  136350. xmin: number;
  136351. zmin: number;
  136352. xmax: number;
  136353. zmax: number;
  136354. subdivisions?: {
  136355. w: number;
  136356. h: number;
  136357. };
  136358. precision?: {
  136359. w: number;
  136360. h: number;
  136361. };
  136362. updatable?: boolean;
  136363. }, scene?: Nullable<Scene>): Mesh;
  136364. /**
  136365. * Creates a ground mesh from a height map
  136366. * * The parameter `url` sets the URL of the height map image resource.
  136367. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136368. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136369. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136370. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136371. * * 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.
  136372. * * 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).
  136373. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136375. * @param name defines the name of the mesh
  136376. * @param url defines the url to the height map
  136377. * @param options defines the options used to create the mesh
  136378. * @param scene defines the hosting scene
  136379. * @returns the ground mesh
  136380. * @see https://doc.babylonjs.com/babylon101/height_map
  136381. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136382. */
  136383. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136384. width?: number;
  136385. height?: number;
  136386. subdivisions?: number;
  136387. minHeight?: number;
  136388. maxHeight?: number;
  136389. colorFilter?: Color3;
  136390. alphaFilter?: number;
  136391. updatable?: boolean;
  136392. onReady?: (mesh: GroundMesh) => void;
  136393. }, scene?: Nullable<Scene>): GroundMesh;
  136394. /**
  136395. * Creates a polygon mesh
  136396. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136397. * * 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
  136398. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136401. * * Remember you can only change the shape positions, not their number when updating a polygon
  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 CreatePolygon(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 an extruded polygon mesh, with depth in the Y direction.
  136421. * * 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)
  136422. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136423. * @param name defines the name of the mesh
  136424. * @param options defines the options used to create the mesh
  136425. * @param scene defines the hosting scene
  136426. * @param earcutInjection can be used to inject your own earcut reference
  136427. * @returns the polygon mesh
  136428. */
  136429. static ExtrudePolygon(name: string, options: {
  136430. shape: Vector3[];
  136431. holes?: Vector3[][];
  136432. depth?: number;
  136433. faceUV?: Vector4[];
  136434. faceColors?: Color4[];
  136435. updatable?: boolean;
  136436. sideOrientation?: number;
  136437. frontUVs?: Vector4;
  136438. backUVs?: Vector4;
  136439. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136440. /**
  136441. * Creates a tube mesh.
  136442. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136443. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136444. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136445. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136446. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136447. * * 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)
  136448. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136449. * * 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
  136450. * * 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
  136451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136455. * @param name defines the name of the mesh
  136456. * @param options defines the options used to create the mesh
  136457. * @param scene defines the hosting scene
  136458. * @returns the tube mesh
  136459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136460. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136461. */
  136462. static CreateTube(name: string, options: {
  136463. path: Vector3[];
  136464. radius?: number;
  136465. tessellation?: number;
  136466. radiusFunction?: {
  136467. (i: number, distance: number): number;
  136468. };
  136469. cap?: number;
  136470. arc?: number;
  136471. updatable?: boolean;
  136472. sideOrientation?: number;
  136473. frontUVs?: Vector4;
  136474. backUVs?: Vector4;
  136475. instance?: Mesh;
  136476. invertUV?: boolean;
  136477. }, scene?: Nullable<Scene>): Mesh;
  136478. /**
  136479. * Creates a polyhedron mesh
  136480. * * 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
  136481. * * The parameter `size` (positive float, default 1) sets the polygon size
  136482. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136483. * * 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`
  136484. * * 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
  136485. * * 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)`)
  136486. * * 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
  136487. * * 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
  136488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136491. * @param name defines the name of the mesh
  136492. * @param options defines the options used to create the mesh
  136493. * @param scene defines the hosting scene
  136494. * @returns the polyhedron mesh
  136495. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136496. */
  136497. static CreatePolyhedron(name: string, options: {
  136498. type?: number;
  136499. size?: number;
  136500. sizeX?: number;
  136501. sizeY?: number;
  136502. sizeZ?: number;
  136503. custom?: any;
  136504. faceUV?: Vector4[];
  136505. faceColors?: Color4[];
  136506. flat?: boolean;
  136507. updatable?: boolean;
  136508. sideOrientation?: number;
  136509. frontUVs?: Vector4;
  136510. backUVs?: Vector4;
  136511. }, scene?: Nullable<Scene>): Mesh;
  136512. /**
  136513. * Creates a decal mesh.
  136514. * 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
  136515. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136516. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136517. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136518. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136519. * @param name defines the name of the mesh
  136520. * @param sourceMesh defines the mesh where the decal must be applied
  136521. * @param options defines the options used to create the mesh
  136522. * @param scene defines the hosting scene
  136523. * @returns the decal mesh
  136524. * @see https://doc.babylonjs.com/how_to/decals
  136525. */
  136526. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136527. position?: Vector3;
  136528. normal?: Vector3;
  136529. size?: Vector3;
  136530. angle?: number;
  136531. }): Mesh;
  136532. }
  136533. }
  136534. declare module BABYLON {
  136535. /**
  136536. * A simplifier interface for future simplification implementations
  136537. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136538. */
  136539. export interface ISimplifier {
  136540. /**
  136541. * Simplification of a given mesh according to the given settings.
  136542. * Since this requires computation, it is assumed that the function runs async.
  136543. * @param settings The settings of the simplification, including quality and distance
  136544. * @param successCallback A callback that will be called after the mesh was simplified.
  136545. * @param errorCallback in case of an error, this callback will be called. optional.
  136546. */
  136547. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136548. }
  136549. /**
  136550. * Expected simplification settings.
  136551. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136552. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136553. */
  136554. export interface ISimplificationSettings {
  136555. /**
  136556. * Gets or sets the expected quality
  136557. */
  136558. quality: number;
  136559. /**
  136560. * Gets or sets the distance when this optimized version should be used
  136561. */
  136562. distance: number;
  136563. /**
  136564. * Gets an already optimized mesh
  136565. */
  136566. optimizeMesh?: boolean;
  136567. }
  136568. /**
  136569. * Class used to specify simplification options
  136570. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136571. */
  136572. export class SimplificationSettings implements ISimplificationSettings {
  136573. /** expected quality */
  136574. quality: number;
  136575. /** distance when this optimized version should be used */
  136576. distance: number;
  136577. /** already optimized mesh */
  136578. optimizeMesh?: boolean | undefined;
  136579. /**
  136580. * Creates a SimplificationSettings
  136581. * @param quality expected quality
  136582. * @param distance distance when this optimized version should be used
  136583. * @param optimizeMesh already optimized mesh
  136584. */
  136585. constructor(
  136586. /** expected quality */
  136587. quality: number,
  136588. /** distance when this optimized version should be used */
  136589. distance: number,
  136590. /** already optimized mesh */
  136591. optimizeMesh?: boolean | undefined);
  136592. }
  136593. /**
  136594. * Interface used to define a simplification task
  136595. */
  136596. export interface ISimplificationTask {
  136597. /**
  136598. * Array of settings
  136599. */
  136600. settings: Array<ISimplificationSettings>;
  136601. /**
  136602. * Simplification type
  136603. */
  136604. simplificationType: SimplificationType;
  136605. /**
  136606. * Mesh to simplify
  136607. */
  136608. mesh: Mesh;
  136609. /**
  136610. * Callback called on success
  136611. */
  136612. successCallback?: () => void;
  136613. /**
  136614. * Defines if parallel processing can be used
  136615. */
  136616. parallelProcessing: boolean;
  136617. }
  136618. /**
  136619. * Queue used to order the simplification tasks
  136620. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136621. */
  136622. export class SimplificationQueue {
  136623. private _simplificationArray;
  136624. /**
  136625. * Gets a boolean indicating that the process is still running
  136626. */
  136627. running: boolean;
  136628. /**
  136629. * Creates a new queue
  136630. */
  136631. constructor();
  136632. /**
  136633. * Adds a new simplification task
  136634. * @param task defines a task to add
  136635. */
  136636. addTask(task: ISimplificationTask): void;
  136637. /**
  136638. * Execute next task
  136639. */
  136640. executeNext(): void;
  136641. /**
  136642. * Execute a simplification task
  136643. * @param task defines the task to run
  136644. */
  136645. runSimplification(task: ISimplificationTask): void;
  136646. private getSimplifier;
  136647. }
  136648. /**
  136649. * The implemented types of simplification
  136650. * At the moment only Quadratic Error Decimation is implemented
  136651. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136652. */
  136653. export enum SimplificationType {
  136654. /** Quadratic error decimation */
  136655. QUADRATIC = 0
  136656. }
  136657. /**
  136658. * An implementation of the Quadratic Error simplification algorithm.
  136659. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136660. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136661. * @author RaananW
  136662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136663. */
  136664. export class QuadraticErrorSimplification implements ISimplifier {
  136665. private _mesh;
  136666. private triangles;
  136667. private vertices;
  136668. private references;
  136669. private _reconstructedMesh;
  136670. /** Gets or sets the number pf sync interations */
  136671. syncIterations: number;
  136672. /** Gets or sets the aggressiveness of the simplifier */
  136673. aggressiveness: number;
  136674. /** Gets or sets the number of allowed iterations for decimation */
  136675. decimationIterations: number;
  136676. /** Gets or sets the espilon to use for bounding box computation */
  136677. boundingBoxEpsilon: number;
  136678. /**
  136679. * Creates a new QuadraticErrorSimplification
  136680. * @param _mesh defines the target mesh
  136681. */
  136682. constructor(_mesh: Mesh);
  136683. /**
  136684. * Simplification of a given mesh according to the given settings.
  136685. * Since this requires computation, it is assumed that the function runs async.
  136686. * @param settings The settings of the simplification, including quality and distance
  136687. * @param successCallback A callback that will be called after the mesh was simplified.
  136688. */
  136689. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136690. private runDecimation;
  136691. private initWithMesh;
  136692. private init;
  136693. private reconstructMesh;
  136694. private initDecimatedMesh;
  136695. private isFlipped;
  136696. private updateTriangles;
  136697. private identifyBorder;
  136698. private updateMesh;
  136699. private vertexError;
  136700. private calculateError;
  136701. }
  136702. }
  136703. declare module BABYLON {
  136704. interface Scene {
  136705. /** @hidden (Backing field) */
  136706. _simplificationQueue: SimplificationQueue;
  136707. /**
  136708. * Gets or sets the simplification queue attached to the scene
  136709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136710. */
  136711. simplificationQueue: SimplificationQueue;
  136712. }
  136713. interface Mesh {
  136714. /**
  136715. * Simplify the mesh according to the given array of settings.
  136716. * Function will return immediately and will simplify async
  136717. * @param settings a collection of simplification settings
  136718. * @param parallelProcessing should all levels calculate parallel or one after the other
  136719. * @param simplificationType the type of simplification to run
  136720. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136721. * @returns the current mesh
  136722. */
  136723. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136724. }
  136725. /**
  136726. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136727. * created in a scene
  136728. */
  136729. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136730. /**
  136731. * The component name helpfull to identify the component in the list of scene components.
  136732. */
  136733. readonly name: string;
  136734. /**
  136735. * The scene the component belongs to.
  136736. */
  136737. scene: Scene;
  136738. /**
  136739. * Creates a new instance of the component for the given scene
  136740. * @param scene Defines the scene to register the component in
  136741. */
  136742. constructor(scene: Scene);
  136743. /**
  136744. * Registers the component in a given scene
  136745. */
  136746. register(): void;
  136747. /**
  136748. * Rebuilds the elements related to this component in case of
  136749. * context lost for instance.
  136750. */
  136751. rebuild(): void;
  136752. /**
  136753. * Disposes the component and the associated ressources
  136754. */
  136755. dispose(): void;
  136756. private _beforeCameraUpdate;
  136757. }
  136758. }
  136759. declare module BABYLON {
  136760. /**
  136761. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136762. */
  136763. export interface INavigationEnginePlugin {
  136764. /**
  136765. * plugin name
  136766. */
  136767. name: string;
  136768. /**
  136769. * Creates a navigation mesh
  136770. * @param meshes array of all the geometry used to compute the navigatio mesh
  136771. * @param parameters bunch of parameters used to filter geometry
  136772. */
  136773. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136774. /**
  136775. * Create a navigation mesh debug mesh
  136776. * @param scene is where the mesh will be added
  136777. * @returns debug display mesh
  136778. */
  136779. createDebugNavMesh(scene: Scene): Mesh;
  136780. /**
  136781. * Get a navigation mesh constrained position, closest to the parameter position
  136782. * @param position world position
  136783. * @returns the closest point to position constrained by the navigation mesh
  136784. */
  136785. getClosestPoint(position: Vector3): Vector3;
  136786. /**
  136787. * Get a navigation mesh constrained position, closest to the parameter position
  136788. * @param position world position
  136789. * @param result output the closest point to position constrained by the navigation mesh
  136790. */
  136791. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136792. /**
  136793. * Get a navigation mesh constrained position, within a particular radius
  136794. * @param position world position
  136795. * @param maxRadius the maximum distance to the constrained world position
  136796. * @returns the closest point to position constrained by the navigation mesh
  136797. */
  136798. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136799. /**
  136800. * Get a navigation mesh constrained position, within a particular radius
  136801. * @param position world position
  136802. * @param maxRadius the maximum distance to the constrained world position
  136803. * @param result output the closest point to position constrained by the navigation mesh
  136804. */
  136805. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136806. /**
  136807. * Compute the final position from a segment made of destination-position
  136808. * @param position world position
  136809. * @param destination world position
  136810. * @returns the resulting point along the navmesh
  136811. */
  136812. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136813. /**
  136814. * Compute the final position from a segment made of destination-position
  136815. * @param position world position
  136816. * @param destination world position
  136817. * @param result output the resulting point along the navmesh
  136818. */
  136819. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136820. /**
  136821. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136822. * @param start world position
  136823. * @param end world position
  136824. * @returns array containing world position composing the path
  136825. */
  136826. computePath(start: Vector3, end: Vector3): Vector3[];
  136827. /**
  136828. * If this plugin is supported
  136829. * @returns true if plugin is supported
  136830. */
  136831. isSupported(): boolean;
  136832. /**
  136833. * Create a new Crowd so you can add agents
  136834. * @param maxAgents the maximum agent count in the crowd
  136835. * @param maxAgentRadius the maximum radius an agent can have
  136836. * @param scene to attach the crowd to
  136837. * @returns the crowd you can add agents to
  136838. */
  136839. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136840. /**
  136841. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136842. * The queries will try to find a solution within those bounds
  136843. * default is (1,1,1)
  136844. * @param extent x,y,z value that define the extent around the queries point of reference
  136845. */
  136846. setDefaultQueryExtent(extent: Vector3): void;
  136847. /**
  136848. * Get the Bounding box extent specified by setDefaultQueryExtent
  136849. * @returns the box extent values
  136850. */
  136851. getDefaultQueryExtent(): Vector3;
  136852. /**
  136853. * build the navmesh from a previously saved state using getNavmeshData
  136854. * @param data the Uint8Array returned by getNavmeshData
  136855. */
  136856. buildFromNavmeshData(data: Uint8Array): void;
  136857. /**
  136858. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136859. * @returns data the Uint8Array that can be saved and reused
  136860. */
  136861. getNavmeshData(): Uint8Array;
  136862. /**
  136863. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136864. * @param result output the box extent values
  136865. */
  136866. getDefaultQueryExtentToRef(result: Vector3): void;
  136867. /**
  136868. * Release all resources
  136869. */
  136870. dispose(): void;
  136871. }
  136872. /**
  136873. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136874. */
  136875. export interface ICrowd {
  136876. /**
  136877. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136878. * You can attach anything to that node. The node position is updated in the scene update tick.
  136879. * @param pos world position that will be constrained by the navigation mesh
  136880. * @param parameters agent parameters
  136881. * @param transform hooked to the agent that will be update by the scene
  136882. * @returns agent index
  136883. */
  136884. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136885. /**
  136886. * Returns the agent position in world space
  136887. * @param index agent index returned by addAgent
  136888. * @returns world space position
  136889. */
  136890. getAgentPosition(index: number): Vector3;
  136891. /**
  136892. * Gets the agent position result in world space
  136893. * @param index agent index returned by addAgent
  136894. * @param result output world space position
  136895. */
  136896. getAgentPositionToRef(index: number, result: Vector3): void;
  136897. /**
  136898. * Gets the agent velocity in world space
  136899. * @param index agent index returned by addAgent
  136900. * @returns world space velocity
  136901. */
  136902. getAgentVelocity(index: number): Vector3;
  136903. /**
  136904. * Gets the agent velocity result in world space
  136905. * @param index agent index returned by addAgent
  136906. * @param result output world space velocity
  136907. */
  136908. getAgentVelocityToRef(index: number, result: Vector3): void;
  136909. /**
  136910. * remove a particular agent previously created
  136911. * @param index agent index returned by addAgent
  136912. */
  136913. removeAgent(index: number): void;
  136914. /**
  136915. * get the list of all agents attached to this crowd
  136916. * @returns list of agent indices
  136917. */
  136918. getAgents(): number[];
  136919. /**
  136920. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136921. * @param deltaTime in seconds
  136922. */
  136923. update(deltaTime: number): void;
  136924. /**
  136925. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136926. * @param index agent index returned by addAgent
  136927. * @param destination targeted world position
  136928. */
  136929. agentGoto(index: number, destination: Vector3): void;
  136930. /**
  136931. * Teleport the agent to a new position
  136932. * @param index agent index returned by addAgent
  136933. * @param destination targeted world position
  136934. */
  136935. agentTeleport(index: number, destination: Vector3): void;
  136936. /**
  136937. * Update agent parameters
  136938. * @param index agent index returned by addAgent
  136939. * @param parameters agent parameters
  136940. */
  136941. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136942. /**
  136943. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136944. * The queries will try to find a solution within those bounds
  136945. * default is (1,1,1)
  136946. * @param extent x,y,z value that define the extent around the queries point of reference
  136947. */
  136948. setDefaultQueryExtent(extent: Vector3): void;
  136949. /**
  136950. * Get the Bounding box extent specified by setDefaultQueryExtent
  136951. * @returns the box extent values
  136952. */
  136953. getDefaultQueryExtent(): Vector3;
  136954. /**
  136955. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136956. * @param result output the box extent values
  136957. */
  136958. getDefaultQueryExtentToRef(result: Vector3): void;
  136959. /**
  136960. * Release all resources
  136961. */
  136962. dispose(): void;
  136963. }
  136964. /**
  136965. * Configures an agent
  136966. */
  136967. export interface IAgentParameters {
  136968. /**
  136969. * Agent radius. [Limit: >= 0]
  136970. */
  136971. radius: number;
  136972. /**
  136973. * Agent height. [Limit: > 0]
  136974. */
  136975. height: number;
  136976. /**
  136977. * Maximum allowed acceleration. [Limit: >= 0]
  136978. */
  136979. maxAcceleration: number;
  136980. /**
  136981. * Maximum allowed speed. [Limit: >= 0]
  136982. */
  136983. maxSpeed: number;
  136984. /**
  136985. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136986. */
  136987. collisionQueryRange: number;
  136988. /**
  136989. * The path visibility optimization range. [Limit: > 0]
  136990. */
  136991. pathOptimizationRange: number;
  136992. /**
  136993. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136994. */
  136995. separationWeight: number;
  136996. }
  136997. /**
  136998. * Configures the navigation mesh creation
  136999. */
  137000. export interface INavMeshParameters {
  137001. /**
  137002. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  137003. */
  137004. cs: number;
  137005. /**
  137006. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  137007. */
  137008. ch: number;
  137009. /**
  137010. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  137011. */
  137012. walkableSlopeAngle: number;
  137013. /**
  137014. * Minimum floor to 'ceiling' height that will still allow the floor area to
  137015. * be considered walkable. [Limit: >= 3] [Units: vx]
  137016. */
  137017. walkableHeight: number;
  137018. /**
  137019. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  137020. */
  137021. walkableClimb: number;
  137022. /**
  137023. * The distance to erode/shrink the walkable area of the heightfield away from
  137024. * obstructions. [Limit: >=0] [Units: vx]
  137025. */
  137026. walkableRadius: number;
  137027. /**
  137028. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  137029. */
  137030. maxEdgeLen: number;
  137031. /**
  137032. * The maximum distance a simplfied contour's border edges should deviate
  137033. * the original raw contour. [Limit: >=0] [Units: vx]
  137034. */
  137035. maxSimplificationError: number;
  137036. /**
  137037. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137038. */
  137039. minRegionArea: number;
  137040. /**
  137041. * Any regions with a span count smaller than this value will, if possible,
  137042. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137043. */
  137044. mergeRegionArea: number;
  137045. /**
  137046. * The maximum number of vertices allowed for polygons generated during the
  137047. * contour to polygon conversion process. [Limit: >= 3]
  137048. */
  137049. maxVertsPerPoly: number;
  137050. /**
  137051. * Sets the sampling distance to use when generating the detail mesh.
  137052. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137053. */
  137054. detailSampleDist: number;
  137055. /**
  137056. * The maximum distance the detail mesh surface should deviate from heightfield
  137057. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137058. */
  137059. detailSampleMaxError: number;
  137060. }
  137061. }
  137062. declare module BABYLON {
  137063. /**
  137064. * RecastJS navigation plugin
  137065. */
  137066. export class RecastJSPlugin implements INavigationEnginePlugin {
  137067. /**
  137068. * Reference to the Recast library
  137069. */
  137070. bjsRECAST: any;
  137071. /**
  137072. * plugin name
  137073. */
  137074. name: string;
  137075. /**
  137076. * the first navmesh created. We might extend this to support multiple navmeshes
  137077. */
  137078. navMesh: any;
  137079. /**
  137080. * Initializes the recastJS plugin
  137081. * @param recastInjection can be used to inject your own recast reference
  137082. */
  137083. constructor(recastInjection?: any);
  137084. /**
  137085. * Creates a navigation mesh
  137086. * @param meshes array of all the geometry used to compute the navigatio mesh
  137087. * @param parameters bunch of parameters used to filter geometry
  137088. */
  137089. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137090. /**
  137091. * Create a navigation mesh debug mesh
  137092. * @param scene is where the mesh will be added
  137093. * @returns debug display mesh
  137094. */
  137095. createDebugNavMesh(scene: Scene): Mesh;
  137096. /**
  137097. * Get a navigation mesh constrained position, closest to the parameter position
  137098. * @param position world position
  137099. * @returns the closest point to position constrained by the navigation mesh
  137100. */
  137101. getClosestPoint(position: Vector3): Vector3;
  137102. /**
  137103. * Get a navigation mesh constrained position, closest to the parameter position
  137104. * @param position world position
  137105. * @param result output the closest point to position constrained by the navigation mesh
  137106. */
  137107. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137108. /**
  137109. * Get a navigation mesh constrained position, within a particular radius
  137110. * @param position world position
  137111. * @param maxRadius the maximum distance to the constrained world position
  137112. * @returns the closest point to position constrained by the navigation mesh
  137113. */
  137114. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137115. /**
  137116. * Get a navigation mesh constrained position, within a particular radius
  137117. * @param position world position
  137118. * @param maxRadius the maximum distance to the constrained world position
  137119. * @param result output the closest point to position constrained by the navigation mesh
  137120. */
  137121. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137122. /**
  137123. * Compute the final position from a segment made of destination-position
  137124. * @param position world position
  137125. * @param destination world position
  137126. * @returns the resulting point along the navmesh
  137127. */
  137128. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137129. /**
  137130. * Compute the final position from a segment made of destination-position
  137131. * @param position world position
  137132. * @param destination world position
  137133. * @param result output the resulting point along the navmesh
  137134. */
  137135. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137136. /**
  137137. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137138. * @param start world position
  137139. * @param end world position
  137140. * @returns array containing world position composing the path
  137141. */
  137142. computePath(start: Vector3, end: Vector3): Vector3[];
  137143. /**
  137144. * Create a new Crowd so you can add agents
  137145. * @param maxAgents the maximum agent count in the crowd
  137146. * @param maxAgentRadius the maximum radius an agent can have
  137147. * @param scene to attach the crowd to
  137148. * @returns the crowd you can add agents to
  137149. */
  137150. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137151. /**
  137152. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137153. * The queries will try to find a solution within those bounds
  137154. * default is (1,1,1)
  137155. * @param extent x,y,z value that define the extent around the queries point of reference
  137156. */
  137157. setDefaultQueryExtent(extent: Vector3): void;
  137158. /**
  137159. * Get the Bounding box extent specified by setDefaultQueryExtent
  137160. * @returns the box extent values
  137161. */
  137162. getDefaultQueryExtent(): Vector3;
  137163. /**
  137164. * build the navmesh from a previously saved state using getNavmeshData
  137165. * @param data the Uint8Array returned by getNavmeshData
  137166. */
  137167. buildFromNavmeshData(data: Uint8Array): void;
  137168. /**
  137169. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137170. * @returns data the Uint8Array that can be saved and reused
  137171. */
  137172. getNavmeshData(): Uint8Array;
  137173. /**
  137174. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137175. * @param result output the box extent values
  137176. */
  137177. getDefaultQueryExtentToRef(result: Vector3): void;
  137178. /**
  137179. * Disposes
  137180. */
  137181. dispose(): void;
  137182. /**
  137183. * If this plugin is supported
  137184. * @returns true if plugin is supported
  137185. */
  137186. isSupported(): boolean;
  137187. }
  137188. /**
  137189. * Recast detour crowd implementation
  137190. */
  137191. export class RecastJSCrowd implements ICrowd {
  137192. /**
  137193. * Recast/detour plugin
  137194. */
  137195. bjsRECASTPlugin: RecastJSPlugin;
  137196. /**
  137197. * Link to the detour crowd
  137198. */
  137199. recastCrowd: any;
  137200. /**
  137201. * One transform per agent
  137202. */
  137203. transforms: TransformNode[];
  137204. /**
  137205. * All agents created
  137206. */
  137207. agents: number[];
  137208. /**
  137209. * Link to the scene is kept to unregister the crowd from the scene
  137210. */
  137211. private _scene;
  137212. /**
  137213. * Observer for crowd updates
  137214. */
  137215. private _onBeforeAnimationsObserver;
  137216. /**
  137217. * Constructor
  137218. * @param plugin recastJS plugin
  137219. * @param maxAgents the maximum agent count in the crowd
  137220. * @param maxAgentRadius the maximum radius an agent can have
  137221. * @param scene to attach the crowd to
  137222. * @returns the crowd you can add agents to
  137223. */
  137224. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137225. /**
  137226. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137227. * You can attach anything to that node. The node position is updated in the scene update tick.
  137228. * @param pos world position that will be constrained by the navigation mesh
  137229. * @param parameters agent parameters
  137230. * @param transform hooked to the agent that will be update by the scene
  137231. * @returns agent index
  137232. */
  137233. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137234. /**
  137235. * Returns the agent position in world space
  137236. * @param index agent index returned by addAgent
  137237. * @returns world space position
  137238. */
  137239. getAgentPosition(index: number): Vector3;
  137240. /**
  137241. * Returns the agent position result in world space
  137242. * @param index agent index returned by addAgent
  137243. * @param result output world space position
  137244. */
  137245. getAgentPositionToRef(index: number, result: Vector3): void;
  137246. /**
  137247. * Returns the agent velocity in world space
  137248. * @param index agent index returned by addAgent
  137249. * @returns world space velocity
  137250. */
  137251. getAgentVelocity(index: number): Vector3;
  137252. /**
  137253. * Returns the agent velocity result in world space
  137254. * @param index agent index returned by addAgent
  137255. * @param result output world space velocity
  137256. */
  137257. getAgentVelocityToRef(index: number, result: Vector3): void;
  137258. /**
  137259. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137260. * @param index agent index returned by addAgent
  137261. * @param destination targeted world position
  137262. */
  137263. agentGoto(index: number, destination: Vector3): void;
  137264. /**
  137265. * Teleport the agent to a new position
  137266. * @param index agent index returned by addAgent
  137267. * @param destination targeted world position
  137268. */
  137269. agentTeleport(index: number, destination: Vector3): void;
  137270. /**
  137271. * Update agent parameters
  137272. * @param index agent index returned by addAgent
  137273. * @param parameters agent parameters
  137274. */
  137275. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137276. /**
  137277. * remove a particular agent previously created
  137278. * @param index agent index returned by addAgent
  137279. */
  137280. removeAgent(index: number): void;
  137281. /**
  137282. * get the list of all agents attached to this crowd
  137283. * @returns list of agent indices
  137284. */
  137285. getAgents(): number[];
  137286. /**
  137287. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137288. * @param deltaTime in seconds
  137289. */
  137290. update(deltaTime: number): void;
  137291. /**
  137292. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137293. * The queries will try to find a solution within those bounds
  137294. * default is (1,1,1)
  137295. * @param extent x,y,z value that define the extent around the queries point of reference
  137296. */
  137297. setDefaultQueryExtent(extent: Vector3): void;
  137298. /**
  137299. * Get the Bounding box extent specified by setDefaultQueryExtent
  137300. * @returns the box extent values
  137301. */
  137302. getDefaultQueryExtent(): Vector3;
  137303. /**
  137304. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137305. * @param result output the box extent values
  137306. */
  137307. getDefaultQueryExtentToRef(result: Vector3): void;
  137308. /**
  137309. * Release all resources
  137310. */
  137311. dispose(): void;
  137312. }
  137313. }
  137314. declare module BABYLON {
  137315. /**
  137316. * Class used to enable access to IndexedDB
  137317. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137318. */
  137319. export class Database implements IOfflineProvider {
  137320. private _callbackManifestChecked;
  137321. private _currentSceneUrl;
  137322. private _db;
  137323. private _enableSceneOffline;
  137324. private _enableTexturesOffline;
  137325. private _manifestVersionFound;
  137326. private _mustUpdateRessources;
  137327. private _hasReachedQuota;
  137328. private _isSupported;
  137329. private _idbFactory;
  137330. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137331. private static IsUASupportingBlobStorage;
  137332. /**
  137333. * Gets a boolean indicating if Database storate is enabled (off by default)
  137334. */
  137335. static IDBStorageEnabled: boolean;
  137336. /**
  137337. * Gets a boolean indicating if scene must be saved in the database
  137338. */
  137339. get enableSceneOffline(): boolean;
  137340. /**
  137341. * Gets a boolean indicating if textures must be saved in the database
  137342. */
  137343. get enableTexturesOffline(): boolean;
  137344. /**
  137345. * Creates a new Database
  137346. * @param urlToScene defines the url to load the scene
  137347. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137348. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137349. */
  137350. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137351. private static _ParseURL;
  137352. private static _ReturnFullUrlLocation;
  137353. private _checkManifestFile;
  137354. /**
  137355. * Open the database and make it available
  137356. * @param successCallback defines the callback to call on success
  137357. * @param errorCallback defines the callback to call on error
  137358. */
  137359. open(successCallback: () => void, errorCallback: () => void): void;
  137360. /**
  137361. * Loads an image from the database
  137362. * @param url defines the url to load from
  137363. * @param image defines the target DOM image
  137364. */
  137365. loadImage(url: string, image: HTMLImageElement): void;
  137366. private _loadImageFromDBAsync;
  137367. private _saveImageIntoDBAsync;
  137368. private _checkVersionFromDB;
  137369. private _loadVersionFromDBAsync;
  137370. private _saveVersionIntoDBAsync;
  137371. /**
  137372. * Loads a file from database
  137373. * @param url defines the URL to load from
  137374. * @param sceneLoaded defines a callback to call on success
  137375. * @param progressCallBack defines a callback to call when progress changed
  137376. * @param errorCallback defines a callback to call on error
  137377. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137378. */
  137379. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137380. private _loadFileAsync;
  137381. private _saveFileAsync;
  137382. /**
  137383. * Validates if xhr data is correct
  137384. * @param xhr defines the request to validate
  137385. * @param dataType defines the expected data type
  137386. * @returns true if data is correct
  137387. */
  137388. private static _ValidateXHRData;
  137389. }
  137390. }
  137391. declare module BABYLON {
  137392. /** @hidden */
  137393. export var gpuUpdateParticlesPixelShader: {
  137394. name: string;
  137395. shader: string;
  137396. };
  137397. }
  137398. declare module BABYLON {
  137399. /** @hidden */
  137400. export var gpuUpdateParticlesVertexShader: {
  137401. name: string;
  137402. shader: string;
  137403. };
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var clipPlaneFragmentDeclaration2: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /** @hidden */
  137414. export var gpuRenderParticlesPixelShader: {
  137415. name: string;
  137416. shader: string;
  137417. };
  137418. }
  137419. declare module BABYLON {
  137420. /** @hidden */
  137421. export var clipPlaneVertexDeclaration2: {
  137422. name: string;
  137423. shader: string;
  137424. };
  137425. }
  137426. declare module BABYLON {
  137427. /** @hidden */
  137428. export var gpuRenderParticlesVertexShader: {
  137429. name: string;
  137430. shader: string;
  137431. };
  137432. }
  137433. declare module BABYLON {
  137434. /**
  137435. * This represents a GPU particle system in Babylon
  137436. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137437. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137438. */
  137439. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137440. /**
  137441. * The layer mask we are rendering the particles through.
  137442. */
  137443. layerMask: number;
  137444. private _capacity;
  137445. private _activeCount;
  137446. private _currentActiveCount;
  137447. private _accumulatedCount;
  137448. private _renderEffect;
  137449. private _updateEffect;
  137450. private _buffer0;
  137451. private _buffer1;
  137452. private _spriteBuffer;
  137453. private _updateVAO;
  137454. private _renderVAO;
  137455. private _targetIndex;
  137456. private _sourceBuffer;
  137457. private _targetBuffer;
  137458. private _engine;
  137459. private _currentRenderId;
  137460. private _started;
  137461. private _stopped;
  137462. private _timeDelta;
  137463. private _randomTexture;
  137464. private _randomTexture2;
  137465. private _attributesStrideSize;
  137466. private _updateEffectOptions;
  137467. private _randomTextureSize;
  137468. private _actualFrame;
  137469. private readonly _rawTextureWidth;
  137470. /**
  137471. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137472. */
  137473. static get IsSupported(): boolean;
  137474. /**
  137475. * An event triggered when the system is disposed.
  137476. */
  137477. onDisposeObservable: Observable<GPUParticleSystem>;
  137478. /**
  137479. * Gets the maximum number of particles active at the same time.
  137480. * @returns The max number of active particles.
  137481. */
  137482. getCapacity(): number;
  137483. /**
  137484. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137485. * to override the particles.
  137486. */
  137487. forceDepthWrite: boolean;
  137488. /**
  137489. * Gets or set the number of active particles
  137490. */
  137491. get activeParticleCount(): number;
  137492. set activeParticleCount(value: number);
  137493. private _preWarmDone;
  137494. /**
  137495. * Specifies if the particles are updated in emitter local space or world space.
  137496. * This is always false for GPU particles
  137497. */
  137498. get isLocal(): boolean;
  137499. set isLocal(value: boolean);
  137500. /**
  137501. * Is this system ready to be used/rendered
  137502. * @return true if the system is ready
  137503. */
  137504. isReady(): boolean;
  137505. /**
  137506. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137507. * @returns True if it has been started, otherwise false.
  137508. */
  137509. isStarted(): boolean;
  137510. /**
  137511. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137512. * @returns True if it has been stopped, otherwise false.
  137513. */
  137514. isStopped(): boolean;
  137515. /**
  137516. * Gets a boolean indicating that the system is stopping
  137517. * @returns true if the system is currently stopping
  137518. */
  137519. isStopping(): boolean;
  137520. /**
  137521. * Gets the number of particles active at the same time.
  137522. * @returns The number of active particles.
  137523. */
  137524. getActiveCount(): number;
  137525. /**
  137526. * Starts the particle system and begins to emit
  137527. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137528. */
  137529. start(delay?: number): void;
  137530. /**
  137531. * Stops the particle system.
  137532. */
  137533. stop(): void;
  137534. /**
  137535. * Remove all active particles
  137536. */
  137537. reset(): void;
  137538. /**
  137539. * Returns the string "GPUParticleSystem"
  137540. * @returns a string containing the class name
  137541. */
  137542. getClassName(): string;
  137543. private _colorGradientsTexture;
  137544. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137545. /**
  137546. * Adds a new color gradient
  137547. * @param gradient defines the gradient to use (between 0 and 1)
  137548. * @param color1 defines the color to affect to the specified gradient
  137549. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137550. * @returns the current particle system
  137551. */
  137552. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137553. private _refreshColorGradient;
  137554. /** Force the system to rebuild all gradients that need to be resync */
  137555. forceRefreshGradients(): void;
  137556. /**
  137557. * Remove a specific color gradient
  137558. * @param gradient defines the gradient to remove
  137559. * @returns the current particle system
  137560. */
  137561. removeColorGradient(gradient: number): GPUParticleSystem;
  137562. private _angularSpeedGradientsTexture;
  137563. private _sizeGradientsTexture;
  137564. private _velocityGradientsTexture;
  137565. private _limitVelocityGradientsTexture;
  137566. private _dragGradientsTexture;
  137567. private _addFactorGradient;
  137568. /**
  137569. * Adds a new size gradient
  137570. * @param gradient defines the gradient to use (between 0 and 1)
  137571. * @param factor defines the size factor to affect to the specified gradient
  137572. * @returns the current particle system
  137573. */
  137574. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137575. /**
  137576. * Remove a specific size gradient
  137577. * @param gradient defines the gradient to remove
  137578. * @returns the current particle system
  137579. */
  137580. removeSizeGradient(gradient: number): GPUParticleSystem;
  137581. private _refreshFactorGradient;
  137582. /**
  137583. * Adds a new angular speed gradient
  137584. * @param gradient defines the gradient to use (between 0 and 1)
  137585. * @param factor defines the angular speed to affect to the specified gradient
  137586. * @returns the current particle system
  137587. */
  137588. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137589. /**
  137590. * Remove a specific angular speed gradient
  137591. * @param gradient defines the gradient to remove
  137592. * @returns the current particle system
  137593. */
  137594. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137595. /**
  137596. * Adds a new velocity gradient
  137597. * @param gradient defines the gradient to use (between 0 and 1)
  137598. * @param factor defines the velocity to affect to the specified gradient
  137599. * @returns the current particle system
  137600. */
  137601. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137602. /**
  137603. * Remove a specific velocity gradient
  137604. * @param gradient defines the gradient to remove
  137605. * @returns the current particle system
  137606. */
  137607. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137608. /**
  137609. * Adds a new limit velocity gradient
  137610. * @param gradient defines the gradient to use (between 0 and 1)
  137611. * @param factor defines the limit velocity value to affect to the specified gradient
  137612. * @returns the current particle system
  137613. */
  137614. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137615. /**
  137616. * Remove a specific limit velocity gradient
  137617. * @param gradient defines the gradient to remove
  137618. * @returns the current particle system
  137619. */
  137620. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137621. /**
  137622. * Adds a new drag gradient
  137623. * @param gradient defines the gradient to use (between 0 and 1)
  137624. * @param factor defines the drag value to affect to the specified gradient
  137625. * @returns the current particle system
  137626. */
  137627. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137628. /**
  137629. * Remove a specific drag gradient
  137630. * @param gradient defines the gradient to remove
  137631. * @returns the current particle system
  137632. */
  137633. removeDragGradient(gradient: number): GPUParticleSystem;
  137634. /**
  137635. * Not supported by GPUParticleSystem
  137636. * @param gradient defines the gradient to use (between 0 and 1)
  137637. * @param factor defines the emit rate value to affect to the specified gradient
  137638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137639. * @returns the current particle system
  137640. */
  137641. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137642. /**
  137643. * Not supported by GPUParticleSystem
  137644. * @param gradient defines the gradient to remove
  137645. * @returns the current particle system
  137646. */
  137647. removeEmitRateGradient(gradient: number): IParticleSystem;
  137648. /**
  137649. * Not supported by GPUParticleSystem
  137650. * @param gradient defines the gradient to use (between 0 and 1)
  137651. * @param factor defines the start size value to affect to the specified gradient
  137652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137653. * @returns the current particle system
  137654. */
  137655. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137656. /**
  137657. * Not supported by GPUParticleSystem
  137658. * @param gradient defines the gradient to remove
  137659. * @returns the current particle system
  137660. */
  137661. removeStartSizeGradient(gradient: number): IParticleSystem;
  137662. /**
  137663. * Not supported by GPUParticleSystem
  137664. * @param gradient defines the gradient to use (between 0 and 1)
  137665. * @param min defines the color remap minimal range
  137666. * @param max defines the color remap maximal range
  137667. * @returns the current particle system
  137668. */
  137669. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137670. /**
  137671. * Not supported by GPUParticleSystem
  137672. * @param gradient defines the gradient to remove
  137673. * @returns the current particle system
  137674. */
  137675. removeColorRemapGradient(): IParticleSystem;
  137676. /**
  137677. * Not supported by GPUParticleSystem
  137678. * @param gradient defines the gradient to use (between 0 and 1)
  137679. * @param min defines the alpha remap minimal range
  137680. * @param max defines the alpha remap maximal range
  137681. * @returns the current particle system
  137682. */
  137683. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137684. /**
  137685. * Not supported by GPUParticleSystem
  137686. * @param gradient defines the gradient to remove
  137687. * @returns the current particle system
  137688. */
  137689. removeAlphaRemapGradient(): IParticleSystem;
  137690. /**
  137691. * Not supported by GPUParticleSystem
  137692. * @param gradient defines the gradient to use (between 0 and 1)
  137693. * @param color defines the color to affect to the specified gradient
  137694. * @returns the current particle system
  137695. */
  137696. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137697. /**
  137698. * Not supported by GPUParticleSystem
  137699. * @param gradient defines the gradient to remove
  137700. * @returns the current particle system
  137701. */
  137702. removeRampGradient(): IParticleSystem;
  137703. /**
  137704. * Not supported by GPUParticleSystem
  137705. * @returns the list of ramp gradients
  137706. */
  137707. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137708. /**
  137709. * Not supported by GPUParticleSystem
  137710. * Gets or sets a boolean indicating that ramp gradients must be used
  137711. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137712. */
  137713. get useRampGradients(): boolean;
  137714. set useRampGradients(value: boolean);
  137715. /**
  137716. * Not supported by GPUParticleSystem
  137717. * @param gradient defines the gradient to use (between 0 and 1)
  137718. * @param factor defines the life time factor to affect to the specified gradient
  137719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137720. * @returns the current particle system
  137721. */
  137722. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137723. /**
  137724. * Not supported by GPUParticleSystem
  137725. * @param gradient defines the gradient to remove
  137726. * @returns the current particle system
  137727. */
  137728. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137729. /**
  137730. * Instantiates a GPU particle system.
  137731. * 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.
  137732. * @param name The name of the particle system
  137733. * @param options The options used to create the system
  137734. * @param scene The scene the particle system belongs to
  137735. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137736. */
  137737. constructor(name: string, options: Partial<{
  137738. capacity: number;
  137739. randomTextureSize: number;
  137740. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137741. protected _reset(): void;
  137742. private _createUpdateVAO;
  137743. private _createRenderVAO;
  137744. private _initialize;
  137745. /** @hidden */
  137746. _recreateUpdateEffect(): void;
  137747. /** @hidden */
  137748. _recreateRenderEffect(): void;
  137749. /**
  137750. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137751. * @param preWarm defines if we are in the pre-warmimg phase
  137752. */
  137753. animate(preWarm?: boolean): void;
  137754. private _createFactorGradientTexture;
  137755. private _createSizeGradientTexture;
  137756. private _createAngularSpeedGradientTexture;
  137757. private _createVelocityGradientTexture;
  137758. private _createLimitVelocityGradientTexture;
  137759. private _createDragGradientTexture;
  137760. private _createColorGradientTexture;
  137761. /**
  137762. * Renders the particle system in its current state
  137763. * @param preWarm defines if the system should only update the particles but not render them
  137764. * @returns the current number of particles
  137765. */
  137766. render(preWarm?: boolean): number;
  137767. /**
  137768. * Rebuilds the particle system
  137769. */
  137770. rebuild(): void;
  137771. private _releaseBuffers;
  137772. private _releaseVAOs;
  137773. /**
  137774. * Disposes the particle system and free the associated resources
  137775. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137776. */
  137777. dispose(disposeTexture?: boolean): void;
  137778. /**
  137779. * Clones the particle system.
  137780. * @param name The name of the cloned object
  137781. * @param newEmitter The new emitter to use
  137782. * @returns the cloned particle system
  137783. */
  137784. clone(name: string, newEmitter: any): GPUParticleSystem;
  137785. /**
  137786. * Serializes the particle system to a JSON object
  137787. * @param serializeTexture defines if the texture must be serialized as well
  137788. * @returns the JSON object
  137789. */
  137790. serialize(serializeTexture?: boolean): any;
  137791. /**
  137792. * Parses a JSON object to create a GPU particle system.
  137793. * @param parsedParticleSystem The JSON object to parse
  137794. * @param scene The scene to create the particle system in
  137795. * @param rootUrl The root url to use to load external dependencies like texture
  137796. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137797. * @returns the parsed GPU particle system
  137798. */
  137799. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137800. }
  137801. }
  137802. declare module BABYLON {
  137803. /**
  137804. * Represents a set of particle systems working together to create a specific effect
  137805. */
  137806. export class ParticleSystemSet implements IDisposable {
  137807. /**
  137808. * Gets or sets base Assets URL
  137809. */
  137810. static BaseAssetsUrl: string;
  137811. private _emitterCreationOptions;
  137812. private _emitterNode;
  137813. /**
  137814. * Gets the particle system list
  137815. */
  137816. systems: IParticleSystem[];
  137817. /**
  137818. * Gets the emitter node used with this set
  137819. */
  137820. get emitterNode(): Nullable<TransformNode>;
  137821. /**
  137822. * Creates a new emitter mesh as a sphere
  137823. * @param options defines the options used to create the sphere
  137824. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137825. * @param scene defines the hosting scene
  137826. */
  137827. setEmitterAsSphere(options: {
  137828. diameter: number;
  137829. segments: number;
  137830. color: Color3;
  137831. }, renderingGroupId: number, scene: Scene): void;
  137832. /**
  137833. * Starts all particle systems of the set
  137834. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137835. */
  137836. start(emitter?: AbstractMesh): void;
  137837. /**
  137838. * Release all associated resources
  137839. */
  137840. dispose(): void;
  137841. /**
  137842. * Serialize the set into a JSON compatible object
  137843. * @param serializeTexture defines if the texture must be serialized as well
  137844. * @returns a JSON compatible representation of the set
  137845. */
  137846. serialize(serializeTexture?: boolean): any;
  137847. /**
  137848. * Parse a new ParticleSystemSet from a serialized source
  137849. * @param data defines a JSON compatible representation of the set
  137850. * @param scene defines the hosting scene
  137851. * @param gpu defines if we want GPU particles or CPU particles
  137852. * @returns a new ParticleSystemSet
  137853. */
  137854. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137855. }
  137856. }
  137857. declare module BABYLON {
  137858. /**
  137859. * This class is made for on one-liner static method to help creating particle system set.
  137860. */
  137861. export class ParticleHelper {
  137862. /**
  137863. * Gets or sets base Assets URL
  137864. */
  137865. static BaseAssetsUrl: string;
  137866. /** Define the Url to load snippets */
  137867. static SnippetUrl: string;
  137868. /**
  137869. * Create a default particle system that you can tweak
  137870. * @param emitter defines the emitter to use
  137871. * @param capacity defines the system capacity (default is 500 particles)
  137872. * @param scene defines the hosting scene
  137873. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137874. * @returns the new Particle system
  137875. */
  137876. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137877. /**
  137878. * This is the main static method (one-liner) of this helper to create different particle systems
  137879. * @param type This string represents the type to the particle system to create
  137880. * @param scene The scene where the particle system should live
  137881. * @param gpu If the system will use gpu
  137882. * @returns the ParticleSystemSet created
  137883. */
  137884. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137885. /**
  137886. * Static function used to export a particle system to a ParticleSystemSet variable.
  137887. * Please note that the emitter shape is not exported
  137888. * @param systems defines the particle systems to export
  137889. * @returns the created particle system set
  137890. */
  137891. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137892. /**
  137893. * Creates a particle system from a snippet saved in a remote file
  137894. * @param name defines the name of the particle system to create
  137895. * @param url defines the url to load from
  137896. * @param scene defines the hosting scene
  137897. * @param gpu If the system will use gpu
  137898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137899. * @returns a promise that will resolve to the new particle system
  137900. */
  137901. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137902. /**
  137903. * Creates a particle system from a snippet saved by the particle system editor
  137904. * @param snippetId defines the snippet to load
  137905. * @param scene defines the hosting scene
  137906. * @param gpu If the system will use gpu
  137907. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137908. * @returns a promise that will resolve to the new particle system
  137909. */
  137910. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137911. }
  137912. }
  137913. declare module BABYLON {
  137914. interface Engine {
  137915. /**
  137916. * Create an effect to use with particle systems.
  137917. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137918. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137919. * @param uniformsNames defines a list of attribute names
  137920. * @param samplers defines an array of string used to represent textures
  137921. * @param defines defines the string containing the defines to use to compile the shaders
  137922. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137923. * @param onCompiled defines a function to call when the effect creation is successful
  137924. * @param onError defines a function to call when the effect creation has failed
  137925. * @returns the new Effect
  137926. */
  137927. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137928. }
  137929. interface Mesh {
  137930. /**
  137931. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137932. * @returns an array of IParticleSystem
  137933. */
  137934. getEmittedParticleSystems(): IParticleSystem[];
  137935. /**
  137936. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137937. * @returns an array of IParticleSystem
  137938. */
  137939. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137940. }
  137941. /**
  137942. * @hidden
  137943. */
  137944. export var _IDoNeedToBeInTheBuild: number;
  137945. }
  137946. declare module BABYLON {
  137947. /** Defines the 4 color options */
  137948. export enum PointColor {
  137949. /** color value */
  137950. Color = 2,
  137951. /** uv value */
  137952. UV = 1,
  137953. /** random value */
  137954. Random = 0,
  137955. /** stated value */
  137956. Stated = 3
  137957. }
  137958. /**
  137959. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137960. * 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.
  137961. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137962. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137963. *
  137964. * Full documentation here : TO BE ENTERED
  137965. */
  137966. export class PointsCloudSystem implements IDisposable {
  137967. /**
  137968. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137969. * Example : var p = SPS.particles[i];
  137970. */
  137971. particles: CloudPoint[];
  137972. /**
  137973. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137974. */
  137975. nbParticles: number;
  137976. /**
  137977. * This a counter for your own usage. It's not set by any SPS functions.
  137978. */
  137979. counter: number;
  137980. /**
  137981. * The PCS name. This name is also given to the underlying mesh.
  137982. */
  137983. name: string;
  137984. /**
  137985. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137986. */
  137987. mesh: Mesh;
  137988. /**
  137989. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  137990. * Please read :
  137991. */
  137992. vars: any;
  137993. /**
  137994. * @hidden
  137995. */
  137996. _size: number;
  137997. private _scene;
  137998. private _promises;
  137999. private _positions;
  138000. private _indices;
  138001. private _normals;
  138002. private _colors;
  138003. private _uvs;
  138004. private _indices32;
  138005. private _positions32;
  138006. private _colors32;
  138007. private _uvs32;
  138008. private _updatable;
  138009. private _isVisibilityBoxLocked;
  138010. private _alwaysVisible;
  138011. private _groups;
  138012. private _groupCounter;
  138013. private _computeParticleColor;
  138014. private _computeParticleTexture;
  138015. private _computeParticleRotation;
  138016. private _computeBoundingBox;
  138017. private _isReady;
  138018. /**
  138019. * Creates a PCS (Points Cloud System) object
  138020. * @param name (String) is the PCS name, this will be the underlying mesh name
  138021. * @param pointSize (number) is the size for each point
  138022. * @param scene (Scene) is the scene in which the PCS is added
  138023. * @param options defines the options of the PCS e.g.
  138024. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  138025. */
  138026. constructor(name: string, pointSize: number, scene: Scene, options?: {
  138027. updatable?: boolean;
  138028. });
  138029. /**
  138030. * Builds the PCS underlying mesh. Returns a standard Mesh.
  138031. * If no points were added to the PCS, the returned mesh is just a single point.
  138032. * @returns a promise for the created mesh
  138033. */
  138034. buildMeshAsync(): Promise<Mesh>;
  138035. /**
  138036. * @hidden
  138037. */
  138038. private _buildMesh;
  138039. private _addParticle;
  138040. private _randomUnitVector;
  138041. private _getColorIndicesForCoord;
  138042. private _setPointsColorOrUV;
  138043. private _colorFromTexture;
  138044. private _calculateDensity;
  138045. /**
  138046. * Adds points to the PCS in random positions within a unit sphere
  138047. * @param nb (positive integer) the number of particles to be created from this model
  138048. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138049. * @returns the number of groups in the system
  138050. */
  138051. addPoints(nb: number, pointFunction?: any): number;
  138052. /**
  138053. * Adds points to the PCS from the surface of the model shape
  138054. * @param mesh is any Mesh object that will be used as a surface model for the points
  138055. * @param nb (positive integer) the number of particles to be created from this model
  138056. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138057. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138058. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138059. * @returns the number of groups in the system
  138060. */
  138061. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138062. /**
  138063. * Adds points to the PCS inside the model shape
  138064. * @param mesh is any Mesh object that will be used as a surface model for the points
  138065. * @param nb (positive integer) the number of particles to be created from this model
  138066. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138067. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138068. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138069. * @returns the number of groups in the system
  138070. */
  138071. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138072. /**
  138073. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138074. * This method calls `updateParticle()` for each particle of the SPS.
  138075. * For an animated SPS, it is usually called within the render loop.
  138076. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138077. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138078. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138079. * @returns the PCS.
  138080. */
  138081. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138082. /**
  138083. * Disposes the PCS.
  138084. */
  138085. dispose(): void;
  138086. /**
  138087. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138088. * doc :
  138089. * @returns the PCS.
  138090. */
  138091. refreshVisibleSize(): PointsCloudSystem;
  138092. /**
  138093. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138094. * @param size the size (float) of the visibility box
  138095. * note : this doesn't lock the PCS mesh bounding box.
  138096. * doc :
  138097. */
  138098. setVisibilityBox(size: number): void;
  138099. /**
  138100. * Gets whether the PCS is always visible or not
  138101. * doc :
  138102. */
  138103. get isAlwaysVisible(): boolean;
  138104. /**
  138105. * Sets the PCS as always visible or not
  138106. * doc :
  138107. */
  138108. set isAlwaysVisible(val: boolean);
  138109. /**
  138110. * Tells to `setParticles()` to compute the particle rotations or not
  138111. * Default value : false. The PCS is faster when it's set to false
  138112. * Note : particle rotations are only applied to parent particles
  138113. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138114. */
  138115. set computeParticleRotation(val: boolean);
  138116. /**
  138117. * Tells to `setParticles()` to compute the particle colors or not.
  138118. * Default value : true. The PCS is faster when it's set to false.
  138119. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138120. */
  138121. set computeParticleColor(val: boolean);
  138122. set computeParticleTexture(val: boolean);
  138123. /**
  138124. * Gets if `setParticles()` computes the particle colors or not.
  138125. * Default value : false. The PCS is faster when it's set to false.
  138126. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138127. */
  138128. get computeParticleColor(): boolean;
  138129. /**
  138130. * Gets if `setParticles()` computes the particle textures or not.
  138131. * Default value : false. The PCS is faster when it's set to false.
  138132. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138133. */
  138134. get computeParticleTexture(): boolean;
  138135. /**
  138136. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138137. */
  138138. set computeBoundingBox(val: boolean);
  138139. /**
  138140. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138141. */
  138142. get computeBoundingBox(): boolean;
  138143. /**
  138144. * This function does nothing. It may be overwritten to set all the particle first values.
  138145. * The PCS doesn't call this function, you may have to call it by your own.
  138146. * doc :
  138147. */
  138148. initParticles(): void;
  138149. /**
  138150. * This function does nothing. It may be overwritten to recycle a particle
  138151. * The PCS doesn't call this function, you can to call it
  138152. * doc :
  138153. * @param particle The particle to recycle
  138154. * @returns the recycled particle
  138155. */
  138156. recycleParticle(particle: CloudPoint): CloudPoint;
  138157. /**
  138158. * Updates a particle : this function should be overwritten by the user.
  138159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138160. * doc :
  138161. * @example : just set a particle position or velocity and recycle conditions
  138162. * @param particle The particle to update
  138163. * @returns the updated particle
  138164. */
  138165. updateParticle(particle: CloudPoint): CloudPoint;
  138166. /**
  138167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138168. * This does nothing and may be overwritten by the user.
  138169. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138171. * @param update the boolean update value actually passed to setParticles()
  138172. */
  138173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138174. /**
  138175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138176. * This will be passed three parameters.
  138177. * This does nothing and may be overwritten by the user.
  138178. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138180. * @param update the boolean update value actually passed to setParticles()
  138181. */
  138182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138183. }
  138184. }
  138185. declare module BABYLON {
  138186. /**
  138187. * Represents one particle of a points cloud system.
  138188. */
  138189. export class CloudPoint {
  138190. /**
  138191. * particle global index
  138192. */
  138193. idx: number;
  138194. /**
  138195. * The color of the particle
  138196. */
  138197. color: Nullable<Color4>;
  138198. /**
  138199. * The world space position of the particle.
  138200. */
  138201. position: Vector3;
  138202. /**
  138203. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138204. */
  138205. rotation: Vector3;
  138206. /**
  138207. * The world space rotation quaternion of the particle.
  138208. */
  138209. rotationQuaternion: Nullable<Quaternion>;
  138210. /**
  138211. * The uv of the particle.
  138212. */
  138213. uv: Nullable<Vector2>;
  138214. /**
  138215. * The current speed of the particle.
  138216. */
  138217. velocity: Vector3;
  138218. /**
  138219. * The pivot point in the particle local space.
  138220. */
  138221. pivot: Vector3;
  138222. /**
  138223. * Must the particle be translated from its pivot point in its local space ?
  138224. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138225. * Default : false
  138226. */
  138227. translateFromPivot: boolean;
  138228. /**
  138229. * Index of this particle in the global "positions" array (Internal use)
  138230. * @hidden
  138231. */
  138232. _pos: number;
  138233. /**
  138234. * @hidden Index of this particle in the global "indices" array (Internal use)
  138235. */
  138236. _ind: number;
  138237. /**
  138238. * Group this particle belongs to
  138239. */
  138240. _group: PointsGroup;
  138241. /**
  138242. * Group id of this particle
  138243. */
  138244. groupId: number;
  138245. /**
  138246. * Index of the particle in its group id (Internal use)
  138247. */
  138248. idxInGroup: number;
  138249. /**
  138250. * @hidden Particle BoundingInfo object (Internal use)
  138251. */
  138252. _boundingInfo: BoundingInfo;
  138253. /**
  138254. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138255. */
  138256. _pcs: PointsCloudSystem;
  138257. /**
  138258. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138259. */
  138260. _stillInvisible: boolean;
  138261. /**
  138262. * @hidden Last computed particle rotation matrix
  138263. */
  138264. _rotationMatrix: number[];
  138265. /**
  138266. * Parent particle Id, if any.
  138267. * Default null.
  138268. */
  138269. parentId: Nullable<number>;
  138270. /**
  138271. * @hidden Internal global position in the PCS.
  138272. */
  138273. _globalPosition: Vector3;
  138274. /**
  138275. * Creates a Point Cloud object.
  138276. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138277. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138278. * @param group (PointsGroup) is the group the particle belongs to
  138279. * @param groupId (integer) is the group identifier in the PCS.
  138280. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138281. * @param pcs defines the PCS it is associated to
  138282. */
  138283. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138284. /**
  138285. * get point size
  138286. */
  138287. get size(): Vector3;
  138288. /**
  138289. * Set point size
  138290. */
  138291. set size(scale: Vector3);
  138292. /**
  138293. * Legacy support, changed quaternion to rotationQuaternion
  138294. */
  138295. get quaternion(): Nullable<Quaternion>;
  138296. /**
  138297. * Legacy support, changed quaternion to rotationQuaternion
  138298. */
  138299. set quaternion(q: Nullable<Quaternion>);
  138300. /**
  138301. * Returns a boolean. True if the particle intersects a mesh, else false
  138302. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138303. * @param target is the object (point or mesh) what the intersection is computed against
  138304. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138305. * @returns true if it intersects
  138306. */
  138307. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138308. /**
  138309. * get the rotation matrix of the particle
  138310. * @hidden
  138311. */
  138312. getRotationMatrix(m: Matrix): void;
  138313. }
  138314. /**
  138315. * Represents a group of points in a points cloud system
  138316. * * PCS internal tool, don't use it manually.
  138317. */
  138318. export class PointsGroup {
  138319. /**
  138320. * The group id
  138321. * @hidden
  138322. */
  138323. groupID: number;
  138324. /**
  138325. * image data for group (internal use)
  138326. * @hidden
  138327. */
  138328. _groupImageData: Nullable<ArrayBufferView>;
  138329. /**
  138330. * Image Width (internal use)
  138331. * @hidden
  138332. */
  138333. _groupImgWidth: number;
  138334. /**
  138335. * Image Height (internal use)
  138336. * @hidden
  138337. */
  138338. _groupImgHeight: number;
  138339. /**
  138340. * Custom position function (internal use)
  138341. * @hidden
  138342. */
  138343. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138344. /**
  138345. * density per facet for surface points
  138346. * @hidden
  138347. */
  138348. _groupDensity: number[];
  138349. /**
  138350. * Only when points are colored by texture carries pointer to texture list array
  138351. * @hidden
  138352. */
  138353. _textureNb: number;
  138354. /**
  138355. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138356. * PCS internal tool, don't use it manually.
  138357. * @hidden
  138358. */
  138359. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138360. }
  138361. }
  138362. declare module BABYLON {
  138363. /**
  138364. * Represents a set of particle systems working together to create a specific effect
  138365. */
  138366. export class ParticleSystemDebugger implements IDisposable {
  138367. /**
  138368. * Defines the particle system to debug
  138369. */
  138370. system: IParticleSystem;
  138371. /**
  138372. * Creates a new particle system debugger
  138373. * @param system defines the particle system to debug
  138374. */
  138375. constructor(
  138376. /**
  138377. * Defines the particle system to debug
  138378. */
  138379. system: IParticleSystem);
  138380. /** Clear all the resources */
  138381. dispose(): void;
  138382. }
  138383. }
  138384. declare module BABYLON {
  138385. interface Scene {
  138386. /** @hidden (Backing field) */
  138387. _physicsEngine: Nullable<IPhysicsEngine>;
  138388. /** @hidden */
  138389. _physicsTimeAccumulator: number;
  138390. /**
  138391. * Gets the current physics engine
  138392. * @returns a IPhysicsEngine or null if none attached
  138393. */
  138394. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138395. /**
  138396. * Enables physics to the current scene
  138397. * @param gravity defines the scene's gravity for the physics engine
  138398. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138399. * @return a boolean indicating if the physics engine was initialized
  138400. */
  138401. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138402. /**
  138403. * Disables and disposes the physics engine associated with the scene
  138404. */
  138405. disablePhysicsEngine(): void;
  138406. /**
  138407. * Gets a boolean indicating if there is an active physics engine
  138408. * @returns a boolean indicating if there is an active physics engine
  138409. */
  138410. isPhysicsEnabled(): boolean;
  138411. /**
  138412. * Deletes a physics compound impostor
  138413. * @param compound defines the compound to delete
  138414. */
  138415. deleteCompoundImpostor(compound: any): void;
  138416. /**
  138417. * An event triggered when physic simulation is about to be run
  138418. */
  138419. onBeforePhysicsObservable: Observable<Scene>;
  138420. /**
  138421. * An event triggered when physic simulation has been done
  138422. */
  138423. onAfterPhysicsObservable: Observable<Scene>;
  138424. }
  138425. interface AbstractMesh {
  138426. /** @hidden */
  138427. _physicsImpostor: Nullable<PhysicsImpostor>;
  138428. /**
  138429. * Gets or sets impostor used for physic simulation
  138430. * @see http://doc.babylonjs.com/features/physics_engine
  138431. */
  138432. physicsImpostor: Nullable<PhysicsImpostor>;
  138433. /**
  138434. * Gets the current physics impostor
  138435. * @see http://doc.babylonjs.com/features/physics_engine
  138436. * @returns a physics impostor or null
  138437. */
  138438. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138439. /** Apply a physic impulse to the mesh
  138440. * @param force defines the force to apply
  138441. * @param contactPoint defines where to apply the force
  138442. * @returns the current mesh
  138443. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138444. */
  138445. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138446. /**
  138447. * Creates a physic joint between two meshes
  138448. * @param otherMesh defines the other mesh to use
  138449. * @param pivot1 defines the pivot to use on this mesh
  138450. * @param pivot2 defines the pivot to use on the other mesh
  138451. * @param options defines additional options (can be plugin dependent)
  138452. * @returns the current mesh
  138453. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138454. */
  138455. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138456. /** @hidden */
  138457. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138458. }
  138459. /**
  138460. * Defines the physics engine scene component responsible to manage a physics engine
  138461. */
  138462. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138463. /**
  138464. * The component name helpful to identify the component in the list of scene components.
  138465. */
  138466. readonly name: string;
  138467. /**
  138468. * The scene the component belongs to.
  138469. */
  138470. scene: Scene;
  138471. /**
  138472. * Creates a new instance of the component for the given scene
  138473. * @param scene Defines the scene to register the component in
  138474. */
  138475. constructor(scene: Scene);
  138476. /**
  138477. * Registers the component in a given scene
  138478. */
  138479. register(): void;
  138480. /**
  138481. * Rebuilds the elements related to this component in case of
  138482. * context lost for instance.
  138483. */
  138484. rebuild(): void;
  138485. /**
  138486. * Disposes the component and the associated ressources
  138487. */
  138488. dispose(): void;
  138489. }
  138490. }
  138491. declare module BABYLON {
  138492. /**
  138493. * A helper for physics simulations
  138494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138495. */
  138496. export class PhysicsHelper {
  138497. private _scene;
  138498. private _physicsEngine;
  138499. /**
  138500. * Initializes the Physics helper
  138501. * @param scene Babylon.js scene
  138502. */
  138503. constructor(scene: Scene);
  138504. /**
  138505. * Applies a radial explosion impulse
  138506. * @param origin the origin of the explosion
  138507. * @param radiusOrEventOptions the radius or the options of radial explosion
  138508. * @param strength the explosion strength
  138509. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138510. * @returns A physics radial explosion event, or null
  138511. */
  138512. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138513. /**
  138514. * Applies a radial explosion force
  138515. * @param origin the origin of the explosion
  138516. * @param radiusOrEventOptions the radius or the options of radial explosion
  138517. * @param strength the explosion strength
  138518. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138519. * @returns A physics radial explosion event, or null
  138520. */
  138521. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138522. /**
  138523. * Creates a gravitational field
  138524. * @param origin the origin of the explosion
  138525. * @param radiusOrEventOptions the radius or the options of radial explosion
  138526. * @param strength the explosion strength
  138527. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138528. * @returns A physics gravitational field event, or null
  138529. */
  138530. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138531. /**
  138532. * Creates a physics updraft event
  138533. * @param origin the origin of the updraft
  138534. * @param radiusOrEventOptions the radius or the options of the updraft
  138535. * @param strength the strength of the updraft
  138536. * @param height the height of the updraft
  138537. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138538. * @returns A physics updraft event, or null
  138539. */
  138540. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138541. /**
  138542. * Creates a physics vortex event
  138543. * @param origin the of the vortex
  138544. * @param radiusOrEventOptions the radius or the options of the vortex
  138545. * @param strength the strength of the vortex
  138546. * @param height the height of the vortex
  138547. * @returns a Physics vortex event, or null
  138548. * A physics vortex event or null
  138549. */
  138550. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138551. }
  138552. /**
  138553. * Represents a physics radial explosion event
  138554. */
  138555. class PhysicsRadialExplosionEvent {
  138556. private _scene;
  138557. private _options;
  138558. private _sphere;
  138559. private _dataFetched;
  138560. /**
  138561. * Initializes a radial explosioin event
  138562. * @param _scene BabylonJS scene
  138563. * @param _options The options for the vortex event
  138564. */
  138565. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138566. /**
  138567. * Returns the data related to the radial explosion event (sphere).
  138568. * @returns The radial explosion event data
  138569. */
  138570. getData(): PhysicsRadialExplosionEventData;
  138571. /**
  138572. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138573. * @param impostor A physics imposter
  138574. * @param origin the origin of the explosion
  138575. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138576. */
  138577. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138578. /**
  138579. * Triggers affecterd impostors callbacks
  138580. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138581. */
  138582. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138583. /**
  138584. * Disposes the sphere.
  138585. * @param force Specifies if the sphere should be disposed by force
  138586. */
  138587. dispose(force?: boolean): void;
  138588. /*** Helpers ***/
  138589. private _prepareSphere;
  138590. private _intersectsWithSphere;
  138591. }
  138592. /**
  138593. * Represents a gravitational field event
  138594. */
  138595. class PhysicsGravitationalFieldEvent {
  138596. private _physicsHelper;
  138597. private _scene;
  138598. private _origin;
  138599. private _options;
  138600. private _tickCallback;
  138601. private _sphere;
  138602. private _dataFetched;
  138603. /**
  138604. * Initializes the physics gravitational field event
  138605. * @param _physicsHelper A physics helper
  138606. * @param _scene BabylonJS scene
  138607. * @param _origin The origin position of the gravitational field event
  138608. * @param _options The options for the vortex event
  138609. */
  138610. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138611. /**
  138612. * Returns the data related to the gravitational field event (sphere).
  138613. * @returns A gravitational field event
  138614. */
  138615. getData(): PhysicsGravitationalFieldEventData;
  138616. /**
  138617. * Enables the gravitational field.
  138618. */
  138619. enable(): void;
  138620. /**
  138621. * Disables the gravitational field.
  138622. */
  138623. disable(): void;
  138624. /**
  138625. * Disposes the sphere.
  138626. * @param force The force to dispose from the gravitational field event
  138627. */
  138628. dispose(force?: boolean): void;
  138629. private _tick;
  138630. }
  138631. /**
  138632. * Represents a physics updraft event
  138633. */
  138634. class PhysicsUpdraftEvent {
  138635. private _scene;
  138636. private _origin;
  138637. private _options;
  138638. private _physicsEngine;
  138639. private _originTop;
  138640. private _originDirection;
  138641. private _tickCallback;
  138642. private _cylinder;
  138643. private _cylinderPosition;
  138644. private _dataFetched;
  138645. /**
  138646. * Initializes the physics updraft event
  138647. * @param _scene BabylonJS scene
  138648. * @param _origin The origin position of the updraft
  138649. * @param _options The options for the updraft event
  138650. */
  138651. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138652. /**
  138653. * Returns the data related to the updraft event (cylinder).
  138654. * @returns A physics updraft event
  138655. */
  138656. getData(): PhysicsUpdraftEventData;
  138657. /**
  138658. * Enables the updraft.
  138659. */
  138660. enable(): void;
  138661. /**
  138662. * Disables the updraft.
  138663. */
  138664. disable(): void;
  138665. /**
  138666. * Disposes the cylinder.
  138667. * @param force Specifies if the updraft should be disposed by force
  138668. */
  138669. dispose(force?: boolean): void;
  138670. private getImpostorHitData;
  138671. private _tick;
  138672. /*** Helpers ***/
  138673. private _prepareCylinder;
  138674. private _intersectsWithCylinder;
  138675. }
  138676. /**
  138677. * Represents a physics vortex event
  138678. */
  138679. class PhysicsVortexEvent {
  138680. private _scene;
  138681. private _origin;
  138682. private _options;
  138683. private _physicsEngine;
  138684. private _originTop;
  138685. private _tickCallback;
  138686. private _cylinder;
  138687. private _cylinderPosition;
  138688. private _dataFetched;
  138689. /**
  138690. * Initializes the physics vortex event
  138691. * @param _scene The BabylonJS scene
  138692. * @param _origin The origin position of the vortex
  138693. * @param _options The options for the vortex event
  138694. */
  138695. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138696. /**
  138697. * Returns the data related to the vortex event (cylinder).
  138698. * @returns The physics vortex event data
  138699. */
  138700. getData(): PhysicsVortexEventData;
  138701. /**
  138702. * Enables the vortex.
  138703. */
  138704. enable(): void;
  138705. /**
  138706. * Disables the cortex.
  138707. */
  138708. disable(): void;
  138709. /**
  138710. * Disposes the sphere.
  138711. * @param force
  138712. */
  138713. dispose(force?: boolean): void;
  138714. private getImpostorHitData;
  138715. private _tick;
  138716. /*** Helpers ***/
  138717. private _prepareCylinder;
  138718. private _intersectsWithCylinder;
  138719. }
  138720. /**
  138721. * Options fot the radial explosion event
  138722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138723. */
  138724. export class PhysicsRadialExplosionEventOptions {
  138725. /**
  138726. * The radius of the sphere for the radial explosion.
  138727. */
  138728. radius: number;
  138729. /**
  138730. * The strenth of the explosion.
  138731. */
  138732. strength: number;
  138733. /**
  138734. * The strenght of the force in correspondence to the distance of the affected object
  138735. */
  138736. falloff: PhysicsRadialImpulseFalloff;
  138737. /**
  138738. * Sphere options for the radial explosion.
  138739. */
  138740. sphere: {
  138741. segments: number;
  138742. diameter: number;
  138743. };
  138744. /**
  138745. * Sphere options for the radial explosion.
  138746. */
  138747. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138748. }
  138749. /**
  138750. * Options fot the updraft event
  138751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138752. */
  138753. export class PhysicsUpdraftEventOptions {
  138754. /**
  138755. * The radius of the cylinder for the vortex
  138756. */
  138757. radius: number;
  138758. /**
  138759. * The strenth of the updraft.
  138760. */
  138761. strength: number;
  138762. /**
  138763. * The height of the cylinder for the updraft.
  138764. */
  138765. height: number;
  138766. /**
  138767. * The mode for the the updraft.
  138768. */
  138769. updraftMode: PhysicsUpdraftMode;
  138770. }
  138771. /**
  138772. * Options fot the vortex event
  138773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138774. */
  138775. export class PhysicsVortexEventOptions {
  138776. /**
  138777. * The radius of the cylinder for the vortex
  138778. */
  138779. radius: number;
  138780. /**
  138781. * The strenth of the vortex.
  138782. */
  138783. strength: number;
  138784. /**
  138785. * The height of the cylinder for the vortex.
  138786. */
  138787. height: number;
  138788. /**
  138789. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138790. */
  138791. centripetalForceThreshold: number;
  138792. /**
  138793. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138794. */
  138795. centripetalForceMultiplier: number;
  138796. /**
  138797. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138798. */
  138799. centrifugalForceMultiplier: number;
  138800. /**
  138801. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138802. */
  138803. updraftForceMultiplier: number;
  138804. }
  138805. /**
  138806. * The strenght of the force in correspondence to the distance of the affected object
  138807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138808. */
  138809. export enum PhysicsRadialImpulseFalloff {
  138810. /** Defines that impulse is constant in strength across it's whole radius */
  138811. Constant = 0,
  138812. /** Defines that impulse gets weaker if it's further from the origin */
  138813. Linear = 1
  138814. }
  138815. /**
  138816. * The strength of the force in correspondence to the distance of the affected object
  138817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138818. */
  138819. export enum PhysicsUpdraftMode {
  138820. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138821. Center = 0,
  138822. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138823. Perpendicular = 1
  138824. }
  138825. /**
  138826. * Interface for a physics hit data
  138827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138828. */
  138829. export interface PhysicsHitData {
  138830. /**
  138831. * The force applied at the contact point
  138832. */
  138833. force: Vector3;
  138834. /**
  138835. * The contact point
  138836. */
  138837. contactPoint: Vector3;
  138838. /**
  138839. * The distance from the origin to the contact point
  138840. */
  138841. distanceFromOrigin: number;
  138842. }
  138843. /**
  138844. * Interface for radial explosion event data
  138845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138846. */
  138847. export interface PhysicsRadialExplosionEventData {
  138848. /**
  138849. * A sphere used for the radial explosion event
  138850. */
  138851. sphere: Mesh;
  138852. }
  138853. /**
  138854. * Interface for gravitational field event data
  138855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138856. */
  138857. export interface PhysicsGravitationalFieldEventData {
  138858. /**
  138859. * A sphere mesh used for the gravitational field event
  138860. */
  138861. sphere: Mesh;
  138862. }
  138863. /**
  138864. * Interface for updraft event data
  138865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138866. */
  138867. export interface PhysicsUpdraftEventData {
  138868. /**
  138869. * A cylinder used for the updraft event
  138870. */
  138871. cylinder: Mesh;
  138872. }
  138873. /**
  138874. * Interface for vortex event data
  138875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138876. */
  138877. export interface PhysicsVortexEventData {
  138878. /**
  138879. * A cylinder used for the vortex event
  138880. */
  138881. cylinder: Mesh;
  138882. }
  138883. /**
  138884. * Interface for an affected physics impostor
  138885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138886. */
  138887. export interface PhysicsAffectedImpostorWithData {
  138888. /**
  138889. * The impostor affected by the effect
  138890. */
  138891. impostor: PhysicsImpostor;
  138892. /**
  138893. * The data about the hit/horce from the explosion
  138894. */
  138895. hitData: PhysicsHitData;
  138896. }
  138897. }
  138898. declare module BABYLON {
  138899. /** @hidden */
  138900. export var blackAndWhitePixelShader: {
  138901. name: string;
  138902. shader: string;
  138903. };
  138904. }
  138905. declare module BABYLON {
  138906. /**
  138907. * Post process used to render in black and white
  138908. */
  138909. export class BlackAndWhitePostProcess extends PostProcess {
  138910. /**
  138911. * Linear about to convert he result to black and white (default: 1)
  138912. */
  138913. degree: number;
  138914. /**
  138915. * Creates a black and white post process
  138916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138917. * @param name The name of the effect.
  138918. * @param options The required width/height ratio to downsize to before computing the render pass.
  138919. * @param camera The camera to apply the render pass to.
  138920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138921. * @param engine The engine which the post process will be applied. (default: current engine)
  138922. * @param reusable If the post process can be reused on the same frame. (default: false)
  138923. */
  138924. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138925. }
  138926. }
  138927. declare module BABYLON {
  138928. /**
  138929. * This represents a set of one or more post processes in Babylon.
  138930. * A post process can be used to apply a shader to a texture after it is rendered.
  138931. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138932. */
  138933. export class PostProcessRenderEffect {
  138934. private _postProcesses;
  138935. private _getPostProcesses;
  138936. private _singleInstance;
  138937. private _cameras;
  138938. private _indicesForCamera;
  138939. /**
  138940. * Name of the effect
  138941. * @hidden
  138942. */
  138943. _name: string;
  138944. /**
  138945. * Instantiates a post process render effect.
  138946. * A post process can be used to apply a shader to a texture after it is rendered.
  138947. * @param engine The engine the effect is tied to
  138948. * @param name The name of the effect
  138949. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138950. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138951. */
  138952. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138953. /**
  138954. * Checks if all the post processes in the effect are supported.
  138955. */
  138956. get isSupported(): boolean;
  138957. /**
  138958. * Updates the current state of the effect
  138959. * @hidden
  138960. */
  138961. _update(): void;
  138962. /**
  138963. * Attaches the effect on cameras
  138964. * @param cameras The camera to attach to.
  138965. * @hidden
  138966. */
  138967. _attachCameras(cameras: Camera): void;
  138968. /**
  138969. * Attaches the effect on cameras
  138970. * @param cameras The camera to attach to.
  138971. * @hidden
  138972. */
  138973. _attachCameras(cameras: Camera[]): void;
  138974. /**
  138975. * Detaches the effect on cameras
  138976. * @param cameras The camera to detatch from.
  138977. * @hidden
  138978. */
  138979. _detachCameras(cameras: Camera): void;
  138980. /**
  138981. * Detatches the effect on cameras
  138982. * @param cameras The camera to detatch from.
  138983. * @hidden
  138984. */
  138985. _detachCameras(cameras: Camera[]): void;
  138986. /**
  138987. * Enables the effect on given cameras
  138988. * @param cameras The camera to enable.
  138989. * @hidden
  138990. */
  138991. _enable(cameras: Camera): void;
  138992. /**
  138993. * Enables the effect on given cameras
  138994. * @param cameras The camera to enable.
  138995. * @hidden
  138996. */
  138997. _enable(cameras: Nullable<Camera[]>): void;
  138998. /**
  138999. * Disables the effect on the given cameras
  139000. * @param cameras The camera to disable.
  139001. * @hidden
  139002. */
  139003. _disable(cameras: Camera): void;
  139004. /**
  139005. * Disables the effect on the given cameras
  139006. * @param cameras The camera to disable.
  139007. * @hidden
  139008. */
  139009. _disable(cameras: Nullable<Camera[]>): void;
  139010. /**
  139011. * Gets a list of the post processes contained in the effect.
  139012. * @param camera The camera to get the post processes on.
  139013. * @returns The list of the post processes in the effect.
  139014. */
  139015. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  139016. }
  139017. }
  139018. declare module BABYLON {
  139019. /** @hidden */
  139020. export var extractHighlightsPixelShader: {
  139021. name: string;
  139022. shader: string;
  139023. };
  139024. }
  139025. declare module BABYLON {
  139026. /**
  139027. * 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.
  139028. */
  139029. export class ExtractHighlightsPostProcess extends PostProcess {
  139030. /**
  139031. * The luminance threshold, pixels below this value will be set to black.
  139032. */
  139033. threshold: number;
  139034. /** @hidden */
  139035. _exposure: number;
  139036. /**
  139037. * Post process which has the input texture to be used when performing highlight extraction
  139038. * @hidden
  139039. */
  139040. _inputPostProcess: Nullable<PostProcess>;
  139041. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139042. }
  139043. }
  139044. declare module BABYLON {
  139045. /** @hidden */
  139046. export var bloomMergePixelShader: {
  139047. name: string;
  139048. shader: string;
  139049. };
  139050. }
  139051. declare module BABYLON {
  139052. /**
  139053. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139054. */
  139055. export class BloomMergePostProcess extends PostProcess {
  139056. /** Weight of the bloom to be added to the original input. */
  139057. weight: number;
  139058. /**
  139059. * Creates a new instance of @see BloomMergePostProcess
  139060. * @param name The name of the effect.
  139061. * @param originalFromInput Post process which's input will be used for the merge.
  139062. * @param blurred Blurred highlights post process which's output will be used.
  139063. * @param weight Weight of the bloom to be added to the original input.
  139064. * @param options The required width/height ratio to downsize to before computing the render pass.
  139065. * @param camera The camera to apply the render pass to.
  139066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139067. * @param engine The engine which the post process will be applied. (default: current engine)
  139068. * @param reusable If the post process can be reused on the same frame. (default: false)
  139069. * @param textureType Type of textures used when performing the post process. (default: 0)
  139070. * @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)
  139071. */
  139072. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139073. /** Weight of the bloom to be added to the original input. */
  139074. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139075. }
  139076. }
  139077. declare module BABYLON {
  139078. /**
  139079. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139080. */
  139081. export class BloomEffect extends PostProcessRenderEffect {
  139082. private bloomScale;
  139083. /**
  139084. * @hidden Internal
  139085. */
  139086. _effects: Array<PostProcess>;
  139087. /**
  139088. * @hidden Internal
  139089. */
  139090. _downscale: ExtractHighlightsPostProcess;
  139091. private _blurX;
  139092. private _blurY;
  139093. private _merge;
  139094. /**
  139095. * The luminance threshold to find bright areas of the image to bloom.
  139096. */
  139097. get threshold(): number;
  139098. set threshold(value: number);
  139099. /**
  139100. * The strength of the bloom.
  139101. */
  139102. get weight(): number;
  139103. set weight(value: number);
  139104. /**
  139105. * Specifies the size of the bloom blur kernel, relative to the final output size
  139106. */
  139107. get kernel(): number;
  139108. set kernel(value: number);
  139109. /**
  139110. * Creates a new instance of @see BloomEffect
  139111. * @param scene The scene the effect belongs to.
  139112. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139113. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139114. * @param bloomWeight The the strength of bloom.
  139115. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139116. * @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)
  139117. */
  139118. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139119. /**
  139120. * Disposes each of the internal effects for a given camera.
  139121. * @param camera The camera to dispose the effect on.
  139122. */
  139123. disposeEffects(camera: Camera): void;
  139124. /**
  139125. * @hidden Internal
  139126. */
  139127. _updateEffects(): void;
  139128. /**
  139129. * Internal
  139130. * @returns if all the contained post processes are ready.
  139131. * @hidden
  139132. */
  139133. _isReady(): boolean;
  139134. }
  139135. }
  139136. declare module BABYLON {
  139137. /** @hidden */
  139138. export var chromaticAberrationPixelShader: {
  139139. name: string;
  139140. shader: string;
  139141. };
  139142. }
  139143. declare module BABYLON {
  139144. /**
  139145. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139146. */
  139147. export class ChromaticAberrationPostProcess extends PostProcess {
  139148. /**
  139149. * The amount of seperation of rgb channels (default: 30)
  139150. */
  139151. aberrationAmount: number;
  139152. /**
  139153. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139154. */
  139155. radialIntensity: number;
  139156. /**
  139157. * 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))
  139158. */
  139159. direction: Vector2;
  139160. /**
  139161. * 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))
  139162. */
  139163. centerPosition: Vector2;
  139164. /**
  139165. * Creates a new instance ChromaticAberrationPostProcess
  139166. * @param name The name of the effect.
  139167. * @param screenWidth The width of the screen to apply the effect on.
  139168. * @param screenHeight The height of the screen to apply the effect on.
  139169. * @param options The required width/height ratio to downsize to before computing the render pass.
  139170. * @param camera The camera to apply the render pass to.
  139171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139172. * @param engine The engine which the post process will be applied. (default: current engine)
  139173. * @param reusable If the post process can be reused on the same frame. (default: false)
  139174. * @param textureType Type of textures used when performing the post process. (default: 0)
  139175. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  139176. */
  139177. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139178. }
  139179. }
  139180. declare module BABYLON {
  139181. /** @hidden */
  139182. export var circleOfConfusionPixelShader: {
  139183. name: string;
  139184. shader: string;
  139185. };
  139186. }
  139187. declare module BABYLON {
  139188. /**
  139189. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139190. */
  139191. export class CircleOfConfusionPostProcess extends PostProcess {
  139192. /**
  139193. * 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.
  139194. */
  139195. lensSize: number;
  139196. /**
  139197. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139198. */
  139199. fStop: number;
  139200. /**
  139201. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139202. */
  139203. focusDistance: number;
  139204. /**
  139205. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139206. */
  139207. focalLength: number;
  139208. private _depthTexture;
  139209. /**
  139210. * Creates a new instance CircleOfConfusionPostProcess
  139211. * @param name The name of the effect.
  139212. * @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.
  139213. * @param options The required width/height ratio to downsize to before computing the render pass.
  139214. * @param camera The camera to apply the render pass to.
  139215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139216. * @param engine The engine which the post process will be applied. (default: current engine)
  139217. * @param reusable If the post process can be reused on the same frame. (default: false)
  139218. * @param textureType Type of textures used when performing the post process. (default: 0)
  139219. * @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)
  139220. */
  139221. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139222. /**
  139223. * 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.
  139224. */
  139225. set depthTexture(value: RenderTargetTexture);
  139226. }
  139227. }
  139228. declare module BABYLON {
  139229. /** @hidden */
  139230. export var colorCorrectionPixelShader: {
  139231. name: string;
  139232. shader: string;
  139233. };
  139234. }
  139235. declare module BABYLON {
  139236. /**
  139237. *
  139238. * This post-process allows the modification of rendered colors by using
  139239. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139240. *
  139241. * The object needs to be provided an url to a texture containing the color
  139242. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139243. * Use an image editing software to tweak the LUT to match your needs.
  139244. *
  139245. * For an example of a color LUT, see here:
  139246. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139247. * For explanations on color grading, see here:
  139248. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139249. *
  139250. */
  139251. export class ColorCorrectionPostProcess extends PostProcess {
  139252. private _colorTableTexture;
  139253. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139254. }
  139255. }
  139256. declare module BABYLON {
  139257. /** @hidden */
  139258. export var convolutionPixelShader: {
  139259. name: string;
  139260. shader: string;
  139261. };
  139262. }
  139263. declare module BABYLON {
  139264. /**
  139265. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139266. * input texture to perform effects such as edge detection or sharpening
  139267. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139268. */
  139269. export class ConvolutionPostProcess extends PostProcess {
  139270. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139271. kernel: number[];
  139272. /**
  139273. * Creates a new instance ConvolutionPostProcess
  139274. * @param name The name of the effect.
  139275. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139276. * @param options The required width/height ratio to downsize to before computing the render pass.
  139277. * @param camera The camera to apply the render pass to.
  139278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139279. * @param engine The engine which the post process will be applied. (default: current engine)
  139280. * @param reusable If the post process can be reused on the same frame. (default: false)
  139281. * @param textureType Type of textures used when performing the post process. (default: 0)
  139282. */
  139283. constructor(name: string,
  139284. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139285. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139286. /**
  139287. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139288. */
  139289. static EdgeDetect0Kernel: number[];
  139290. /**
  139291. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139292. */
  139293. static EdgeDetect1Kernel: number[];
  139294. /**
  139295. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139296. */
  139297. static EdgeDetect2Kernel: number[];
  139298. /**
  139299. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139300. */
  139301. static SharpenKernel: number[];
  139302. /**
  139303. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139304. */
  139305. static EmbossKernel: number[];
  139306. /**
  139307. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139308. */
  139309. static GaussianKernel: number[];
  139310. }
  139311. }
  139312. declare module BABYLON {
  139313. /**
  139314. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139315. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139316. * based on samples that have a large difference in distance than the center pixel.
  139317. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139318. */
  139319. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139320. direction: Vector2;
  139321. /**
  139322. * Creates a new instance CircleOfConfusionPostProcess
  139323. * @param name The name of the effect.
  139324. * @param scene The scene the effect belongs to.
  139325. * @param direction The direction the blur should be applied.
  139326. * @param kernel The size of the kernel used to blur.
  139327. * @param options The required width/height ratio to downsize to before computing the render pass.
  139328. * @param camera The camera to apply the render pass to.
  139329. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139330. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139332. * @param engine The engine which the post process will be applied. (default: current engine)
  139333. * @param reusable If the post process can be reused on the same frame. (default: false)
  139334. * @param textureType Type of textures used when performing the post process. (default: 0)
  139335. * @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)
  139336. */
  139337. 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);
  139338. }
  139339. }
  139340. declare module BABYLON {
  139341. /** @hidden */
  139342. export var depthOfFieldMergePixelShader: {
  139343. name: string;
  139344. shader: string;
  139345. };
  139346. }
  139347. declare module BABYLON {
  139348. /**
  139349. * Options to be set when merging outputs from the default pipeline.
  139350. */
  139351. export class DepthOfFieldMergePostProcessOptions {
  139352. /**
  139353. * The original image to merge on top of
  139354. */
  139355. originalFromInput: PostProcess;
  139356. /**
  139357. * Parameters to perform the merge of the depth of field effect
  139358. */
  139359. depthOfField?: {
  139360. circleOfConfusion: PostProcess;
  139361. blurSteps: Array<PostProcess>;
  139362. };
  139363. /**
  139364. * Parameters to perform the merge of bloom effect
  139365. */
  139366. bloom?: {
  139367. blurred: PostProcess;
  139368. weight: number;
  139369. };
  139370. }
  139371. /**
  139372. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139373. */
  139374. export class DepthOfFieldMergePostProcess extends PostProcess {
  139375. private blurSteps;
  139376. /**
  139377. * Creates a new instance of DepthOfFieldMergePostProcess
  139378. * @param name The name of the effect.
  139379. * @param originalFromInput Post process which's input will be used for the merge.
  139380. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139381. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139382. * @param options The required width/height ratio to downsize to before computing the render pass.
  139383. * @param camera The camera to apply the render pass to.
  139384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139385. * @param engine The engine which the post process will be applied. (default: current engine)
  139386. * @param reusable If the post process can be reused on the same frame. (default: false)
  139387. * @param textureType Type of textures used when performing the post process. (default: 0)
  139388. * @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)
  139389. */
  139390. 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);
  139391. /**
  139392. * Updates the effect with the current post process compile time values and recompiles the shader.
  139393. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139394. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139395. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139396. * @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
  139397. * @param onCompiled Called when the shader has been compiled.
  139398. * @param onError Called if there is an error when compiling a shader.
  139399. */
  139400. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139401. }
  139402. }
  139403. declare module BABYLON {
  139404. /**
  139405. * Specifies the level of max blur that should be applied when using the depth of field effect
  139406. */
  139407. export enum DepthOfFieldEffectBlurLevel {
  139408. /**
  139409. * Subtle blur
  139410. */
  139411. Low = 0,
  139412. /**
  139413. * Medium blur
  139414. */
  139415. Medium = 1,
  139416. /**
  139417. * Large blur
  139418. */
  139419. High = 2
  139420. }
  139421. /**
  139422. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139423. */
  139424. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139425. private _circleOfConfusion;
  139426. /**
  139427. * @hidden Internal, blurs from high to low
  139428. */
  139429. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139430. private _depthOfFieldBlurY;
  139431. private _dofMerge;
  139432. /**
  139433. * @hidden Internal post processes in depth of field effect
  139434. */
  139435. _effects: Array<PostProcess>;
  139436. /**
  139437. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139438. */
  139439. set focalLength(value: number);
  139440. get focalLength(): number;
  139441. /**
  139442. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139443. */
  139444. set fStop(value: number);
  139445. get fStop(): number;
  139446. /**
  139447. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139448. */
  139449. set focusDistance(value: number);
  139450. get focusDistance(): number;
  139451. /**
  139452. * 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.
  139453. */
  139454. set lensSize(value: number);
  139455. get lensSize(): number;
  139456. /**
  139457. * Creates a new instance DepthOfFieldEffect
  139458. * @param scene The scene the effect belongs to.
  139459. * @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.
  139460. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139461. * @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)
  139462. */
  139463. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139464. /**
  139465. * Get the current class name of the current effet
  139466. * @returns "DepthOfFieldEffect"
  139467. */
  139468. getClassName(): string;
  139469. /**
  139470. * 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.
  139471. */
  139472. set depthTexture(value: RenderTargetTexture);
  139473. /**
  139474. * Disposes each of the internal effects for a given camera.
  139475. * @param camera The camera to dispose the effect on.
  139476. */
  139477. disposeEffects(camera: Camera): void;
  139478. /**
  139479. * @hidden Internal
  139480. */
  139481. _updateEffects(): void;
  139482. /**
  139483. * Internal
  139484. * @returns if all the contained post processes are ready.
  139485. * @hidden
  139486. */
  139487. _isReady(): boolean;
  139488. }
  139489. }
  139490. declare module BABYLON {
  139491. /** @hidden */
  139492. export var displayPassPixelShader: {
  139493. name: string;
  139494. shader: string;
  139495. };
  139496. }
  139497. declare module BABYLON {
  139498. /**
  139499. * DisplayPassPostProcess which produces an output the same as it's input
  139500. */
  139501. export class DisplayPassPostProcess extends PostProcess {
  139502. /**
  139503. * Creates the DisplayPassPostProcess
  139504. * @param name The name of the effect.
  139505. * @param options The required width/height ratio to downsize to before computing the render pass.
  139506. * @param camera The camera to apply the render pass to.
  139507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139508. * @param engine The engine which the post process will be applied. (default: current engine)
  139509. * @param reusable If the post process can be reused on the same frame. (default: false)
  139510. */
  139511. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139512. }
  139513. }
  139514. declare module BABYLON {
  139515. /** @hidden */
  139516. export var filterPixelShader: {
  139517. name: string;
  139518. shader: string;
  139519. };
  139520. }
  139521. declare module BABYLON {
  139522. /**
  139523. * Applies a kernel filter to the image
  139524. */
  139525. export class FilterPostProcess extends PostProcess {
  139526. /** The matrix to be applied to the image */
  139527. kernelMatrix: Matrix;
  139528. /**
  139529. *
  139530. * @param name The name of the effect.
  139531. * @param kernelMatrix The matrix to be applied to the image
  139532. * @param options The required width/height ratio to downsize to before computing the render pass.
  139533. * @param camera The camera to apply the render pass to.
  139534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139535. * @param engine The engine which the post process will be applied. (default: current engine)
  139536. * @param reusable If the post process can be reused on the same frame. (default: false)
  139537. */
  139538. constructor(name: string,
  139539. /** The matrix to be applied to the image */
  139540. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139541. }
  139542. }
  139543. declare module BABYLON {
  139544. /** @hidden */
  139545. export var fxaaPixelShader: {
  139546. name: string;
  139547. shader: string;
  139548. };
  139549. }
  139550. declare module BABYLON {
  139551. /** @hidden */
  139552. export var fxaaVertexShader: {
  139553. name: string;
  139554. shader: string;
  139555. };
  139556. }
  139557. declare module BABYLON {
  139558. /**
  139559. * Fxaa post process
  139560. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139561. */
  139562. export class FxaaPostProcess extends PostProcess {
  139563. /** @hidden */
  139564. texelWidth: number;
  139565. /** @hidden */
  139566. texelHeight: number;
  139567. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139568. private _getDefines;
  139569. }
  139570. }
  139571. declare module BABYLON {
  139572. /** @hidden */
  139573. export var grainPixelShader: {
  139574. name: string;
  139575. shader: string;
  139576. };
  139577. }
  139578. declare module BABYLON {
  139579. /**
  139580. * The GrainPostProcess adds noise to the image at mid luminance levels
  139581. */
  139582. export class GrainPostProcess extends PostProcess {
  139583. /**
  139584. * The intensity of the grain added (default: 30)
  139585. */
  139586. intensity: number;
  139587. /**
  139588. * If the grain should be randomized on every frame
  139589. */
  139590. animated: boolean;
  139591. /**
  139592. * Creates a new instance of @see GrainPostProcess
  139593. * @param name The name of the effect.
  139594. * @param options The required width/height ratio to downsize to before computing the render pass.
  139595. * @param camera The camera to apply the render pass to.
  139596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139597. * @param engine The engine which the post process will be applied. (default: current engine)
  139598. * @param reusable If the post process can be reused on the same frame. (default: false)
  139599. * @param textureType Type of textures used when performing the post process. (default: 0)
  139600. * @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)
  139601. */
  139602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139603. }
  139604. }
  139605. declare module BABYLON {
  139606. /** @hidden */
  139607. export var highlightsPixelShader: {
  139608. name: string;
  139609. shader: string;
  139610. };
  139611. }
  139612. declare module BABYLON {
  139613. /**
  139614. * Extracts highlights from the image
  139615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139616. */
  139617. export class HighlightsPostProcess extends PostProcess {
  139618. /**
  139619. * Extracts highlights from the image
  139620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139621. * @param name The name of the effect.
  139622. * @param options The required width/height ratio to downsize to before computing the render pass.
  139623. * @param camera The camera to apply the render pass to.
  139624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139625. * @param engine The engine which the post process will be applied. (default: current engine)
  139626. * @param reusable If the post process can be reused on the same frame. (default: false)
  139627. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139628. */
  139629. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139630. }
  139631. }
  139632. declare module BABYLON {
  139633. /** @hidden */
  139634. export var mrtFragmentDeclaration: {
  139635. name: string;
  139636. shader: string;
  139637. };
  139638. }
  139639. declare module BABYLON {
  139640. /** @hidden */
  139641. export var geometryPixelShader: {
  139642. name: string;
  139643. shader: string;
  139644. };
  139645. }
  139646. declare module BABYLON {
  139647. /** @hidden */
  139648. export var geometryVertexShader: {
  139649. name: string;
  139650. shader: string;
  139651. };
  139652. }
  139653. declare module BABYLON {
  139654. /** @hidden */
  139655. interface ISavedTransformationMatrix {
  139656. world: Matrix;
  139657. viewProjection: Matrix;
  139658. }
  139659. /**
  139660. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139661. */
  139662. export class GeometryBufferRenderer {
  139663. /**
  139664. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139665. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139666. */
  139667. static readonly POSITION_TEXTURE_TYPE: number;
  139668. /**
  139669. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139670. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139671. */
  139672. static readonly VELOCITY_TEXTURE_TYPE: number;
  139673. /**
  139674. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139675. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139676. */
  139677. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139678. /**
  139679. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139680. * in order to compute objects velocities when enableVelocity is set to "true"
  139681. * @hidden
  139682. */
  139683. _previousTransformationMatrices: {
  139684. [index: number]: ISavedTransformationMatrix;
  139685. };
  139686. /**
  139687. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139688. * in order to compute objects velocities when enableVelocity is set to "true"
  139689. * @hidden
  139690. */
  139691. _previousBonesTransformationMatrices: {
  139692. [index: number]: Float32Array;
  139693. };
  139694. /**
  139695. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139696. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139697. */
  139698. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139699. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139700. renderTransparentMeshes: boolean;
  139701. private _scene;
  139702. private _multiRenderTarget;
  139703. private _ratio;
  139704. private _enablePosition;
  139705. private _enableVelocity;
  139706. private _enableReflectivity;
  139707. private _positionIndex;
  139708. private _velocityIndex;
  139709. private _reflectivityIndex;
  139710. protected _effect: Effect;
  139711. protected _cachedDefines: string;
  139712. /**
  139713. * Set the render list (meshes to be rendered) used in the G buffer.
  139714. */
  139715. set renderList(meshes: Mesh[]);
  139716. /**
  139717. * Gets wether or not G buffer are supported by the running hardware.
  139718. * This requires draw buffer supports
  139719. */
  139720. get isSupported(): boolean;
  139721. /**
  139722. * Returns the index of the given texture type in the G-Buffer textures array
  139723. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139724. * @returns the index of the given texture type in the G-Buffer textures array
  139725. */
  139726. getTextureIndex(textureType: number): number;
  139727. /**
  139728. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139729. */
  139730. get enablePosition(): boolean;
  139731. /**
  139732. * Sets whether or not objects positions are enabled for the G buffer.
  139733. */
  139734. set enablePosition(enable: boolean);
  139735. /**
  139736. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139737. */
  139738. get enableVelocity(): boolean;
  139739. /**
  139740. * Sets wether or not objects velocities are enabled for the G buffer.
  139741. */
  139742. set enableVelocity(enable: boolean);
  139743. /**
  139744. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139745. */
  139746. get enableReflectivity(): boolean;
  139747. /**
  139748. * Sets wether or not objects roughness are enabled for the G buffer.
  139749. */
  139750. set enableReflectivity(enable: boolean);
  139751. /**
  139752. * Gets the scene associated with the buffer.
  139753. */
  139754. get scene(): Scene;
  139755. /**
  139756. * Gets the ratio used by the buffer during its creation.
  139757. * How big is the buffer related to the main canvas.
  139758. */
  139759. get ratio(): number;
  139760. /** @hidden */
  139761. static _SceneComponentInitialization: (scene: Scene) => void;
  139762. /**
  139763. * Creates a new G Buffer for the scene
  139764. * @param scene The scene the buffer belongs to
  139765. * @param ratio How big is the buffer related to the main canvas.
  139766. */
  139767. constructor(scene: Scene, ratio?: number);
  139768. /**
  139769. * Checks wether everything is ready to render a submesh to the G buffer.
  139770. * @param subMesh the submesh to check readiness for
  139771. * @param useInstances is the mesh drawn using instance or not
  139772. * @returns true if ready otherwise false
  139773. */
  139774. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139775. /**
  139776. * Gets the current underlying G Buffer.
  139777. * @returns the buffer
  139778. */
  139779. getGBuffer(): MultiRenderTarget;
  139780. /**
  139781. * Gets the number of samples used to render the buffer (anti aliasing).
  139782. */
  139783. get samples(): number;
  139784. /**
  139785. * Sets the number of samples used to render the buffer (anti aliasing).
  139786. */
  139787. set samples(value: number);
  139788. /**
  139789. * Disposes the renderer and frees up associated resources.
  139790. */
  139791. dispose(): void;
  139792. protected _createRenderTargets(): void;
  139793. private _copyBonesTransformationMatrices;
  139794. }
  139795. }
  139796. declare module BABYLON {
  139797. interface Scene {
  139798. /** @hidden (Backing field) */
  139799. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139800. /**
  139801. * Gets or Sets the current geometry buffer associated to the scene.
  139802. */
  139803. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139804. /**
  139805. * Enables a GeometryBufferRender and associates it with the scene
  139806. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139807. * @returns the GeometryBufferRenderer
  139808. */
  139809. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139810. /**
  139811. * Disables the GeometryBufferRender associated with the scene
  139812. */
  139813. disableGeometryBufferRenderer(): void;
  139814. }
  139815. /**
  139816. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139817. * in several rendering techniques.
  139818. */
  139819. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139820. /**
  139821. * The component name helpful to identify the component in the list of scene components.
  139822. */
  139823. readonly name: string;
  139824. /**
  139825. * The scene the component belongs to.
  139826. */
  139827. scene: Scene;
  139828. /**
  139829. * Creates a new instance of the component for the given scene
  139830. * @param scene Defines the scene to register the component in
  139831. */
  139832. constructor(scene: Scene);
  139833. /**
  139834. * Registers the component in a given scene
  139835. */
  139836. register(): void;
  139837. /**
  139838. * Rebuilds the elements related to this component in case of
  139839. * context lost for instance.
  139840. */
  139841. rebuild(): void;
  139842. /**
  139843. * Disposes the component and the associated ressources
  139844. */
  139845. dispose(): void;
  139846. private _gatherRenderTargets;
  139847. }
  139848. }
  139849. declare module BABYLON {
  139850. /** @hidden */
  139851. export var motionBlurPixelShader: {
  139852. name: string;
  139853. shader: string;
  139854. };
  139855. }
  139856. declare module BABYLON {
  139857. /**
  139858. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139859. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139860. * As an example, all you have to do is to create the post-process:
  139861. * var mb = new BABYLON.MotionBlurPostProcess(
  139862. * 'mb', // The name of the effect.
  139863. * scene, // The scene containing the objects to blur according to their velocity.
  139864. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139865. * camera // The camera to apply the render pass to.
  139866. * );
  139867. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139868. */
  139869. export class MotionBlurPostProcess extends PostProcess {
  139870. /**
  139871. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139872. */
  139873. motionStrength: number;
  139874. /**
  139875. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139876. */
  139877. get motionBlurSamples(): number;
  139878. /**
  139879. * Sets the number of iterations to be used for motion blur quality
  139880. */
  139881. set motionBlurSamples(samples: number);
  139882. private _motionBlurSamples;
  139883. private _geometryBufferRenderer;
  139884. /**
  139885. * Creates a new instance MotionBlurPostProcess
  139886. * @param name The name of the effect.
  139887. * @param scene The scene containing the objects to blur according to their velocity.
  139888. * @param options The required width/height ratio to downsize to before computing the render pass.
  139889. * @param camera The camera to apply the render pass to.
  139890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139891. * @param engine The engine which the post process will be applied. (default: current engine)
  139892. * @param reusable If the post process can be reused on the same frame. (default: false)
  139893. * @param textureType Type of textures used when performing the post process. (default: 0)
  139894. * @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)
  139895. */
  139896. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139897. /**
  139898. * Excludes the given skinned mesh from computing bones velocities.
  139899. * 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.
  139900. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139901. */
  139902. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139903. /**
  139904. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139905. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139906. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139907. */
  139908. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139909. /**
  139910. * Disposes the post process.
  139911. * @param camera The camera to dispose the post process on.
  139912. */
  139913. dispose(camera?: Camera): void;
  139914. }
  139915. }
  139916. declare module BABYLON {
  139917. /** @hidden */
  139918. export var refractionPixelShader: {
  139919. name: string;
  139920. shader: string;
  139921. };
  139922. }
  139923. declare module BABYLON {
  139924. /**
  139925. * Post process which applies a refractin texture
  139926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139927. */
  139928. export class RefractionPostProcess extends PostProcess {
  139929. /** the base color of the refraction (used to taint the rendering) */
  139930. color: Color3;
  139931. /** simulated refraction depth */
  139932. depth: number;
  139933. /** the coefficient of the base color (0 to remove base color tainting) */
  139934. colorLevel: number;
  139935. private _refTexture;
  139936. private _ownRefractionTexture;
  139937. /**
  139938. * Gets or sets the refraction texture
  139939. * Please note that you are responsible for disposing the texture if you set it manually
  139940. */
  139941. get refractionTexture(): Texture;
  139942. set refractionTexture(value: Texture);
  139943. /**
  139944. * Initializes the RefractionPostProcess
  139945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139946. * @param name The name of the effect.
  139947. * @param refractionTextureUrl Url of the refraction texture to use
  139948. * @param color the base color of the refraction (used to taint the rendering)
  139949. * @param depth simulated refraction depth
  139950. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139951. * @param camera The camera to apply the render pass to.
  139952. * @param options The required width/height ratio to downsize to before computing the render pass.
  139953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139954. * @param engine The engine which the post process will be applied. (default: current engine)
  139955. * @param reusable If the post process can be reused on the same frame. (default: false)
  139956. */
  139957. constructor(name: string, refractionTextureUrl: string,
  139958. /** the base color of the refraction (used to taint the rendering) */
  139959. color: Color3,
  139960. /** simulated refraction depth */
  139961. depth: number,
  139962. /** the coefficient of the base color (0 to remove base color tainting) */
  139963. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139964. /**
  139965. * Disposes of the post process
  139966. * @param camera Camera to dispose post process on
  139967. */
  139968. dispose(camera: Camera): void;
  139969. }
  139970. }
  139971. declare module BABYLON {
  139972. /** @hidden */
  139973. export var sharpenPixelShader: {
  139974. name: string;
  139975. shader: string;
  139976. };
  139977. }
  139978. declare module BABYLON {
  139979. /**
  139980. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139981. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139982. */
  139983. export class SharpenPostProcess extends PostProcess {
  139984. /**
  139985. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139986. */
  139987. colorAmount: number;
  139988. /**
  139989. * How much sharpness should be applied (default: 0.3)
  139990. */
  139991. edgeAmount: number;
  139992. /**
  139993. * Creates a new instance ConvolutionPostProcess
  139994. * @param name The name of the effect.
  139995. * @param options The required width/height ratio to downsize to before computing the render pass.
  139996. * @param camera The camera to apply the render pass to.
  139997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139998. * @param engine The engine which the post process will be applied. (default: current engine)
  139999. * @param reusable If the post process can be reused on the same frame. (default: false)
  140000. * @param textureType Type of textures used when performing the post process. (default: 0)
  140001. * @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)
  140002. */
  140003. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140004. }
  140005. }
  140006. declare module BABYLON {
  140007. /**
  140008. * PostProcessRenderPipeline
  140009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140010. */
  140011. export class PostProcessRenderPipeline {
  140012. private engine;
  140013. private _renderEffects;
  140014. private _renderEffectsForIsolatedPass;
  140015. /**
  140016. * List of inspectable custom properties (used by the Inspector)
  140017. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  140018. */
  140019. inspectableCustomProperties: IInspectable[];
  140020. /**
  140021. * @hidden
  140022. */
  140023. protected _cameras: Camera[];
  140024. /** @hidden */
  140025. _name: string;
  140026. /**
  140027. * Gets pipeline name
  140028. */
  140029. get name(): string;
  140030. /** Gets the list of attached cameras */
  140031. get cameras(): Camera[];
  140032. /**
  140033. * Initializes a PostProcessRenderPipeline
  140034. * @param engine engine to add the pipeline to
  140035. * @param name name of the pipeline
  140036. */
  140037. constructor(engine: Engine, name: string);
  140038. /**
  140039. * Gets the class name
  140040. * @returns "PostProcessRenderPipeline"
  140041. */
  140042. getClassName(): string;
  140043. /**
  140044. * If all the render effects in the pipeline are supported
  140045. */
  140046. get isSupported(): boolean;
  140047. /**
  140048. * Adds an effect to the pipeline
  140049. * @param renderEffect the effect to add
  140050. */
  140051. addEffect(renderEffect: PostProcessRenderEffect): void;
  140052. /** @hidden */
  140053. _rebuild(): void;
  140054. /** @hidden */
  140055. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140056. /** @hidden */
  140057. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140058. /** @hidden */
  140059. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140060. /** @hidden */
  140061. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140062. /** @hidden */
  140063. _attachCameras(cameras: Camera, unique: boolean): void;
  140064. /** @hidden */
  140065. _attachCameras(cameras: Camera[], unique: boolean): void;
  140066. /** @hidden */
  140067. _detachCameras(cameras: Camera): void;
  140068. /** @hidden */
  140069. _detachCameras(cameras: Nullable<Camera[]>): void;
  140070. /** @hidden */
  140071. _update(): void;
  140072. /** @hidden */
  140073. _reset(): void;
  140074. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140075. /**
  140076. * Disposes of the pipeline
  140077. */
  140078. dispose(): void;
  140079. }
  140080. }
  140081. declare module BABYLON {
  140082. /**
  140083. * PostProcessRenderPipelineManager class
  140084. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140085. */
  140086. export class PostProcessRenderPipelineManager {
  140087. private _renderPipelines;
  140088. /**
  140089. * Initializes a PostProcessRenderPipelineManager
  140090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140091. */
  140092. constructor();
  140093. /**
  140094. * Gets the list of supported render pipelines
  140095. */
  140096. get supportedPipelines(): PostProcessRenderPipeline[];
  140097. /**
  140098. * Adds a pipeline to the manager
  140099. * @param renderPipeline The pipeline to add
  140100. */
  140101. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140102. /**
  140103. * Attaches a camera to the pipeline
  140104. * @param renderPipelineName The name of the pipeline to attach to
  140105. * @param cameras the camera to attach
  140106. * @param unique if the camera can be attached multiple times to the pipeline
  140107. */
  140108. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140109. /**
  140110. * Detaches a camera from the pipeline
  140111. * @param renderPipelineName The name of the pipeline to detach from
  140112. * @param cameras the camera to detach
  140113. */
  140114. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140115. /**
  140116. * Enables an effect by name on a pipeline
  140117. * @param renderPipelineName the name of the pipeline to enable the effect in
  140118. * @param renderEffectName the name of the effect to enable
  140119. * @param cameras the cameras that the effect should be enabled on
  140120. */
  140121. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140122. /**
  140123. * Disables an effect by name on a pipeline
  140124. * @param renderPipelineName the name of the pipeline to disable the effect in
  140125. * @param renderEffectName the name of the effect to disable
  140126. * @param cameras the cameras that the effect should be disabled on
  140127. */
  140128. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140129. /**
  140130. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140131. */
  140132. update(): void;
  140133. /** @hidden */
  140134. _rebuild(): void;
  140135. /**
  140136. * Disposes of the manager and pipelines
  140137. */
  140138. dispose(): void;
  140139. }
  140140. }
  140141. declare module BABYLON {
  140142. interface Scene {
  140143. /** @hidden (Backing field) */
  140144. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140145. /**
  140146. * Gets the postprocess render pipeline manager
  140147. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140148. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140149. */
  140150. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140151. }
  140152. /**
  140153. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140154. */
  140155. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140156. /**
  140157. * The component name helpfull to identify the component in the list of scene components.
  140158. */
  140159. readonly name: string;
  140160. /**
  140161. * The scene the component belongs to.
  140162. */
  140163. scene: Scene;
  140164. /**
  140165. * Creates a new instance of the component for the given scene
  140166. * @param scene Defines the scene to register the component in
  140167. */
  140168. constructor(scene: Scene);
  140169. /**
  140170. * Registers the component in a given scene
  140171. */
  140172. register(): void;
  140173. /**
  140174. * Rebuilds the elements related to this component in case of
  140175. * context lost for instance.
  140176. */
  140177. rebuild(): void;
  140178. /**
  140179. * Disposes the component and the associated ressources
  140180. */
  140181. dispose(): void;
  140182. private _gatherRenderTargets;
  140183. }
  140184. }
  140185. declare module BABYLON {
  140186. /**
  140187. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140188. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140189. */
  140190. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140191. private _scene;
  140192. private _camerasToBeAttached;
  140193. /**
  140194. * ID of the sharpen post process,
  140195. */
  140196. private readonly SharpenPostProcessId;
  140197. /**
  140198. * @ignore
  140199. * ID of the image processing post process;
  140200. */
  140201. readonly ImageProcessingPostProcessId: string;
  140202. /**
  140203. * @ignore
  140204. * ID of the Fast Approximate Anti-Aliasing post process;
  140205. */
  140206. readonly FxaaPostProcessId: string;
  140207. /**
  140208. * ID of the chromatic aberration post process,
  140209. */
  140210. private readonly ChromaticAberrationPostProcessId;
  140211. /**
  140212. * ID of the grain post process
  140213. */
  140214. private readonly GrainPostProcessId;
  140215. /**
  140216. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140217. */
  140218. sharpen: SharpenPostProcess;
  140219. private _sharpenEffect;
  140220. private bloom;
  140221. /**
  140222. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140223. */
  140224. depthOfField: DepthOfFieldEffect;
  140225. /**
  140226. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140227. */
  140228. fxaa: FxaaPostProcess;
  140229. /**
  140230. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140231. */
  140232. imageProcessing: ImageProcessingPostProcess;
  140233. /**
  140234. * Chromatic aberration post process which will shift rgb colors in the image
  140235. */
  140236. chromaticAberration: ChromaticAberrationPostProcess;
  140237. private _chromaticAberrationEffect;
  140238. /**
  140239. * Grain post process which add noise to the image
  140240. */
  140241. grain: GrainPostProcess;
  140242. private _grainEffect;
  140243. /**
  140244. * Glow post process which adds a glow to emissive areas of the image
  140245. */
  140246. private _glowLayer;
  140247. /**
  140248. * Animations which can be used to tweak settings over a period of time
  140249. */
  140250. animations: Animation[];
  140251. private _imageProcessingConfigurationObserver;
  140252. private _sharpenEnabled;
  140253. private _bloomEnabled;
  140254. private _depthOfFieldEnabled;
  140255. private _depthOfFieldBlurLevel;
  140256. private _fxaaEnabled;
  140257. private _imageProcessingEnabled;
  140258. private _defaultPipelineTextureType;
  140259. private _bloomScale;
  140260. private _chromaticAberrationEnabled;
  140261. private _grainEnabled;
  140262. private _buildAllowed;
  140263. /**
  140264. * Gets active scene
  140265. */
  140266. get scene(): Scene;
  140267. /**
  140268. * Enable or disable the sharpen process from the pipeline
  140269. */
  140270. set sharpenEnabled(enabled: boolean);
  140271. get sharpenEnabled(): boolean;
  140272. private _resizeObserver;
  140273. private _hardwareScaleLevel;
  140274. private _bloomKernel;
  140275. /**
  140276. * Specifies the size of the bloom blur kernel, relative to the final output size
  140277. */
  140278. get bloomKernel(): number;
  140279. set bloomKernel(value: number);
  140280. /**
  140281. * Specifies the weight of the bloom in the final rendering
  140282. */
  140283. private _bloomWeight;
  140284. /**
  140285. * Specifies the luma threshold for the area that will be blurred by the bloom
  140286. */
  140287. private _bloomThreshold;
  140288. private _hdr;
  140289. /**
  140290. * The strength of the bloom.
  140291. */
  140292. set bloomWeight(value: number);
  140293. get bloomWeight(): number;
  140294. /**
  140295. * The strength of the bloom.
  140296. */
  140297. set bloomThreshold(value: number);
  140298. get bloomThreshold(): number;
  140299. /**
  140300. * The scale of the bloom, lower value will provide better performance.
  140301. */
  140302. set bloomScale(value: number);
  140303. get bloomScale(): number;
  140304. /**
  140305. * Enable or disable the bloom from the pipeline
  140306. */
  140307. set bloomEnabled(enabled: boolean);
  140308. get bloomEnabled(): boolean;
  140309. private _rebuildBloom;
  140310. /**
  140311. * If the depth of field is enabled.
  140312. */
  140313. get depthOfFieldEnabled(): boolean;
  140314. set depthOfFieldEnabled(enabled: boolean);
  140315. /**
  140316. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140317. */
  140318. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140319. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140320. /**
  140321. * If the anti aliasing is enabled.
  140322. */
  140323. set fxaaEnabled(enabled: boolean);
  140324. get fxaaEnabled(): boolean;
  140325. private _samples;
  140326. /**
  140327. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140328. */
  140329. set samples(sampleCount: number);
  140330. get samples(): number;
  140331. /**
  140332. * If image processing is enabled.
  140333. */
  140334. set imageProcessingEnabled(enabled: boolean);
  140335. get imageProcessingEnabled(): boolean;
  140336. /**
  140337. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140338. */
  140339. set glowLayerEnabled(enabled: boolean);
  140340. get glowLayerEnabled(): boolean;
  140341. /**
  140342. * Gets the glow layer (or null if not defined)
  140343. */
  140344. get glowLayer(): Nullable<GlowLayer>;
  140345. /**
  140346. * Enable or disable the chromaticAberration process from the pipeline
  140347. */
  140348. set chromaticAberrationEnabled(enabled: boolean);
  140349. get chromaticAberrationEnabled(): boolean;
  140350. /**
  140351. * Enable or disable the grain process from the pipeline
  140352. */
  140353. set grainEnabled(enabled: boolean);
  140354. get grainEnabled(): boolean;
  140355. /**
  140356. * @constructor
  140357. * @param name - The rendering pipeline name (default: "")
  140358. * @param hdr - If high dynamic range textures should be used (default: true)
  140359. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140360. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140361. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140362. */
  140363. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140364. /**
  140365. * Get the class name
  140366. * @returns "DefaultRenderingPipeline"
  140367. */
  140368. getClassName(): string;
  140369. /**
  140370. * Force the compilation of the entire pipeline.
  140371. */
  140372. prepare(): void;
  140373. private _hasCleared;
  140374. private _prevPostProcess;
  140375. private _prevPrevPostProcess;
  140376. private _setAutoClearAndTextureSharing;
  140377. private _depthOfFieldSceneObserver;
  140378. private _buildPipeline;
  140379. private _disposePostProcesses;
  140380. /**
  140381. * Adds a camera to the pipeline
  140382. * @param camera the camera to be added
  140383. */
  140384. addCamera(camera: Camera): void;
  140385. /**
  140386. * Removes a camera from the pipeline
  140387. * @param camera the camera to remove
  140388. */
  140389. removeCamera(camera: Camera): void;
  140390. /**
  140391. * Dispose of the pipeline and stop all post processes
  140392. */
  140393. dispose(): void;
  140394. /**
  140395. * Serialize the rendering pipeline (Used when exporting)
  140396. * @returns the serialized object
  140397. */
  140398. serialize(): any;
  140399. /**
  140400. * Parse the serialized pipeline
  140401. * @param source Source pipeline.
  140402. * @param scene The scene to load the pipeline to.
  140403. * @param rootUrl The URL of the serialized pipeline.
  140404. * @returns An instantiated pipeline from the serialized object.
  140405. */
  140406. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140407. }
  140408. }
  140409. declare module BABYLON {
  140410. /** @hidden */
  140411. export var lensHighlightsPixelShader: {
  140412. name: string;
  140413. shader: string;
  140414. };
  140415. }
  140416. declare module BABYLON {
  140417. /** @hidden */
  140418. export var depthOfFieldPixelShader: {
  140419. name: string;
  140420. shader: string;
  140421. };
  140422. }
  140423. declare module BABYLON {
  140424. /**
  140425. * BABYLON.JS Chromatic Aberration GLSL Shader
  140426. * Author: Olivier Guyot
  140427. * Separates very slightly R, G and B colors on the edges of the screen
  140428. * Inspired by Francois Tarlier & Martins Upitis
  140429. */
  140430. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140431. /**
  140432. * @ignore
  140433. * The chromatic aberration PostProcess id in the pipeline
  140434. */
  140435. LensChromaticAberrationEffect: string;
  140436. /**
  140437. * @ignore
  140438. * The highlights enhancing PostProcess id in the pipeline
  140439. */
  140440. HighlightsEnhancingEffect: string;
  140441. /**
  140442. * @ignore
  140443. * The depth-of-field PostProcess id in the pipeline
  140444. */
  140445. LensDepthOfFieldEffect: string;
  140446. private _scene;
  140447. private _depthTexture;
  140448. private _grainTexture;
  140449. private _chromaticAberrationPostProcess;
  140450. private _highlightsPostProcess;
  140451. private _depthOfFieldPostProcess;
  140452. private _edgeBlur;
  140453. private _grainAmount;
  140454. private _chromaticAberration;
  140455. private _distortion;
  140456. private _highlightsGain;
  140457. private _highlightsThreshold;
  140458. private _dofDistance;
  140459. private _dofAperture;
  140460. private _dofDarken;
  140461. private _dofPentagon;
  140462. private _blurNoise;
  140463. /**
  140464. * @constructor
  140465. *
  140466. * Effect parameters are as follow:
  140467. * {
  140468. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140469. * edge_blur: number; // from 0 to x (1 for realism)
  140470. * distortion: number; // from 0 to x (1 for realism)
  140471. * grain_amount: number; // from 0 to 1
  140472. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140473. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140474. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140475. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140476. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140477. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140478. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140479. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140480. * }
  140481. * Note: if an effect parameter is unset, effect is disabled
  140482. *
  140483. * @param name The rendering pipeline name
  140484. * @param parameters - An object containing all parameters (see above)
  140485. * @param scene The scene linked to this pipeline
  140486. * @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)
  140487. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140488. */
  140489. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140490. /**
  140491. * Get the class name
  140492. * @returns "LensRenderingPipeline"
  140493. */
  140494. getClassName(): string;
  140495. /**
  140496. * Gets associated scene
  140497. */
  140498. get scene(): Scene;
  140499. /**
  140500. * Gets or sets the edge blur
  140501. */
  140502. get edgeBlur(): number;
  140503. set edgeBlur(value: number);
  140504. /**
  140505. * Gets or sets the grain amount
  140506. */
  140507. get grainAmount(): number;
  140508. set grainAmount(value: number);
  140509. /**
  140510. * Gets or sets the chromatic aberration amount
  140511. */
  140512. get chromaticAberration(): number;
  140513. set chromaticAberration(value: number);
  140514. /**
  140515. * Gets or sets the depth of field aperture
  140516. */
  140517. get dofAperture(): number;
  140518. set dofAperture(value: number);
  140519. /**
  140520. * Gets or sets the edge distortion
  140521. */
  140522. get edgeDistortion(): number;
  140523. set edgeDistortion(value: number);
  140524. /**
  140525. * Gets or sets the depth of field distortion
  140526. */
  140527. get dofDistortion(): number;
  140528. set dofDistortion(value: number);
  140529. /**
  140530. * Gets or sets the darken out of focus amount
  140531. */
  140532. get darkenOutOfFocus(): number;
  140533. set darkenOutOfFocus(value: number);
  140534. /**
  140535. * Gets or sets a boolean indicating if blur noise is enabled
  140536. */
  140537. get blurNoise(): boolean;
  140538. set blurNoise(value: boolean);
  140539. /**
  140540. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140541. */
  140542. get pentagonBokeh(): boolean;
  140543. set pentagonBokeh(value: boolean);
  140544. /**
  140545. * Gets or sets the highlight grain amount
  140546. */
  140547. get highlightsGain(): number;
  140548. set highlightsGain(value: number);
  140549. /**
  140550. * Gets or sets the highlight threshold
  140551. */
  140552. get highlightsThreshold(): number;
  140553. set highlightsThreshold(value: number);
  140554. /**
  140555. * Sets the amount of blur at the edges
  140556. * @param amount blur amount
  140557. */
  140558. setEdgeBlur(amount: number): void;
  140559. /**
  140560. * Sets edge blur to 0
  140561. */
  140562. disableEdgeBlur(): void;
  140563. /**
  140564. * Sets the amout of grain
  140565. * @param amount Amount of grain
  140566. */
  140567. setGrainAmount(amount: number): void;
  140568. /**
  140569. * Set grain amount to 0
  140570. */
  140571. disableGrain(): void;
  140572. /**
  140573. * Sets the chromatic aberration amount
  140574. * @param amount amount of chromatic aberration
  140575. */
  140576. setChromaticAberration(amount: number): void;
  140577. /**
  140578. * Sets chromatic aberration amount to 0
  140579. */
  140580. disableChromaticAberration(): void;
  140581. /**
  140582. * Sets the EdgeDistortion amount
  140583. * @param amount amount of EdgeDistortion
  140584. */
  140585. setEdgeDistortion(amount: number): void;
  140586. /**
  140587. * Sets edge distortion to 0
  140588. */
  140589. disableEdgeDistortion(): void;
  140590. /**
  140591. * Sets the FocusDistance amount
  140592. * @param amount amount of FocusDistance
  140593. */
  140594. setFocusDistance(amount: number): void;
  140595. /**
  140596. * Disables depth of field
  140597. */
  140598. disableDepthOfField(): void;
  140599. /**
  140600. * Sets the Aperture amount
  140601. * @param amount amount of Aperture
  140602. */
  140603. setAperture(amount: number): void;
  140604. /**
  140605. * Sets the DarkenOutOfFocus amount
  140606. * @param amount amount of DarkenOutOfFocus
  140607. */
  140608. setDarkenOutOfFocus(amount: number): void;
  140609. private _pentagonBokehIsEnabled;
  140610. /**
  140611. * Creates a pentagon bokeh effect
  140612. */
  140613. enablePentagonBokeh(): void;
  140614. /**
  140615. * Disables the pentagon bokeh effect
  140616. */
  140617. disablePentagonBokeh(): void;
  140618. /**
  140619. * Enables noise blur
  140620. */
  140621. enableNoiseBlur(): void;
  140622. /**
  140623. * Disables noise blur
  140624. */
  140625. disableNoiseBlur(): void;
  140626. /**
  140627. * Sets the HighlightsGain amount
  140628. * @param amount amount of HighlightsGain
  140629. */
  140630. setHighlightsGain(amount: number): void;
  140631. /**
  140632. * Sets the HighlightsThreshold amount
  140633. * @param amount amount of HighlightsThreshold
  140634. */
  140635. setHighlightsThreshold(amount: number): void;
  140636. /**
  140637. * Disables highlights
  140638. */
  140639. disableHighlights(): void;
  140640. /**
  140641. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140642. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140643. */
  140644. dispose(disableDepthRender?: boolean): void;
  140645. private _createChromaticAberrationPostProcess;
  140646. private _createHighlightsPostProcess;
  140647. private _createDepthOfFieldPostProcess;
  140648. private _createGrainTexture;
  140649. }
  140650. }
  140651. declare module BABYLON {
  140652. /** @hidden */
  140653. export var ssao2PixelShader: {
  140654. name: string;
  140655. shader: string;
  140656. };
  140657. }
  140658. declare module BABYLON {
  140659. /** @hidden */
  140660. export var ssaoCombinePixelShader: {
  140661. name: string;
  140662. shader: string;
  140663. };
  140664. }
  140665. declare module BABYLON {
  140666. /**
  140667. * Render pipeline to produce ssao effect
  140668. */
  140669. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140670. /**
  140671. * @ignore
  140672. * The PassPostProcess id in the pipeline that contains the original scene color
  140673. */
  140674. SSAOOriginalSceneColorEffect: string;
  140675. /**
  140676. * @ignore
  140677. * The SSAO PostProcess id in the pipeline
  140678. */
  140679. SSAORenderEffect: string;
  140680. /**
  140681. * @ignore
  140682. * The horizontal blur PostProcess id in the pipeline
  140683. */
  140684. SSAOBlurHRenderEffect: string;
  140685. /**
  140686. * @ignore
  140687. * The vertical blur PostProcess id in the pipeline
  140688. */
  140689. SSAOBlurVRenderEffect: string;
  140690. /**
  140691. * @ignore
  140692. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140693. */
  140694. SSAOCombineRenderEffect: string;
  140695. /**
  140696. * The output strength of the SSAO post-process. Default value is 1.0.
  140697. */
  140698. totalStrength: number;
  140699. /**
  140700. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140701. */
  140702. maxZ: number;
  140703. /**
  140704. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140705. */
  140706. minZAspect: number;
  140707. private _samples;
  140708. /**
  140709. * Number of samples used for the SSAO calculations. Default value is 8
  140710. */
  140711. set samples(n: number);
  140712. get samples(): number;
  140713. private _textureSamples;
  140714. /**
  140715. * Number of samples to use for antialiasing
  140716. */
  140717. set textureSamples(n: number);
  140718. get textureSamples(): number;
  140719. /**
  140720. * Ratio object used for SSAO ratio and blur ratio
  140721. */
  140722. private _ratio;
  140723. /**
  140724. * Dynamically generated sphere sampler.
  140725. */
  140726. private _sampleSphere;
  140727. /**
  140728. * Blur filter offsets
  140729. */
  140730. private _samplerOffsets;
  140731. private _expensiveBlur;
  140732. /**
  140733. * If bilateral blur should be used
  140734. */
  140735. set expensiveBlur(b: boolean);
  140736. get expensiveBlur(): boolean;
  140737. /**
  140738. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140739. */
  140740. radius: number;
  140741. /**
  140742. * The base color of the SSAO post-process
  140743. * The final result is "base + ssao" between [0, 1]
  140744. */
  140745. base: number;
  140746. /**
  140747. * Support test.
  140748. */
  140749. static get IsSupported(): boolean;
  140750. private _scene;
  140751. private _depthTexture;
  140752. private _normalTexture;
  140753. private _randomTexture;
  140754. private _originalColorPostProcess;
  140755. private _ssaoPostProcess;
  140756. private _blurHPostProcess;
  140757. private _blurVPostProcess;
  140758. private _ssaoCombinePostProcess;
  140759. /**
  140760. * Gets active scene
  140761. */
  140762. get scene(): Scene;
  140763. /**
  140764. * @constructor
  140765. * @param name The rendering pipeline name
  140766. * @param scene The scene linked to this pipeline
  140767. * @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 }
  140768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140769. */
  140770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140771. /**
  140772. * Get the class name
  140773. * @returns "SSAO2RenderingPipeline"
  140774. */
  140775. getClassName(): string;
  140776. /**
  140777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140778. */
  140779. dispose(disableGeometryBufferRenderer?: boolean): void;
  140780. private _createBlurPostProcess;
  140781. /** @hidden */
  140782. _rebuild(): void;
  140783. private _bits;
  140784. private _radicalInverse_VdC;
  140785. private _hammersley;
  140786. private _hemisphereSample_uniform;
  140787. private _generateHemisphere;
  140788. private _createSSAOPostProcess;
  140789. private _createSSAOCombinePostProcess;
  140790. private _createRandomTexture;
  140791. /**
  140792. * Serialize the rendering pipeline (Used when exporting)
  140793. * @returns the serialized object
  140794. */
  140795. serialize(): any;
  140796. /**
  140797. * Parse the serialized pipeline
  140798. * @param source Source pipeline.
  140799. * @param scene The scene to load the pipeline to.
  140800. * @param rootUrl The URL of the serialized pipeline.
  140801. * @returns An instantiated pipeline from the serialized object.
  140802. */
  140803. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140804. }
  140805. }
  140806. declare module BABYLON {
  140807. /** @hidden */
  140808. export var ssaoPixelShader: {
  140809. name: string;
  140810. shader: string;
  140811. };
  140812. }
  140813. declare module BABYLON {
  140814. /**
  140815. * Render pipeline to produce ssao effect
  140816. */
  140817. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140818. /**
  140819. * @ignore
  140820. * The PassPostProcess id in the pipeline that contains the original scene color
  140821. */
  140822. SSAOOriginalSceneColorEffect: string;
  140823. /**
  140824. * @ignore
  140825. * The SSAO PostProcess id in the pipeline
  140826. */
  140827. SSAORenderEffect: string;
  140828. /**
  140829. * @ignore
  140830. * The horizontal blur PostProcess id in the pipeline
  140831. */
  140832. SSAOBlurHRenderEffect: string;
  140833. /**
  140834. * @ignore
  140835. * The vertical blur PostProcess id in the pipeline
  140836. */
  140837. SSAOBlurVRenderEffect: string;
  140838. /**
  140839. * @ignore
  140840. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140841. */
  140842. SSAOCombineRenderEffect: string;
  140843. /**
  140844. * The output strength of the SSAO post-process. Default value is 1.0.
  140845. */
  140846. totalStrength: number;
  140847. /**
  140848. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140849. */
  140850. radius: number;
  140851. /**
  140852. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140853. * Must not be equal to fallOff and superior to fallOff.
  140854. * Default value is 0.0075
  140855. */
  140856. area: number;
  140857. /**
  140858. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140859. * Must not be equal to area and inferior to area.
  140860. * Default value is 0.000001
  140861. */
  140862. fallOff: number;
  140863. /**
  140864. * The base color of the SSAO post-process
  140865. * The final result is "base + ssao" between [0, 1]
  140866. */
  140867. base: number;
  140868. private _scene;
  140869. private _depthTexture;
  140870. private _randomTexture;
  140871. private _originalColorPostProcess;
  140872. private _ssaoPostProcess;
  140873. private _blurHPostProcess;
  140874. private _blurVPostProcess;
  140875. private _ssaoCombinePostProcess;
  140876. private _firstUpdate;
  140877. /**
  140878. * Gets active scene
  140879. */
  140880. get scene(): Scene;
  140881. /**
  140882. * @constructor
  140883. * @param name - The rendering pipeline name
  140884. * @param scene - The scene linked to this pipeline
  140885. * @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 }
  140886. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140887. */
  140888. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140889. /**
  140890. * Get the class name
  140891. * @returns "SSAORenderingPipeline"
  140892. */
  140893. getClassName(): string;
  140894. /**
  140895. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140896. */
  140897. dispose(disableDepthRender?: boolean): void;
  140898. private _createBlurPostProcess;
  140899. /** @hidden */
  140900. _rebuild(): void;
  140901. private _createSSAOPostProcess;
  140902. private _createSSAOCombinePostProcess;
  140903. private _createRandomTexture;
  140904. }
  140905. }
  140906. declare module BABYLON {
  140907. /** @hidden */
  140908. export var screenSpaceReflectionPixelShader: {
  140909. name: string;
  140910. shader: string;
  140911. };
  140912. }
  140913. declare module BABYLON {
  140914. /**
  140915. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140916. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140917. */
  140918. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140919. /**
  140920. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140921. */
  140922. threshold: number;
  140923. /**
  140924. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140925. */
  140926. strength: number;
  140927. /**
  140928. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140929. */
  140930. reflectionSpecularFalloffExponent: number;
  140931. /**
  140932. * 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]
  140933. */
  140934. step: number;
  140935. /**
  140936. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140937. */
  140938. roughnessFactor: number;
  140939. private _geometryBufferRenderer;
  140940. private _enableSmoothReflections;
  140941. private _reflectionSamples;
  140942. private _smoothSteps;
  140943. /**
  140944. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140945. * @param name The name of the effect.
  140946. * @param scene The scene containing the objects to calculate reflections.
  140947. * @param options The required width/height ratio to downsize to before computing the render pass.
  140948. * @param camera The camera to apply the render pass to.
  140949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140950. * @param engine The engine which the post process will be applied. (default: current engine)
  140951. * @param reusable If the post process can be reused on the same frame. (default: false)
  140952. * @param textureType Type of textures used when performing the post process. (default: 0)
  140953. * @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)
  140954. */
  140955. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140956. /**
  140957. * Gets wether or not smoothing reflections is enabled.
  140958. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140959. */
  140960. get enableSmoothReflections(): boolean;
  140961. /**
  140962. * Sets wether or not smoothing reflections is enabled.
  140963. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140964. */
  140965. set enableSmoothReflections(enabled: boolean);
  140966. /**
  140967. * Gets the number of samples taken while computing reflections. More samples count is high,
  140968. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140969. */
  140970. get reflectionSamples(): number;
  140971. /**
  140972. * Sets the number of samples taken while computing reflections. More samples count is high,
  140973. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140974. */
  140975. set reflectionSamples(samples: number);
  140976. /**
  140977. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140978. * more the post-process will require GPU power and can generate a drop in FPS.
  140979. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140980. */
  140981. get smoothSteps(): number;
  140982. set smoothSteps(steps: number);
  140983. private _updateEffectDefines;
  140984. }
  140985. }
  140986. declare module BABYLON {
  140987. /** @hidden */
  140988. export var standardPixelShader: {
  140989. name: string;
  140990. shader: string;
  140991. };
  140992. }
  140993. declare module BABYLON {
  140994. /**
  140995. * Standard rendering pipeline
  140996. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140997. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140998. */
  140999. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  141000. /**
  141001. * Public members
  141002. */
  141003. /**
  141004. * Post-process which contains the original scene color before the pipeline applies all the effects
  141005. */
  141006. originalPostProcess: Nullable<PostProcess>;
  141007. /**
  141008. * Post-process used to down scale an image x4
  141009. */
  141010. downSampleX4PostProcess: Nullable<PostProcess>;
  141011. /**
  141012. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  141013. */
  141014. brightPassPostProcess: Nullable<PostProcess>;
  141015. /**
  141016. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  141017. */
  141018. blurHPostProcesses: PostProcess[];
  141019. /**
  141020. * Post-process array storing all the vertical blur post-processes used by the pipeline
  141021. */
  141022. blurVPostProcesses: PostProcess[];
  141023. /**
  141024. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  141025. */
  141026. textureAdderPostProcess: Nullable<PostProcess>;
  141027. /**
  141028. * Post-process used to create volumetric lighting effect
  141029. */
  141030. volumetricLightPostProcess: Nullable<PostProcess>;
  141031. /**
  141032. * Post-process used to smooth the previous volumetric light post-process on the X axis
  141033. */
  141034. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  141035. /**
  141036. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  141037. */
  141038. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  141039. /**
  141040. * Post-process used to merge the volumetric light effect and the real scene color
  141041. */
  141042. volumetricLightMergePostProces: Nullable<PostProcess>;
  141043. /**
  141044. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141045. */
  141046. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141047. /**
  141048. * Base post-process used to calculate the average luminance of the final image for HDR
  141049. */
  141050. luminancePostProcess: Nullable<PostProcess>;
  141051. /**
  141052. * Post-processes used to create down sample post-processes in order to get
  141053. * the average luminance of the final image for HDR
  141054. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141055. */
  141056. luminanceDownSamplePostProcesses: PostProcess[];
  141057. /**
  141058. * Post-process used to create a HDR effect (light adaptation)
  141059. */
  141060. hdrPostProcess: Nullable<PostProcess>;
  141061. /**
  141062. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141063. */
  141064. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141065. /**
  141066. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141067. */
  141068. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141069. /**
  141070. * Post-process used to merge the final HDR post-process and the real scene color
  141071. */
  141072. hdrFinalPostProcess: Nullable<PostProcess>;
  141073. /**
  141074. * Post-process used to create a lens flare effect
  141075. */
  141076. lensFlarePostProcess: Nullable<PostProcess>;
  141077. /**
  141078. * Post-process that merges the result of the lens flare post-process and the real scene color
  141079. */
  141080. lensFlareComposePostProcess: Nullable<PostProcess>;
  141081. /**
  141082. * Post-process used to create a motion blur effect
  141083. */
  141084. motionBlurPostProcess: Nullable<PostProcess>;
  141085. /**
  141086. * Post-process used to create a depth of field effect
  141087. */
  141088. depthOfFieldPostProcess: Nullable<PostProcess>;
  141089. /**
  141090. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141091. */
  141092. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141093. /**
  141094. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141095. */
  141096. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141097. /**
  141098. * Represents the brightness threshold in order to configure the illuminated surfaces
  141099. */
  141100. brightThreshold: number;
  141101. /**
  141102. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141103. */
  141104. blurWidth: number;
  141105. /**
  141106. * Sets if the blur for highlighted surfaces must be only horizontal
  141107. */
  141108. horizontalBlur: boolean;
  141109. /**
  141110. * Gets the overall exposure used by the pipeline
  141111. */
  141112. get exposure(): number;
  141113. /**
  141114. * Sets the overall exposure used by the pipeline
  141115. */
  141116. set exposure(value: number);
  141117. /**
  141118. * Texture used typically to simulate "dirty" on camera lens
  141119. */
  141120. lensTexture: Nullable<Texture>;
  141121. /**
  141122. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141123. */
  141124. volumetricLightCoefficient: number;
  141125. /**
  141126. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141127. */
  141128. volumetricLightPower: number;
  141129. /**
  141130. * Used the set the blur intensity to smooth the volumetric lights
  141131. */
  141132. volumetricLightBlurScale: number;
  141133. /**
  141134. * Light (spot or directional) used to generate the volumetric lights rays
  141135. * The source light must have a shadow generate so the pipeline can get its
  141136. * depth map
  141137. */
  141138. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141139. /**
  141140. * For eye adaptation, represents the minimum luminance the eye can see
  141141. */
  141142. hdrMinimumLuminance: number;
  141143. /**
  141144. * For eye adaptation, represents the decrease luminance speed
  141145. */
  141146. hdrDecreaseRate: number;
  141147. /**
  141148. * For eye adaptation, represents the increase luminance speed
  141149. */
  141150. hdrIncreaseRate: number;
  141151. /**
  141152. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141153. */
  141154. get hdrAutoExposure(): boolean;
  141155. /**
  141156. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141157. */
  141158. set hdrAutoExposure(value: boolean);
  141159. /**
  141160. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141161. */
  141162. lensColorTexture: Nullable<Texture>;
  141163. /**
  141164. * The overall strengh for the lens flare effect
  141165. */
  141166. lensFlareStrength: number;
  141167. /**
  141168. * Dispersion coefficient for lens flare ghosts
  141169. */
  141170. lensFlareGhostDispersal: number;
  141171. /**
  141172. * Main lens flare halo width
  141173. */
  141174. lensFlareHaloWidth: number;
  141175. /**
  141176. * Based on the lens distortion effect, defines how much the lens flare result
  141177. * is distorted
  141178. */
  141179. lensFlareDistortionStrength: number;
  141180. /**
  141181. * Configures the blur intensity used for for lens flare (halo)
  141182. */
  141183. lensFlareBlurWidth: number;
  141184. /**
  141185. * Lens star texture must be used to simulate rays on the flares and is available
  141186. * in the documentation
  141187. */
  141188. lensStarTexture: Nullable<Texture>;
  141189. /**
  141190. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141191. * flare effect by taking account of the dirt texture
  141192. */
  141193. lensFlareDirtTexture: Nullable<Texture>;
  141194. /**
  141195. * Represents the focal length for the depth of field effect
  141196. */
  141197. depthOfFieldDistance: number;
  141198. /**
  141199. * Represents the blur intensity for the blurred part of the depth of field effect
  141200. */
  141201. depthOfFieldBlurWidth: number;
  141202. /**
  141203. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141204. */
  141205. get motionStrength(): number;
  141206. /**
  141207. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141208. */
  141209. set motionStrength(strength: number);
  141210. /**
  141211. * Gets wether or not the motion blur post-process is object based or screen based.
  141212. */
  141213. get objectBasedMotionBlur(): boolean;
  141214. /**
  141215. * Sets wether or not the motion blur post-process should be object based or screen based
  141216. */
  141217. set objectBasedMotionBlur(value: boolean);
  141218. /**
  141219. * List of animations for the pipeline (IAnimatable implementation)
  141220. */
  141221. animations: Animation[];
  141222. /**
  141223. * Private members
  141224. */
  141225. private _scene;
  141226. private _currentDepthOfFieldSource;
  141227. private _basePostProcess;
  141228. private _fixedExposure;
  141229. private _currentExposure;
  141230. private _hdrAutoExposure;
  141231. private _hdrCurrentLuminance;
  141232. private _motionStrength;
  141233. private _isObjectBasedMotionBlur;
  141234. private _floatTextureType;
  141235. private _camerasToBeAttached;
  141236. private _ratio;
  141237. private _bloomEnabled;
  141238. private _depthOfFieldEnabled;
  141239. private _vlsEnabled;
  141240. private _lensFlareEnabled;
  141241. private _hdrEnabled;
  141242. private _motionBlurEnabled;
  141243. private _fxaaEnabled;
  141244. private _screenSpaceReflectionsEnabled;
  141245. private _motionBlurSamples;
  141246. private _volumetricLightStepsCount;
  141247. private _samples;
  141248. /**
  141249. * @ignore
  141250. * Specifies if the bloom pipeline is enabled
  141251. */
  141252. get BloomEnabled(): boolean;
  141253. set BloomEnabled(enabled: boolean);
  141254. /**
  141255. * @ignore
  141256. * Specifies if the depth of field pipeline is enabed
  141257. */
  141258. get DepthOfFieldEnabled(): boolean;
  141259. set DepthOfFieldEnabled(enabled: boolean);
  141260. /**
  141261. * @ignore
  141262. * Specifies if the lens flare pipeline is enabed
  141263. */
  141264. get LensFlareEnabled(): boolean;
  141265. set LensFlareEnabled(enabled: boolean);
  141266. /**
  141267. * @ignore
  141268. * Specifies if the HDR pipeline is enabled
  141269. */
  141270. get HDREnabled(): boolean;
  141271. set HDREnabled(enabled: boolean);
  141272. /**
  141273. * @ignore
  141274. * Specifies if the volumetric lights scattering effect is enabled
  141275. */
  141276. get VLSEnabled(): boolean;
  141277. set VLSEnabled(enabled: boolean);
  141278. /**
  141279. * @ignore
  141280. * Specifies if the motion blur effect is enabled
  141281. */
  141282. get MotionBlurEnabled(): boolean;
  141283. set MotionBlurEnabled(enabled: boolean);
  141284. /**
  141285. * Specifies if anti-aliasing is enabled
  141286. */
  141287. get fxaaEnabled(): boolean;
  141288. set fxaaEnabled(enabled: boolean);
  141289. /**
  141290. * Specifies if screen space reflections are enabled.
  141291. */
  141292. get screenSpaceReflectionsEnabled(): boolean;
  141293. set screenSpaceReflectionsEnabled(enabled: boolean);
  141294. /**
  141295. * Specifies the number of steps used to calculate the volumetric lights
  141296. * Typically in interval [50, 200]
  141297. */
  141298. get volumetricLightStepsCount(): number;
  141299. set volumetricLightStepsCount(count: number);
  141300. /**
  141301. * Specifies the number of samples used for the motion blur effect
  141302. * Typically in interval [16, 64]
  141303. */
  141304. get motionBlurSamples(): number;
  141305. set motionBlurSamples(samples: number);
  141306. /**
  141307. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141308. */
  141309. get samples(): number;
  141310. set samples(sampleCount: number);
  141311. /**
  141312. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141313. * @constructor
  141314. * @param name The rendering pipeline name
  141315. * @param scene The scene linked to this pipeline
  141316. * @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)
  141317. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141318. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141319. */
  141320. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141321. private _buildPipeline;
  141322. private _createDownSampleX4PostProcess;
  141323. private _createBrightPassPostProcess;
  141324. private _createBlurPostProcesses;
  141325. private _createTextureAdderPostProcess;
  141326. private _createVolumetricLightPostProcess;
  141327. private _createLuminancePostProcesses;
  141328. private _createHdrPostProcess;
  141329. private _createLensFlarePostProcess;
  141330. private _createDepthOfFieldPostProcess;
  141331. private _createMotionBlurPostProcess;
  141332. private _getDepthTexture;
  141333. private _disposePostProcesses;
  141334. /**
  141335. * Dispose of the pipeline and stop all post processes
  141336. */
  141337. dispose(): void;
  141338. /**
  141339. * Serialize the rendering pipeline (Used when exporting)
  141340. * @returns the serialized object
  141341. */
  141342. serialize(): any;
  141343. /**
  141344. * Parse the serialized pipeline
  141345. * @param source Source pipeline.
  141346. * @param scene The scene to load the pipeline to.
  141347. * @param rootUrl The URL of the serialized pipeline.
  141348. * @returns An instantiated pipeline from the serialized object.
  141349. */
  141350. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141351. /**
  141352. * Luminance steps
  141353. */
  141354. static LuminanceSteps: number;
  141355. }
  141356. }
  141357. declare module BABYLON {
  141358. /** @hidden */
  141359. export var tonemapPixelShader: {
  141360. name: string;
  141361. shader: string;
  141362. };
  141363. }
  141364. declare module BABYLON {
  141365. /** Defines operator used for tonemapping */
  141366. export enum TonemappingOperator {
  141367. /** Hable */
  141368. Hable = 0,
  141369. /** Reinhard */
  141370. Reinhard = 1,
  141371. /** HejiDawson */
  141372. HejiDawson = 2,
  141373. /** Photographic */
  141374. Photographic = 3
  141375. }
  141376. /**
  141377. * Defines a post process to apply tone mapping
  141378. */
  141379. export class TonemapPostProcess extends PostProcess {
  141380. private _operator;
  141381. /** Defines the required exposure adjustement */
  141382. exposureAdjustment: number;
  141383. /**
  141384. * Creates a new TonemapPostProcess
  141385. * @param name defines the name of the postprocess
  141386. * @param _operator defines the operator to use
  141387. * @param exposureAdjustment defines the required exposure adjustement
  141388. * @param camera defines the camera to use (can be null)
  141389. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141390. * @param engine defines the hosting engine (can be ignore if camera is set)
  141391. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141392. */
  141393. constructor(name: string, _operator: TonemappingOperator,
  141394. /** Defines the required exposure adjustement */
  141395. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141396. }
  141397. }
  141398. declare module BABYLON {
  141399. /** @hidden */
  141400. export var volumetricLightScatteringPixelShader: {
  141401. name: string;
  141402. shader: string;
  141403. };
  141404. }
  141405. declare module BABYLON {
  141406. /** @hidden */
  141407. export var volumetricLightScatteringPassVertexShader: {
  141408. name: string;
  141409. shader: string;
  141410. };
  141411. }
  141412. declare module BABYLON {
  141413. /** @hidden */
  141414. export var volumetricLightScatteringPassPixelShader: {
  141415. name: string;
  141416. shader: string;
  141417. };
  141418. }
  141419. declare module BABYLON {
  141420. /**
  141421. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141422. */
  141423. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141424. private _volumetricLightScatteringPass;
  141425. private _volumetricLightScatteringRTT;
  141426. private _viewPort;
  141427. private _screenCoordinates;
  141428. private _cachedDefines;
  141429. /**
  141430. * If not undefined, the mesh position is computed from the attached node position
  141431. */
  141432. attachedNode: {
  141433. position: Vector3;
  141434. };
  141435. /**
  141436. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141437. */
  141438. customMeshPosition: Vector3;
  141439. /**
  141440. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141441. */
  141442. useCustomMeshPosition: boolean;
  141443. /**
  141444. * If the post-process should inverse the light scattering direction
  141445. */
  141446. invert: boolean;
  141447. /**
  141448. * The internal mesh used by the post-process
  141449. */
  141450. mesh: Mesh;
  141451. /**
  141452. * @hidden
  141453. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141454. */
  141455. get useDiffuseColor(): boolean;
  141456. set useDiffuseColor(useDiffuseColor: boolean);
  141457. /**
  141458. * Array containing the excluded meshes not rendered in the internal pass
  141459. */
  141460. excludedMeshes: AbstractMesh[];
  141461. /**
  141462. * Controls the overall intensity of the post-process
  141463. */
  141464. exposure: number;
  141465. /**
  141466. * Dissipates each sample's contribution in range [0, 1]
  141467. */
  141468. decay: number;
  141469. /**
  141470. * Controls the overall intensity of each sample
  141471. */
  141472. weight: number;
  141473. /**
  141474. * Controls the density of each sample
  141475. */
  141476. density: number;
  141477. /**
  141478. * @constructor
  141479. * @param name The post-process name
  141480. * @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)
  141481. * @param camera The camera that the post-process will be attached to
  141482. * @param mesh The mesh used to create the light scattering
  141483. * @param samples The post-process quality, default 100
  141484. * @param samplingModeThe post-process filtering mode
  141485. * @param engine The babylon engine
  141486. * @param reusable If the post-process is reusable
  141487. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141488. */
  141489. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141490. /**
  141491. * Returns the string "VolumetricLightScatteringPostProcess"
  141492. * @returns "VolumetricLightScatteringPostProcess"
  141493. */
  141494. getClassName(): string;
  141495. private _isReady;
  141496. /**
  141497. * Sets the new light position for light scattering effect
  141498. * @param position The new custom light position
  141499. */
  141500. setCustomMeshPosition(position: Vector3): void;
  141501. /**
  141502. * Returns the light position for light scattering effect
  141503. * @return Vector3 The custom light position
  141504. */
  141505. getCustomMeshPosition(): Vector3;
  141506. /**
  141507. * Disposes the internal assets and detaches the post-process from the camera
  141508. */
  141509. dispose(camera: Camera): void;
  141510. /**
  141511. * Returns the render target texture used by the post-process
  141512. * @return the render target texture used by the post-process
  141513. */
  141514. getPass(): RenderTargetTexture;
  141515. private _meshExcluded;
  141516. private _createPass;
  141517. private _updateMeshScreenCoordinates;
  141518. /**
  141519. * Creates a default mesh for the Volumeric Light Scattering post-process
  141520. * @param name The mesh name
  141521. * @param scene The scene where to create the mesh
  141522. * @return the default mesh
  141523. */
  141524. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141525. }
  141526. }
  141527. declare module BABYLON {
  141528. interface Scene {
  141529. /** @hidden (Backing field) */
  141530. _boundingBoxRenderer: BoundingBoxRenderer;
  141531. /** @hidden (Backing field) */
  141532. _forceShowBoundingBoxes: boolean;
  141533. /**
  141534. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141535. */
  141536. forceShowBoundingBoxes: boolean;
  141537. /**
  141538. * Gets the bounding box renderer associated with the scene
  141539. * @returns a BoundingBoxRenderer
  141540. */
  141541. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141542. }
  141543. interface AbstractMesh {
  141544. /** @hidden (Backing field) */
  141545. _showBoundingBox: boolean;
  141546. /**
  141547. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141548. */
  141549. showBoundingBox: boolean;
  141550. }
  141551. /**
  141552. * Component responsible of rendering the bounding box of the meshes in a scene.
  141553. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141554. */
  141555. export class BoundingBoxRenderer implements ISceneComponent {
  141556. /**
  141557. * The component name helpfull to identify the component in the list of scene components.
  141558. */
  141559. readonly name: string;
  141560. /**
  141561. * The scene the component belongs to.
  141562. */
  141563. scene: Scene;
  141564. /**
  141565. * Color of the bounding box lines placed in front of an object
  141566. */
  141567. frontColor: Color3;
  141568. /**
  141569. * Color of the bounding box lines placed behind an object
  141570. */
  141571. backColor: Color3;
  141572. /**
  141573. * Defines if the renderer should show the back lines or not
  141574. */
  141575. showBackLines: boolean;
  141576. /**
  141577. * @hidden
  141578. */
  141579. renderList: SmartArray<BoundingBox>;
  141580. private _colorShader;
  141581. private _vertexBuffers;
  141582. private _indexBuffer;
  141583. private _fillIndexBuffer;
  141584. private _fillIndexData;
  141585. /**
  141586. * Instantiates a new bounding box renderer in a scene.
  141587. * @param scene the scene the renderer renders in
  141588. */
  141589. constructor(scene: Scene);
  141590. /**
  141591. * Registers the component in a given scene
  141592. */
  141593. register(): void;
  141594. private _evaluateSubMesh;
  141595. private _activeMesh;
  141596. private _prepareRessources;
  141597. private _createIndexBuffer;
  141598. /**
  141599. * Rebuilds the elements related to this component in case of
  141600. * context lost for instance.
  141601. */
  141602. rebuild(): void;
  141603. /**
  141604. * @hidden
  141605. */
  141606. reset(): void;
  141607. /**
  141608. * Render the bounding boxes of a specific rendering group
  141609. * @param renderingGroupId defines the rendering group to render
  141610. */
  141611. render(renderingGroupId: number): void;
  141612. /**
  141613. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141614. * @param mesh Define the mesh to render the occlusion bounding box for
  141615. */
  141616. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141617. /**
  141618. * Dispose and release the resources attached to this renderer.
  141619. */
  141620. dispose(): void;
  141621. }
  141622. }
  141623. declare module BABYLON {
  141624. interface Scene {
  141625. /** @hidden (Backing field) */
  141626. _depthRenderer: {
  141627. [id: string]: DepthRenderer;
  141628. };
  141629. /**
  141630. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141631. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141632. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141633. * @returns the created depth renderer
  141634. */
  141635. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141636. /**
  141637. * Disables a depth renderer for a given camera
  141638. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141639. */
  141640. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141641. }
  141642. /**
  141643. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141644. * in several rendering techniques.
  141645. */
  141646. export class DepthRendererSceneComponent implements ISceneComponent {
  141647. /**
  141648. * The component name helpfull to identify the component in the list of scene components.
  141649. */
  141650. readonly name: string;
  141651. /**
  141652. * The scene the component belongs to.
  141653. */
  141654. scene: Scene;
  141655. /**
  141656. * Creates a new instance of the component for the given scene
  141657. * @param scene Defines the scene to register the component in
  141658. */
  141659. constructor(scene: Scene);
  141660. /**
  141661. * Registers the component in a given scene
  141662. */
  141663. register(): void;
  141664. /**
  141665. * Rebuilds the elements related to this component in case of
  141666. * context lost for instance.
  141667. */
  141668. rebuild(): void;
  141669. /**
  141670. * Disposes the component and the associated ressources
  141671. */
  141672. dispose(): void;
  141673. private _gatherRenderTargets;
  141674. private _gatherActiveCameraRenderTargets;
  141675. }
  141676. }
  141677. declare module BABYLON {
  141678. /** @hidden */
  141679. export var outlinePixelShader: {
  141680. name: string;
  141681. shader: string;
  141682. };
  141683. }
  141684. declare module BABYLON {
  141685. /** @hidden */
  141686. export var outlineVertexShader: {
  141687. name: string;
  141688. shader: string;
  141689. };
  141690. }
  141691. declare module BABYLON {
  141692. interface Scene {
  141693. /** @hidden */
  141694. _outlineRenderer: OutlineRenderer;
  141695. /**
  141696. * Gets the outline renderer associated with the scene
  141697. * @returns a OutlineRenderer
  141698. */
  141699. getOutlineRenderer(): OutlineRenderer;
  141700. }
  141701. interface AbstractMesh {
  141702. /** @hidden (Backing field) */
  141703. _renderOutline: boolean;
  141704. /**
  141705. * Gets or sets a boolean indicating if the outline must be rendered as well
  141706. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141707. */
  141708. renderOutline: boolean;
  141709. /** @hidden (Backing field) */
  141710. _renderOverlay: boolean;
  141711. /**
  141712. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141713. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141714. */
  141715. renderOverlay: boolean;
  141716. }
  141717. /**
  141718. * This class is responsible to draw bothe outline/overlay of meshes.
  141719. * It should not be used directly but through the available method on mesh.
  141720. */
  141721. export class OutlineRenderer implements ISceneComponent {
  141722. /**
  141723. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141724. */
  141725. private static _StencilReference;
  141726. /**
  141727. * The name of the component. Each component must have a unique name.
  141728. */
  141729. name: string;
  141730. /**
  141731. * The scene the component belongs to.
  141732. */
  141733. scene: Scene;
  141734. /**
  141735. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141736. */
  141737. zOffset: number;
  141738. private _engine;
  141739. private _effect;
  141740. private _cachedDefines;
  141741. private _savedDepthWrite;
  141742. /**
  141743. * Instantiates a new outline renderer. (There could be only one per scene).
  141744. * @param scene Defines the scene it belongs to
  141745. */
  141746. constructor(scene: Scene);
  141747. /**
  141748. * Register the component to one instance of a scene.
  141749. */
  141750. register(): void;
  141751. /**
  141752. * Rebuilds the elements related to this component in case of
  141753. * context lost for instance.
  141754. */
  141755. rebuild(): void;
  141756. /**
  141757. * Disposes the component and the associated ressources.
  141758. */
  141759. dispose(): void;
  141760. /**
  141761. * Renders the outline in the canvas.
  141762. * @param subMesh Defines the sumesh to render
  141763. * @param batch Defines the batch of meshes in case of instances
  141764. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141765. */
  141766. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141767. /**
  141768. * Returns whether or not the outline renderer is ready for a given submesh.
  141769. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141770. * @param subMesh Defines the submesh to check readyness for
  141771. * @param useInstances Defines wheter wee are trying to render instances or not
  141772. * @returns true if ready otherwise false
  141773. */
  141774. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141775. private _beforeRenderingMesh;
  141776. private _afterRenderingMesh;
  141777. }
  141778. }
  141779. declare module BABYLON {
  141780. /**
  141781. * Defines the basic options interface of a Sprite Frame Source Size.
  141782. */
  141783. export interface ISpriteJSONSpriteSourceSize {
  141784. /**
  141785. * number of the original width of the Frame
  141786. */
  141787. w: number;
  141788. /**
  141789. * number of the original height of the Frame
  141790. */
  141791. h: number;
  141792. }
  141793. /**
  141794. * Defines the basic options interface of a Sprite Frame Data.
  141795. */
  141796. export interface ISpriteJSONSpriteFrameData {
  141797. /**
  141798. * number of the x offset of the Frame
  141799. */
  141800. x: number;
  141801. /**
  141802. * number of the y offset of the Frame
  141803. */
  141804. y: number;
  141805. /**
  141806. * number of the width of the Frame
  141807. */
  141808. w: number;
  141809. /**
  141810. * number of the height of the Frame
  141811. */
  141812. h: number;
  141813. }
  141814. /**
  141815. * Defines the basic options interface of a JSON Sprite.
  141816. */
  141817. export interface ISpriteJSONSprite {
  141818. /**
  141819. * string name of the Frame
  141820. */
  141821. filename: string;
  141822. /**
  141823. * ISpriteJSONSpriteFrame basic object of the frame data
  141824. */
  141825. frame: ISpriteJSONSpriteFrameData;
  141826. /**
  141827. * boolean to flag is the frame was rotated.
  141828. */
  141829. rotated: boolean;
  141830. /**
  141831. * boolean to flag is the frame was trimmed.
  141832. */
  141833. trimmed: boolean;
  141834. /**
  141835. * ISpriteJSONSpriteFrame basic object of the source data
  141836. */
  141837. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141838. /**
  141839. * ISpriteJSONSpriteFrame basic object of the source data
  141840. */
  141841. sourceSize: ISpriteJSONSpriteSourceSize;
  141842. }
  141843. /**
  141844. * Defines the basic options interface of a JSON atlas.
  141845. */
  141846. export interface ISpriteJSONAtlas {
  141847. /**
  141848. * Array of objects that contain the frame data.
  141849. */
  141850. frames: Array<ISpriteJSONSprite>;
  141851. /**
  141852. * object basic object containing the sprite meta data.
  141853. */
  141854. meta?: object;
  141855. }
  141856. }
  141857. declare module BABYLON {
  141858. /** @hidden */
  141859. export var spriteMapPixelShader: {
  141860. name: string;
  141861. shader: string;
  141862. };
  141863. }
  141864. declare module BABYLON {
  141865. /** @hidden */
  141866. export var spriteMapVertexShader: {
  141867. name: string;
  141868. shader: string;
  141869. };
  141870. }
  141871. declare module BABYLON {
  141872. /**
  141873. * Defines the basic options interface of a SpriteMap
  141874. */
  141875. export interface ISpriteMapOptions {
  141876. /**
  141877. * Vector2 of the number of cells in the grid.
  141878. */
  141879. stageSize?: Vector2;
  141880. /**
  141881. * Vector2 of the size of the output plane in World Units.
  141882. */
  141883. outputSize?: Vector2;
  141884. /**
  141885. * Vector3 of the position of the output plane in World Units.
  141886. */
  141887. outputPosition?: Vector3;
  141888. /**
  141889. * Vector3 of the rotation of the output plane.
  141890. */
  141891. outputRotation?: Vector3;
  141892. /**
  141893. * number of layers that the system will reserve in resources.
  141894. */
  141895. layerCount?: number;
  141896. /**
  141897. * number of max animation frames a single cell will reserve in resources.
  141898. */
  141899. maxAnimationFrames?: number;
  141900. /**
  141901. * number cell index of the base tile when the system compiles.
  141902. */
  141903. baseTile?: number;
  141904. /**
  141905. * boolean flip the sprite after its been repositioned by the framing data.
  141906. */
  141907. flipU?: boolean;
  141908. /**
  141909. * Vector3 scalar of the global RGB values of the SpriteMap.
  141910. */
  141911. colorMultiply?: Vector3;
  141912. }
  141913. /**
  141914. * Defines the IDisposable interface in order to be cleanable from resources.
  141915. */
  141916. export interface ISpriteMap extends IDisposable {
  141917. /**
  141918. * String name of the SpriteMap.
  141919. */
  141920. name: string;
  141921. /**
  141922. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141923. */
  141924. atlasJSON: ISpriteJSONAtlas;
  141925. /**
  141926. * Texture of the SpriteMap.
  141927. */
  141928. spriteSheet: Texture;
  141929. /**
  141930. * The parameters to initialize the SpriteMap with.
  141931. */
  141932. options: ISpriteMapOptions;
  141933. }
  141934. /**
  141935. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141936. */
  141937. export class SpriteMap implements ISpriteMap {
  141938. /** The Name of the spriteMap */
  141939. name: string;
  141940. /** The JSON file with the frame and meta data */
  141941. atlasJSON: ISpriteJSONAtlas;
  141942. /** The systems Sprite Sheet Texture */
  141943. spriteSheet: Texture;
  141944. /** Arguments passed with the Constructor */
  141945. options: ISpriteMapOptions;
  141946. /** Public Sprite Storage array, parsed from atlasJSON */
  141947. sprites: Array<ISpriteJSONSprite>;
  141948. /** Returns the Number of Sprites in the System */
  141949. get spriteCount(): number;
  141950. /** Returns the Position of Output Plane*/
  141951. get position(): Vector3;
  141952. /** Returns the Position of Output Plane*/
  141953. set position(v: Vector3);
  141954. /** Returns the Rotation of Output Plane*/
  141955. get rotation(): Vector3;
  141956. /** Returns the Rotation of Output Plane*/
  141957. set rotation(v: Vector3);
  141958. /** Sets the AnimationMap*/
  141959. get animationMap(): RawTexture;
  141960. /** Sets the AnimationMap*/
  141961. set animationMap(v: RawTexture);
  141962. /** Scene that the SpriteMap was created in */
  141963. private _scene;
  141964. /** Texture Buffer of Float32 that holds tile frame data*/
  141965. private _frameMap;
  141966. /** Texture Buffers of Float32 that holds tileMap data*/
  141967. private _tileMaps;
  141968. /** Texture Buffer of Float32 that holds Animation Data*/
  141969. private _animationMap;
  141970. /** Custom ShaderMaterial Central to the System*/
  141971. private _material;
  141972. /** Custom ShaderMaterial Central to the System*/
  141973. private _output;
  141974. /** Systems Time Ticker*/
  141975. private _time;
  141976. /**
  141977. * Creates a new SpriteMap
  141978. * @param name defines the SpriteMaps Name
  141979. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141980. * @param spriteSheet is the Texture that the Sprites are on.
  141981. * @param options a basic deployment configuration
  141982. * @param scene The Scene that the map is deployed on
  141983. */
  141984. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141985. /**
  141986. * Returns tileID location
  141987. * @returns Vector2 the cell position ID
  141988. */
  141989. getTileID(): Vector2;
  141990. /**
  141991. * Gets the UV location of the mouse over the SpriteMap.
  141992. * @returns Vector2 the UV position of the mouse interaction
  141993. */
  141994. getMousePosition(): Vector2;
  141995. /**
  141996. * Creates the "frame" texture Buffer
  141997. * -------------------------------------
  141998. * Structure of frames
  141999. * "filename": "Falling-Water-2.png",
  142000. * "frame": {"x":69,"y":103,"w":24,"h":32},
  142001. * "rotated": true,
  142002. * "trimmed": true,
  142003. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  142004. * "sourceSize": {"w":32,"h":32}
  142005. * @returns RawTexture of the frameMap
  142006. */
  142007. private _createFrameBuffer;
  142008. /**
  142009. * Creates the tileMap texture Buffer
  142010. * @param buffer normally and array of numbers, or a false to generate from scratch
  142011. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  142012. * @returns RawTexture of the tileMap
  142013. */
  142014. private _createTileBuffer;
  142015. /**
  142016. * Modifies the data of the tileMaps
  142017. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  142018. * @param pos is the iVector2 Coordinates of the Tile
  142019. * @param tile The SpriteIndex of the new Tile
  142020. */
  142021. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  142022. /**
  142023. * Creates the animationMap texture Buffer
  142024. * @param buffer normally and array of numbers, or a false to generate from scratch
  142025. * @returns RawTexture of the animationMap
  142026. */
  142027. private _createTileAnimationBuffer;
  142028. /**
  142029. * Modifies the data of the animationMap
  142030. * @param cellID is the Index of the Sprite
  142031. * @param _frame is the target Animation frame
  142032. * @param toCell is the Target Index of the next frame of the animation
  142033. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  142034. * @param speed is a global scalar of the time variable on the map.
  142035. */
  142036. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  142037. /**
  142038. * Exports the .tilemaps file
  142039. */
  142040. saveTileMaps(): void;
  142041. /**
  142042. * Imports the .tilemaps file
  142043. * @param url of the .tilemaps file
  142044. */
  142045. loadTileMaps(url: string): void;
  142046. /**
  142047. * Release associated resources
  142048. */
  142049. dispose(): void;
  142050. }
  142051. }
  142052. declare module BABYLON {
  142053. /**
  142054. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142055. * @see http://doc.babylonjs.com/babylon101/sprites
  142056. */
  142057. export class SpritePackedManager extends SpriteManager {
  142058. /** defines the packed manager's name */
  142059. name: string;
  142060. /**
  142061. * Creates a new sprite manager from a packed sprite sheet
  142062. * @param name defines the manager's name
  142063. * @param imgUrl defines the sprite sheet url
  142064. * @param capacity defines the maximum allowed number of sprites
  142065. * @param scene defines the hosting scene
  142066. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142067. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142068. * @param samplingMode defines the smapling mode to use with spritesheet
  142069. * @param fromPacked set to true; do not alter
  142070. */
  142071. constructor(
  142072. /** defines the packed manager's name */
  142073. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142074. }
  142075. }
  142076. declare module BABYLON {
  142077. /**
  142078. * Defines the list of states available for a task inside a AssetsManager
  142079. */
  142080. export enum AssetTaskState {
  142081. /**
  142082. * Initialization
  142083. */
  142084. INIT = 0,
  142085. /**
  142086. * Running
  142087. */
  142088. RUNNING = 1,
  142089. /**
  142090. * Done
  142091. */
  142092. DONE = 2,
  142093. /**
  142094. * Error
  142095. */
  142096. ERROR = 3
  142097. }
  142098. /**
  142099. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142100. */
  142101. export abstract class AbstractAssetTask {
  142102. /**
  142103. * Task name
  142104. */ name: string;
  142105. /**
  142106. * Callback called when the task is successful
  142107. */
  142108. onSuccess: (task: any) => void;
  142109. /**
  142110. * Callback called when the task is not successful
  142111. */
  142112. onError: (task: any, message?: string, exception?: any) => void;
  142113. /**
  142114. * Creates a new AssetsManager
  142115. * @param name defines the name of the task
  142116. */
  142117. constructor(
  142118. /**
  142119. * Task name
  142120. */ name: string);
  142121. private _isCompleted;
  142122. private _taskState;
  142123. private _errorObject;
  142124. /**
  142125. * Get if the task is completed
  142126. */
  142127. get isCompleted(): boolean;
  142128. /**
  142129. * Gets the current state of the task
  142130. */
  142131. get taskState(): AssetTaskState;
  142132. /**
  142133. * Gets the current error object (if task is in error)
  142134. */
  142135. get errorObject(): {
  142136. message?: string;
  142137. exception?: any;
  142138. };
  142139. /**
  142140. * Internal only
  142141. * @hidden
  142142. */
  142143. _setErrorObject(message?: string, exception?: any): void;
  142144. /**
  142145. * Execute the current task
  142146. * @param scene defines the scene where you want your assets to be loaded
  142147. * @param onSuccess is a callback called when the task is successfully executed
  142148. * @param onError is a callback called if an error occurs
  142149. */
  142150. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142151. /**
  142152. * Execute the current task
  142153. * @param scene defines the scene where you want your assets to be loaded
  142154. * @param onSuccess is a callback called when the task is successfully executed
  142155. * @param onError is a callback called if an error occurs
  142156. */
  142157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142158. /**
  142159. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142160. * This can be used with failed tasks that have the reason for failure fixed.
  142161. */
  142162. reset(): void;
  142163. private onErrorCallback;
  142164. private onDoneCallback;
  142165. }
  142166. /**
  142167. * Define the interface used by progress events raised during assets loading
  142168. */
  142169. export interface IAssetsProgressEvent {
  142170. /**
  142171. * Defines the number of remaining tasks to process
  142172. */
  142173. remainingCount: number;
  142174. /**
  142175. * Defines the total number of tasks
  142176. */
  142177. totalCount: number;
  142178. /**
  142179. * Defines the task that was just processed
  142180. */
  142181. task: AbstractAssetTask;
  142182. }
  142183. /**
  142184. * Class used to share progress information about assets loading
  142185. */
  142186. export class AssetsProgressEvent implements IAssetsProgressEvent {
  142187. /**
  142188. * Defines the number of remaining tasks to process
  142189. */
  142190. remainingCount: number;
  142191. /**
  142192. * Defines the total number of tasks
  142193. */
  142194. totalCount: number;
  142195. /**
  142196. * Defines the task that was just processed
  142197. */
  142198. task: AbstractAssetTask;
  142199. /**
  142200. * Creates a AssetsProgressEvent
  142201. * @param remainingCount defines the number of remaining tasks to process
  142202. * @param totalCount defines the total number of tasks
  142203. * @param task defines the task that was just processed
  142204. */
  142205. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142206. }
  142207. /**
  142208. * Define a task used by AssetsManager to load meshes
  142209. */
  142210. export class MeshAssetTask extends AbstractAssetTask {
  142211. /**
  142212. * Defines the name of the task
  142213. */
  142214. name: string;
  142215. /**
  142216. * Defines the list of mesh's names you want to load
  142217. */
  142218. meshesNames: any;
  142219. /**
  142220. * Defines the root url to use as a base to load your meshes and associated resources
  142221. */
  142222. rootUrl: string;
  142223. /**
  142224. * Defines the filename of the scene to load from
  142225. */
  142226. sceneFilename: string;
  142227. /**
  142228. * Gets the list of loaded meshes
  142229. */
  142230. loadedMeshes: Array<AbstractMesh>;
  142231. /**
  142232. * Gets the list of loaded particle systems
  142233. */
  142234. loadedParticleSystems: Array<IParticleSystem>;
  142235. /**
  142236. * Gets the list of loaded skeletons
  142237. */
  142238. loadedSkeletons: Array<Skeleton>;
  142239. /**
  142240. * Gets the list of loaded animation groups
  142241. */
  142242. loadedAnimationGroups: Array<AnimationGroup>;
  142243. /**
  142244. * Callback called when the task is successful
  142245. */
  142246. onSuccess: (task: MeshAssetTask) => void;
  142247. /**
  142248. * Callback called when the task is successful
  142249. */
  142250. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142251. /**
  142252. * Creates a new MeshAssetTask
  142253. * @param name defines the name of the task
  142254. * @param meshesNames defines the list of mesh's names you want to load
  142255. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142256. * @param sceneFilename defines the filename of the scene to load from
  142257. */
  142258. constructor(
  142259. /**
  142260. * Defines the name of the task
  142261. */
  142262. name: string,
  142263. /**
  142264. * Defines the list of mesh's names you want to load
  142265. */
  142266. meshesNames: any,
  142267. /**
  142268. * Defines the root url to use as a base to load your meshes and associated resources
  142269. */
  142270. rootUrl: string,
  142271. /**
  142272. * Defines the filename of the scene to load from
  142273. */
  142274. sceneFilename: string);
  142275. /**
  142276. * Execute the current task
  142277. * @param scene defines the scene where you want your assets to be loaded
  142278. * @param onSuccess is a callback called when the task is successfully executed
  142279. * @param onError is a callback called if an error occurs
  142280. */
  142281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142282. }
  142283. /**
  142284. * Define a task used by AssetsManager to load text content
  142285. */
  142286. export class TextFileAssetTask extends AbstractAssetTask {
  142287. /**
  142288. * Defines the name of the task
  142289. */
  142290. name: string;
  142291. /**
  142292. * Defines the location of the file to load
  142293. */
  142294. url: string;
  142295. /**
  142296. * Gets the loaded text string
  142297. */
  142298. text: string;
  142299. /**
  142300. * Callback called when the task is successful
  142301. */
  142302. onSuccess: (task: TextFileAssetTask) => void;
  142303. /**
  142304. * Callback called when the task is successful
  142305. */
  142306. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142307. /**
  142308. * Creates a new TextFileAssetTask object
  142309. * @param name defines the name of the task
  142310. * @param url defines the location of the file to load
  142311. */
  142312. constructor(
  142313. /**
  142314. * Defines the name of the task
  142315. */
  142316. name: string,
  142317. /**
  142318. * Defines the location of the file to load
  142319. */
  142320. url: string);
  142321. /**
  142322. * Execute the current task
  142323. * @param scene defines the scene where you want your assets to be loaded
  142324. * @param onSuccess is a callback called when the task is successfully executed
  142325. * @param onError is a callback called if an error occurs
  142326. */
  142327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142328. }
  142329. /**
  142330. * Define a task used by AssetsManager to load binary data
  142331. */
  142332. export class BinaryFileAssetTask extends AbstractAssetTask {
  142333. /**
  142334. * Defines the name of the task
  142335. */
  142336. name: string;
  142337. /**
  142338. * Defines the location of the file to load
  142339. */
  142340. url: string;
  142341. /**
  142342. * Gets the lodaded data (as an array buffer)
  142343. */
  142344. data: ArrayBuffer;
  142345. /**
  142346. * Callback called when the task is successful
  142347. */
  142348. onSuccess: (task: BinaryFileAssetTask) => void;
  142349. /**
  142350. * Callback called when the task is successful
  142351. */
  142352. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142353. /**
  142354. * Creates a new BinaryFileAssetTask object
  142355. * @param name defines the name of the new task
  142356. * @param url defines the location of the file to load
  142357. */
  142358. constructor(
  142359. /**
  142360. * Defines the name of the task
  142361. */
  142362. name: string,
  142363. /**
  142364. * Defines the location of the file to load
  142365. */
  142366. url: string);
  142367. /**
  142368. * Execute the current task
  142369. * @param scene defines the scene where you want your assets to be loaded
  142370. * @param onSuccess is a callback called when the task is successfully executed
  142371. * @param onError is a callback called if an error occurs
  142372. */
  142373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142374. }
  142375. /**
  142376. * Define a task used by AssetsManager to load images
  142377. */
  142378. export class ImageAssetTask extends AbstractAssetTask {
  142379. /**
  142380. * Defines the name of the task
  142381. */
  142382. name: string;
  142383. /**
  142384. * Defines the location of the image to load
  142385. */
  142386. url: string;
  142387. /**
  142388. * Gets the loaded images
  142389. */
  142390. image: HTMLImageElement;
  142391. /**
  142392. * Callback called when the task is successful
  142393. */
  142394. onSuccess: (task: ImageAssetTask) => void;
  142395. /**
  142396. * Callback called when the task is successful
  142397. */
  142398. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142399. /**
  142400. * Creates a new ImageAssetTask
  142401. * @param name defines the name of the task
  142402. * @param url defines the location of the image to load
  142403. */
  142404. constructor(
  142405. /**
  142406. * Defines the name of the task
  142407. */
  142408. name: string,
  142409. /**
  142410. * Defines the location of the image to load
  142411. */
  142412. url: string);
  142413. /**
  142414. * Execute the current task
  142415. * @param scene defines the scene where you want your assets to be loaded
  142416. * @param onSuccess is a callback called when the task is successfully executed
  142417. * @param onError is a callback called if an error occurs
  142418. */
  142419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142420. }
  142421. /**
  142422. * Defines the interface used by texture loading tasks
  142423. */
  142424. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142425. /**
  142426. * Gets the loaded texture
  142427. */
  142428. texture: TEX;
  142429. }
  142430. /**
  142431. * Define a task used by AssetsManager to load 2D textures
  142432. */
  142433. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142434. /**
  142435. * Defines the name of the task
  142436. */
  142437. name: string;
  142438. /**
  142439. * Defines the location of the file to load
  142440. */
  142441. url: string;
  142442. /**
  142443. * Defines if mipmap should not be generated (default is false)
  142444. */
  142445. noMipmap?: boolean | undefined;
  142446. /**
  142447. * Defines if texture must be inverted on Y axis (default is true)
  142448. */
  142449. invertY: boolean;
  142450. /**
  142451. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142452. */
  142453. samplingMode: number;
  142454. /**
  142455. * Gets the loaded texture
  142456. */
  142457. texture: Texture;
  142458. /**
  142459. * Callback called when the task is successful
  142460. */
  142461. onSuccess: (task: TextureAssetTask) => void;
  142462. /**
  142463. * Callback called when the task is successful
  142464. */
  142465. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142466. /**
  142467. * Creates a new TextureAssetTask object
  142468. * @param name defines the name of the task
  142469. * @param url defines the location of the file to load
  142470. * @param noMipmap defines if mipmap should not be generated (default is false)
  142471. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142472. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142473. */
  142474. constructor(
  142475. /**
  142476. * Defines the name of the task
  142477. */
  142478. name: string,
  142479. /**
  142480. * Defines the location of the file to load
  142481. */
  142482. url: string,
  142483. /**
  142484. * Defines if mipmap should not be generated (default is false)
  142485. */
  142486. noMipmap?: boolean | undefined,
  142487. /**
  142488. * Defines if texture must be inverted on Y axis (default is true)
  142489. */
  142490. invertY?: boolean,
  142491. /**
  142492. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142493. */
  142494. samplingMode?: number);
  142495. /**
  142496. * Execute the current task
  142497. * @param scene defines the scene where you want your assets to be loaded
  142498. * @param onSuccess is a callback called when the task is successfully executed
  142499. * @param onError is a callback called if an error occurs
  142500. */
  142501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142502. }
  142503. /**
  142504. * Define a task used by AssetsManager to load cube textures
  142505. */
  142506. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142507. /**
  142508. * Defines the name of the task
  142509. */
  142510. name: string;
  142511. /**
  142512. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142513. */
  142514. url: string;
  142515. /**
  142516. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142517. */
  142518. extensions?: string[] | undefined;
  142519. /**
  142520. * Defines if mipmaps should not be generated (default is false)
  142521. */
  142522. noMipmap?: boolean | undefined;
  142523. /**
  142524. * Defines the explicit list of files (undefined by default)
  142525. */
  142526. files?: string[] | undefined;
  142527. /**
  142528. * Gets the loaded texture
  142529. */
  142530. texture: CubeTexture;
  142531. /**
  142532. * Callback called when the task is successful
  142533. */
  142534. onSuccess: (task: CubeTextureAssetTask) => void;
  142535. /**
  142536. * Callback called when the task is successful
  142537. */
  142538. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142539. /**
  142540. * Creates a new CubeTextureAssetTask
  142541. * @param name defines the name of the task
  142542. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142543. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142544. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142545. * @param files defines the explicit list of files (undefined by default)
  142546. */
  142547. constructor(
  142548. /**
  142549. * Defines the name of the task
  142550. */
  142551. name: string,
  142552. /**
  142553. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142554. */
  142555. url: string,
  142556. /**
  142557. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142558. */
  142559. extensions?: string[] | undefined,
  142560. /**
  142561. * Defines if mipmaps should not be generated (default is false)
  142562. */
  142563. noMipmap?: boolean | undefined,
  142564. /**
  142565. * Defines the explicit list of files (undefined by default)
  142566. */
  142567. files?: string[] | undefined);
  142568. /**
  142569. * Execute the current task
  142570. * @param scene defines the scene where you want your assets to be loaded
  142571. * @param onSuccess is a callback called when the task is successfully executed
  142572. * @param onError is a callback called if an error occurs
  142573. */
  142574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142575. }
  142576. /**
  142577. * Define a task used by AssetsManager to load HDR cube textures
  142578. */
  142579. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142580. /**
  142581. * Defines the name of the task
  142582. */
  142583. name: string;
  142584. /**
  142585. * Defines the location of the file to load
  142586. */
  142587. url: string;
  142588. /**
  142589. * Defines the desired size (the more it increases the longer the generation will be)
  142590. */
  142591. size: number;
  142592. /**
  142593. * Defines if mipmaps should not be generated (default is false)
  142594. */
  142595. noMipmap: boolean;
  142596. /**
  142597. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142598. */
  142599. generateHarmonics: boolean;
  142600. /**
  142601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  142602. */
  142603. gammaSpace: boolean;
  142604. /**
  142605. * Internal Use Only
  142606. */
  142607. reserved: boolean;
  142608. /**
  142609. * Gets the loaded texture
  142610. */
  142611. texture: HDRCubeTexture;
  142612. /**
  142613. * Callback called when the task is successful
  142614. */
  142615. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142616. /**
  142617. * Callback called when the task is successful
  142618. */
  142619. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142620. /**
  142621. * Creates a new HDRCubeTextureAssetTask object
  142622. * @param name defines the name of the task
  142623. * @param url defines the location of the file to load
  142624. * @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.
  142625. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142626. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142627. * @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)
  142628. * @param reserved Internal use only
  142629. */
  142630. constructor(
  142631. /**
  142632. * Defines the name of the task
  142633. */
  142634. name: string,
  142635. /**
  142636. * Defines the location of the file to load
  142637. */
  142638. url: string,
  142639. /**
  142640. * Defines the desired size (the more it increases the longer the generation will be)
  142641. */
  142642. size: number,
  142643. /**
  142644. * Defines if mipmaps should not be generated (default is false)
  142645. */
  142646. noMipmap?: boolean,
  142647. /**
  142648. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142649. */
  142650. generateHarmonics?: boolean,
  142651. /**
  142652. * 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)
  142653. */
  142654. gammaSpace?: boolean,
  142655. /**
  142656. * Internal Use Only
  142657. */
  142658. reserved?: boolean);
  142659. /**
  142660. * Execute the current task
  142661. * @param scene defines the scene where you want your assets to be loaded
  142662. * @param onSuccess is a callback called when the task is successfully executed
  142663. * @param onError is a callback called if an error occurs
  142664. */
  142665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142666. }
  142667. /**
  142668. * Define a task used by AssetsManager to load Equirectangular cube textures
  142669. */
  142670. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142671. /**
  142672. * Defines the name of the task
  142673. */
  142674. name: string;
  142675. /**
  142676. * Defines the location of the file to load
  142677. */
  142678. url: string;
  142679. /**
  142680. * Defines the desired size (the more it increases the longer the generation will be)
  142681. */
  142682. size: number;
  142683. /**
  142684. * Defines if mipmaps should not be generated (default is false)
  142685. */
  142686. noMipmap: boolean;
  142687. /**
  142688. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142689. * but the standard material would require them in Gamma space) (default is true)
  142690. */
  142691. gammaSpace: boolean;
  142692. /**
  142693. * Gets the loaded texture
  142694. */
  142695. texture: EquiRectangularCubeTexture;
  142696. /**
  142697. * Callback called when the task is successful
  142698. */
  142699. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142700. /**
  142701. * Callback called when the task is successful
  142702. */
  142703. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142704. /**
  142705. * Creates a new EquiRectangularCubeTextureAssetTask object
  142706. * @param name defines the name of the task
  142707. * @param url defines the location of the file to load
  142708. * @param size defines the desired size (the more it increases the longer the generation will be)
  142709. * If the size is omitted this implies you are using a preprocessed cubemap.
  142710. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142711. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142712. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142713. * (default is true)
  142714. */
  142715. constructor(
  142716. /**
  142717. * Defines the name of the task
  142718. */
  142719. name: string,
  142720. /**
  142721. * Defines the location of the file to load
  142722. */
  142723. url: string,
  142724. /**
  142725. * Defines the desired size (the more it increases the longer the generation will be)
  142726. */
  142727. size: number,
  142728. /**
  142729. * Defines if mipmaps should not be generated (default is false)
  142730. */
  142731. noMipmap?: boolean,
  142732. /**
  142733. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142734. * but the standard material would require them in Gamma space) (default is true)
  142735. */
  142736. gammaSpace?: boolean);
  142737. /**
  142738. * Execute the current task
  142739. * @param scene defines the scene where you want your assets to be loaded
  142740. * @param onSuccess is a callback called when the task is successfully executed
  142741. * @param onError is a callback called if an error occurs
  142742. */
  142743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142744. }
  142745. /**
  142746. * This class can be used to easily import assets into a scene
  142747. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142748. */
  142749. export class AssetsManager {
  142750. private _scene;
  142751. private _isLoading;
  142752. protected _tasks: AbstractAssetTask[];
  142753. protected _waitingTasksCount: number;
  142754. protected _totalTasksCount: number;
  142755. /**
  142756. * Callback called when all tasks are processed
  142757. */
  142758. onFinish: (tasks: AbstractAssetTask[]) => void;
  142759. /**
  142760. * Callback called when a task is successful
  142761. */
  142762. onTaskSuccess: (task: AbstractAssetTask) => void;
  142763. /**
  142764. * Callback called when a task had an error
  142765. */
  142766. onTaskError: (task: AbstractAssetTask) => void;
  142767. /**
  142768. * Callback called when a task is done (whatever the result is)
  142769. */
  142770. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142771. /**
  142772. * Observable called when all tasks are processed
  142773. */
  142774. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142775. /**
  142776. * Observable called when a task had an error
  142777. */
  142778. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142779. /**
  142780. * Observable called when all tasks were executed
  142781. */
  142782. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142783. /**
  142784. * Observable called when a task is done (whatever the result is)
  142785. */
  142786. onProgressObservable: Observable<IAssetsProgressEvent>;
  142787. /**
  142788. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142789. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142790. */
  142791. useDefaultLoadingScreen: boolean;
  142792. /**
  142793. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142794. * when all assets have been downloaded.
  142795. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142796. */
  142797. autoHideLoadingUI: boolean;
  142798. /**
  142799. * Creates a new AssetsManager
  142800. * @param scene defines the scene to work on
  142801. */
  142802. constructor(scene: Scene);
  142803. /**
  142804. * Add a MeshAssetTask to the list of active tasks
  142805. * @param taskName defines the name of the new task
  142806. * @param meshesNames defines the name of meshes to load
  142807. * @param rootUrl defines the root url to use to locate files
  142808. * @param sceneFilename defines the filename of the scene file
  142809. * @returns a new MeshAssetTask object
  142810. */
  142811. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142812. /**
  142813. * Add a TextFileAssetTask to the list of active tasks
  142814. * @param taskName defines the name of the new task
  142815. * @param url defines the url of the file to load
  142816. * @returns a new TextFileAssetTask object
  142817. */
  142818. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142819. /**
  142820. * Add a BinaryFileAssetTask to the list of active tasks
  142821. * @param taskName defines the name of the new task
  142822. * @param url defines the url of the file to load
  142823. * @returns a new BinaryFileAssetTask object
  142824. */
  142825. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142826. /**
  142827. * Add a ImageAssetTask to the list of active tasks
  142828. * @param taskName defines the name of the new task
  142829. * @param url defines the url of the file to load
  142830. * @returns a new ImageAssetTask object
  142831. */
  142832. addImageTask(taskName: string, url: string): ImageAssetTask;
  142833. /**
  142834. * Add a TextureAssetTask to the list of active tasks
  142835. * @param taskName defines the name of the new task
  142836. * @param url defines the url of the file to load
  142837. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142838. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142839. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142840. * @returns a new TextureAssetTask object
  142841. */
  142842. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142843. /**
  142844. * Add a CubeTextureAssetTask to the list of active tasks
  142845. * @param taskName defines the name of the new task
  142846. * @param url defines the url of the file to load
  142847. * @param extensions defines the extension to use to load the cube map (can be null)
  142848. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142849. * @param files defines the list of files to load (can be null)
  142850. * @returns a new CubeTextureAssetTask object
  142851. */
  142852. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142853. /**
  142854. *
  142855. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142856. * @param taskName defines the name of the new task
  142857. * @param url defines the url of the file to load
  142858. * @param size defines the size you want for the cubemap (can be null)
  142859. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142860. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142861. * @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)
  142862. * @param reserved Internal use only
  142863. * @returns a new HDRCubeTextureAssetTask object
  142864. */
  142865. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142866. /**
  142867. *
  142868. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142869. * @param taskName defines the name of the new task
  142870. * @param url defines the url of the file to load
  142871. * @param size defines the size you want for the cubemap (can be null)
  142872. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142873. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142874. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142875. * @returns a new EquiRectangularCubeTextureAssetTask object
  142876. */
  142877. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142878. /**
  142879. * Remove a task from the assets manager.
  142880. * @param task the task to remove
  142881. */
  142882. removeTask(task: AbstractAssetTask): void;
  142883. private _decreaseWaitingTasksCount;
  142884. private _runTask;
  142885. /**
  142886. * Reset the AssetsManager and remove all tasks
  142887. * @return the current instance of the AssetsManager
  142888. */
  142889. reset(): AssetsManager;
  142890. /**
  142891. * Start the loading process
  142892. * @return the current instance of the AssetsManager
  142893. */
  142894. load(): AssetsManager;
  142895. /**
  142896. * Start the loading process as an async operation
  142897. * @return a promise returning the list of failed tasks
  142898. */
  142899. loadAsync(): Promise<void>;
  142900. }
  142901. }
  142902. declare module BABYLON {
  142903. /**
  142904. * Wrapper class for promise with external resolve and reject.
  142905. */
  142906. export class Deferred<T> {
  142907. /**
  142908. * The promise associated with this deferred object.
  142909. */
  142910. readonly promise: Promise<T>;
  142911. private _resolve;
  142912. private _reject;
  142913. /**
  142914. * The resolve method of the promise associated with this deferred object.
  142915. */
  142916. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142917. /**
  142918. * The reject method of the promise associated with this deferred object.
  142919. */
  142920. get reject(): (reason?: any) => void;
  142921. /**
  142922. * Constructor for this deferred object.
  142923. */
  142924. constructor();
  142925. }
  142926. }
  142927. declare module BABYLON {
  142928. /**
  142929. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142930. */
  142931. export class MeshExploder {
  142932. private _centerMesh;
  142933. private _meshes;
  142934. private _meshesOrigins;
  142935. private _toCenterVectors;
  142936. private _scaledDirection;
  142937. private _newPosition;
  142938. private _centerPosition;
  142939. /**
  142940. * Explodes meshes from a center mesh.
  142941. * @param meshes The meshes to explode.
  142942. * @param centerMesh The mesh to be center of explosion.
  142943. */
  142944. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142945. private _setCenterMesh;
  142946. /**
  142947. * Get class name
  142948. * @returns "MeshExploder"
  142949. */
  142950. getClassName(): string;
  142951. /**
  142952. * "Exploded meshes"
  142953. * @returns Array of meshes with the centerMesh at index 0.
  142954. */
  142955. getMeshes(): Array<Mesh>;
  142956. /**
  142957. * Explodes meshes giving a specific direction
  142958. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142959. */
  142960. explode(direction?: number): void;
  142961. }
  142962. }
  142963. declare module BABYLON {
  142964. /**
  142965. * Class used to help managing file picking and drag'n'drop
  142966. */
  142967. export class FilesInput {
  142968. /**
  142969. * List of files ready to be loaded
  142970. */
  142971. static get FilesToLoad(): {
  142972. [key: string]: File;
  142973. };
  142974. /**
  142975. * Callback called when a file is processed
  142976. */
  142977. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142978. private _engine;
  142979. private _currentScene;
  142980. private _sceneLoadedCallback;
  142981. private _progressCallback;
  142982. private _additionalRenderLoopLogicCallback;
  142983. private _textureLoadingCallback;
  142984. private _startingProcessingFilesCallback;
  142985. private _onReloadCallback;
  142986. private _errorCallback;
  142987. private _elementToMonitor;
  142988. private _sceneFileToLoad;
  142989. private _filesToLoad;
  142990. /**
  142991. * Creates a new FilesInput
  142992. * @param engine defines the rendering engine
  142993. * @param scene defines the hosting scene
  142994. * @param sceneLoadedCallback callback called when scene is loaded
  142995. * @param progressCallback callback called to track progress
  142996. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142997. * @param textureLoadingCallback callback called when a texture is loading
  142998. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142999. * @param onReloadCallback callback called when a reload is requested
  143000. * @param errorCallback callback call if an error occurs
  143001. */
  143002. 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);
  143003. private _dragEnterHandler;
  143004. private _dragOverHandler;
  143005. private _dropHandler;
  143006. /**
  143007. * Calls this function to listen to drag'n'drop events on a specific DOM element
  143008. * @param elementToMonitor defines the DOM element to track
  143009. */
  143010. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  143011. /**
  143012. * Release all associated resources
  143013. */
  143014. dispose(): void;
  143015. private renderFunction;
  143016. private drag;
  143017. private drop;
  143018. private _traverseFolder;
  143019. private _processFiles;
  143020. /**
  143021. * Load files from a drop event
  143022. * @param event defines the drop event to use as source
  143023. */
  143024. loadFiles(event: any): void;
  143025. private _processReload;
  143026. /**
  143027. * Reload the current scene from the loaded files
  143028. */
  143029. reload(): void;
  143030. }
  143031. }
  143032. declare module BABYLON {
  143033. /**
  143034. * Defines the root class used to create scene optimization to use with SceneOptimizer
  143035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143036. */
  143037. export class SceneOptimization {
  143038. /**
  143039. * Defines the priority of this optimization (0 by default which means first in the list)
  143040. */
  143041. priority: number;
  143042. /**
  143043. * Gets a string describing the action executed by the current optimization
  143044. * @returns description string
  143045. */
  143046. getDescription(): string;
  143047. /**
  143048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143049. * @param scene defines the current scene where to apply this optimization
  143050. * @param optimizer defines the current optimizer
  143051. * @returns true if everything that can be done was applied
  143052. */
  143053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143054. /**
  143055. * Creates the SceneOptimization object
  143056. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143057. * @param desc defines the description associated with the optimization
  143058. */
  143059. constructor(
  143060. /**
  143061. * Defines the priority of this optimization (0 by default which means first in the list)
  143062. */
  143063. priority?: number);
  143064. }
  143065. /**
  143066. * Defines an optimization used to reduce the size of render target textures
  143067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143068. */
  143069. export class TextureOptimization extends SceneOptimization {
  143070. /**
  143071. * Defines the priority of this optimization (0 by default which means first in the list)
  143072. */
  143073. priority: number;
  143074. /**
  143075. * 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
  143076. */
  143077. maximumSize: number;
  143078. /**
  143079. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143080. */
  143081. step: number;
  143082. /**
  143083. * Gets a string describing the action executed by the current optimization
  143084. * @returns description string
  143085. */
  143086. getDescription(): string;
  143087. /**
  143088. * Creates the TextureOptimization object
  143089. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143090. * @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
  143091. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143092. */
  143093. constructor(
  143094. /**
  143095. * Defines the priority of this optimization (0 by default which means first in the list)
  143096. */
  143097. priority?: number,
  143098. /**
  143099. * 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
  143100. */
  143101. maximumSize?: number,
  143102. /**
  143103. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143104. */
  143105. step?: number);
  143106. /**
  143107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143108. * @param scene defines the current scene where to apply this optimization
  143109. * @param optimizer defines the current optimizer
  143110. * @returns true if everything that can be done was applied
  143111. */
  143112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143113. }
  143114. /**
  143115. * Defines an optimization used to increase or decrease the rendering resolution
  143116. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143117. */
  143118. export class HardwareScalingOptimization extends SceneOptimization {
  143119. /**
  143120. * Defines the priority of this optimization (0 by default which means first in the list)
  143121. */
  143122. priority: number;
  143123. /**
  143124. * Defines the maximum scale to use (2 by default)
  143125. */
  143126. maximumScale: number;
  143127. /**
  143128. * Defines the step to use between two passes (0.5 by default)
  143129. */
  143130. step: number;
  143131. private _currentScale;
  143132. private _directionOffset;
  143133. /**
  143134. * Gets a string describing the action executed by the current optimization
  143135. * @return description string
  143136. */
  143137. getDescription(): string;
  143138. /**
  143139. * Creates the HardwareScalingOptimization object
  143140. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143141. * @param maximumScale defines the maximum scale to use (2 by default)
  143142. * @param step defines the step to use between two passes (0.5 by default)
  143143. */
  143144. constructor(
  143145. /**
  143146. * Defines the priority of this optimization (0 by default which means first in the list)
  143147. */
  143148. priority?: number,
  143149. /**
  143150. * Defines the maximum scale to use (2 by default)
  143151. */
  143152. maximumScale?: number,
  143153. /**
  143154. * Defines the step to use between two passes (0.5 by default)
  143155. */
  143156. step?: number);
  143157. /**
  143158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143159. * @param scene defines the current scene where to apply this optimization
  143160. * @param optimizer defines the current optimizer
  143161. * @returns true if everything that can be done was applied
  143162. */
  143163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143164. }
  143165. /**
  143166. * Defines an optimization used to remove shadows
  143167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143168. */
  143169. export class ShadowsOptimization extends SceneOptimization {
  143170. /**
  143171. * Gets a string describing the action executed by the current optimization
  143172. * @return description string
  143173. */
  143174. getDescription(): string;
  143175. /**
  143176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143177. * @param scene defines the current scene where to apply this optimization
  143178. * @param optimizer defines the current optimizer
  143179. * @returns true if everything that can be done was applied
  143180. */
  143181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143182. }
  143183. /**
  143184. * Defines an optimization used to turn post-processes off
  143185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143186. */
  143187. export class PostProcessesOptimization extends SceneOptimization {
  143188. /**
  143189. * Gets a string describing the action executed by the current optimization
  143190. * @return description string
  143191. */
  143192. getDescription(): string;
  143193. /**
  143194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143195. * @param scene defines the current scene where to apply this optimization
  143196. * @param optimizer defines the current optimizer
  143197. * @returns true if everything that can be done was applied
  143198. */
  143199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143200. }
  143201. /**
  143202. * Defines an optimization used to turn lens flares off
  143203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143204. */
  143205. export class LensFlaresOptimization extends SceneOptimization {
  143206. /**
  143207. * Gets a string describing the action executed by the current optimization
  143208. * @return description string
  143209. */
  143210. getDescription(): string;
  143211. /**
  143212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143213. * @param scene defines the current scene where to apply this optimization
  143214. * @param optimizer defines the current optimizer
  143215. * @returns true if everything that can be done was applied
  143216. */
  143217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143218. }
  143219. /**
  143220. * Defines an optimization based on user defined callback.
  143221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143222. */
  143223. export class CustomOptimization extends SceneOptimization {
  143224. /**
  143225. * Callback called to apply the custom optimization.
  143226. */
  143227. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143228. /**
  143229. * Callback called to get custom description
  143230. */
  143231. onGetDescription: () => string;
  143232. /**
  143233. * Gets a string describing the action executed by the current optimization
  143234. * @returns description string
  143235. */
  143236. getDescription(): string;
  143237. /**
  143238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143239. * @param scene defines the current scene where to apply this optimization
  143240. * @param optimizer defines the current optimizer
  143241. * @returns true if everything that can be done was applied
  143242. */
  143243. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143244. }
  143245. /**
  143246. * Defines an optimization used to turn particles off
  143247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143248. */
  143249. export class ParticlesOptimization extends SceneOptimization {
  143250. /**
  143251. * Gets a string describing the action executed by the current optimization
  143252. * @return description string
  143253. */
  143254. getDescription(): string;
  143255. /**
  143256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143257. * @param scene defines the current scene where to apply this optimization
  143258. * @param optimizer defines the current optimizer
  143259. * @returns true if everything that can be done was applied
  143260. */
  143261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143262. }
  143263. /**
  143264. * Defines an optimization used to turn render targets off
  143265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143266. */
  143267. export class RenderTargetsOptimization extends SceneOptimization {
  143268. /**
  143269. * Gets a string describing the action executed by the current optimization
  143270. * @return description string
  143271. */
  143272. getDescription(): string;
  143273. /**
  143274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143275. * @param scene defines the current scene where to apply this optimization
  143276. * @param optimizer defines the current optimizer
  143277. * @returns true if everything that can be done was applied
  143278. */
  143279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143280. }
  143281. /**
  143282. * Defines an optimization used to merge meshes with compatible materials
  143283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143284. */
  143285. export class MergeMeshesOptimization extends SceneOptimization {
  143286. private static _UpdateSelectionTree;
  143287. /**
  143288. * Gets or sets a boolean which defines if optimization octree has to be updated
  143289. */
  143290. static get UpdateSelectionTree(): boolean;
  143291. /**
  143292. * Gets or sets a boolean which defines if optimization octree has to be updated
  143293. */
  143294. static set UpdateSelectionTree(value: boolean);
  143295. /**
  143296. * Gets a string describing the action executed by the current optimization
  143297. * @return description string
  143298. */
  143299. getDescription(): string;
  143300. private _canBeMerged;
  143301. /**
  143302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143303. * @param scene defines the current scene where to apply this optimization
  143304. * @param optimizer defines the current optimizer
  143305. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143306. * @returns true if everything that can be done was applied
  143307. */
  143308. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143309. }
  143310. /**
  143311. * Defines a list of options used by SceneOptimizer
  143312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143313. */
  143314. export class SceneOptimizerOptions {
  143315. /**
  143316. * Defines the target frame rate to reach (60 by default)
  143317. */
  143318. targetFrameRate: number;
  143319. /**
  143320. * Defines the interval between two checkes (2000ms by default)
  143321. */
  143322. trackerDuration: number;
  143323. /**
  143324. * Gets the list of optimizations to apply
  143325. */
  143326. optimizations: SceneOptimization[];
  143327. /**
  143328. * Creates a new list of options used by SceneOptimizer
  143329. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143330. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143331. */
  143332. constructor(
  143333. /**
  143334. * Defines the target frame rate to reach (60 by default)
  143335. */
  143336. targetFrameRate?: number,
  143337. /**
  143338. * Defines the interval between two checkes (2000ms by default)
  143339. */
  143340. trackerDuration?: number);
  143341. /**
  143342. * Add a new optimization
  143343. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143344. * @returns the current SceneOptimizerOptions
  143345. */
  143346. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143347. /**
  143348. * Add a new custom optimization
  143349. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143350. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143351. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143352. * @returns the current SceneOptimizerOptions
  143353. */
  143354. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143355. /**
  143356. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143357. * @param targetFrameRate defines the target frame rate (60 by default)
  143358. * @returns a SceneOptimizerOptions object
  143359. */
  143360. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143361. /**
  143362. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143363. * @param targetFrameRate defines the target frame rate (60 by default)
  143364. * @returns a SceneOptimizerOptions object
  143365. */
  143366. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143367. /**
  143368. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143369. * @param targetFrameRate defines the target frame rate (60 by default)
  143370. * @returns a SceneOptimizerOptions object
  143371. */
  143372. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143373. }
  143374. /**
  143375. * Class used to run optimizations in order to reach a target frame rate
  143376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143377. */
  143378. export class SceneOptimizer implements IDisposable {
  143379. private _isRunning;
  143380. private _options;
  143381. private _scene;
  143382. private _currentPriorityLevel;
  143383. private _targetFrameRate;
  143384. private _trackerDuration;
  143385. private _currentFrameRate;
  143386. private _sceneDisposeObserver;
  143387. private _improvementMode;
  143388. /**
  143389. * Defines an observable called when the optimizer reaches the target frame rate
  143390. */
  143391. onSuccessObservable: Observable<SceneOptimizer>;
  143392. /**
  143393. * Defines an observable called when the optimizer enables an optimization
  143394. */
  143395. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143396. /**
  143397. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143398. */
  143399. onFailureObservable: Observable<SceneOptimizer>;
  143400. /**
  143401. * Gets a boolean indicating if the optimizer is in improvement mode
  143402. */
  143403. get isInImprovementMode(): boolean;
  143404. /**
  143405. * Gets the current priority level (0 at start)
  143406. */
  143407. get currentPriorityLevel(): number;
  143408. /**
  143409. * Gets the current frame rate checked by the SceneOptimizer
  143410. */
  143411. get currentFrameRate(): number;
  143412. /**
  143413. * Gets or sets the current target frame rate (60 by default)
  143414. */
  143415. get targetFrameRate(): number;
  143416. /**
  143417. * Gets or sets the current target frame rate (60 by default)
  143418. */
  143419. set targetFrameRate(value: number);
  143420. /**
  143421. * Gets or sets the current interval between two checks (every 2000ms by default)
  143422. */
  143423. get trackerDuration(): number;
  143424. /**
  143425. * Gets or sets the current interval between two checks (every 2000ms by default)
  143426. */
  143427. set trackerDuration(value: number);
  143428. /**
  143429. * Gets the list of active optimizations
  143430. */
  143431. get optimizations(): SceneOptimization[];
  143432. /**
  143433. * Creates a new SceneOptimizer
  143434. * @param scene defines the scene to work on
  143435. * @param options defines the options to use with the SceneOptimizer
  143436. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143437. * @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)
  143438. */
  143439. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143440. /**
  143441. * Stops the current optimizer
  143442. */
  143443. stop(): void;
  143444. /**
  143445. * Reset the optimizer to initial step (current priority level = 0)
  143446. */
  143447. reset(): void;
  143448. /**
  143449. * Start the optimizer. By default it will try to reach a specific framerate
  143450. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143451. */
  143452. start(): void;
  143453. private _checkCurrentState;
  143454. /**
  143455. * Release all resources
  143456. */
  143457. dispose(): void;
  143458. /**
  143459. * Helper function to create a SceneOptimizer with one single line of code
  143460. * @param scene defines the scene to work on
  143461. * @param options defines the options to use with the SceneOptimizer
  143462. * @param onSuccess defines a callback to call on success
  143463. * @param onFailure defines a callback to call on failure
  143464. * @returns the new SceneOptimizer object
  143465. */
  143466. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143467. }
  143468. }
  143469. declare module BABYLON {
  143470. /**
  143471. * Class used to serialize a scene into a string
  143472. */
  143473. export class SceneSerializer {
  143474. /**
  143475. * Clear cache used by a previous serialization
  143476. */
  143477. static ClearCache(): void;
  143478. /**
  143479. * Serialize a scene into a JSON compatible object
  143480. * @param scene defines the scene to serialize
  143481. * @returns a JSON compatible object
  143482. */
  143483. static Serialize(scene: Scene): any;
  143484. /**
  143485. * Serialize a mesh into a JSON compatible object
  143486. * @param toSerialize defines the mesh to serialize
  143487. * @param withParents defines if parents must be serialized as well
  143488. * @param withChildren defines if children must be serialized as well
  143489. * @returns a JSON compatible object
  143490. */
  143491. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143492. }
  143493. }
  143494. declare module BABYLON {
  143495. /**
  143496. * Class used to host texture specific utilities
  143497. */
  143498. export class TextureTools {
  143499. /**
  143500. * Uses the GPU to create a copy texture rescaled at a given size
  143501. * @param texture Texture to copy from
  143502. * @param width defines the desired width
  143503. * @param height defines the desired height
  143504. * @param useBilinearMode defines if bilinear mode has to be used
  143505. * @return the generated texture
  143506. */
  143507. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143508. }
  143509. }
  143510. declare module BABYLON {
  143511. /**
  143512. * This represents the different options available for the video capture.
  143513. */
  143514. export interface VideoRecorderOptions {
  143515. /** Defines the mime type of the video. */
  143516. mimeType: string;
  143517. /** Defines the FPS the video should be recorded at. */
  143518. fps: number;
  143519. /** Defines the chunk size for the recording data. */
  143520. recordChunckSize: number;
  143521. /** The audio tracks to attach to the recording. */
  143522. audioTracks?: MediaStreamTrack[];
  143523. }
  143524. /**
  143525. * This can help with recording videos from BabylonJS.
  143526. * This is based on the available WebRTC functionalities of the browser.
  143527. *
  143528. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143529. */
  143530. export class VideoRecorder {
  143531. private static readonly _defaultOptions;
  143532. /**
  143533. * Returns whether or not the VideoRecorder is available in your browser.
  143534. * @param engine Defines the Babylon Engine.
  143535. * @returns true if supported otherwise false.
  143536. */
  143537. static IsSupported(engine: Engine): boolean;
  143538. private readonly _options;
  143539. private _canvas;
  143540. private _mediaRecorder;
  143541. private _recordedChunks;
  143542. private _fileName;
  143543. private _resolve;
  143544. private _reject;
  143545. /**
  143546. * True when a recording is already in progress.
  143547. */
  143548. get isRecording(): boolean;
  143549. /**
  143550. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143551. * @param engine Defines the BabylonJS Engine you wish to record.
  143552. * @param options Defines options that can be used to customize the capture.
  143553. */
  143554. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143555. /**
  143556. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143557. */
  143558. stopRecording(): void;
  143559. /**
  143560. * Starts recording the canvas for a max duration specified in parameters.
  143561. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143562. * If null no automatic download will start and you can rely on the promise to get the data back.
  143563. * @param maxDuration Defines the maximum recording time in seconds.
  143564. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143565. * @return A promise callback at the end of the recording with the video data in Blob.
  143566. */
  143567. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143568. /**
  143569. * Releases internal resources used during the recording.
  143570. */
  143571. dispose(): void;
  143572. private _handleDataAvailable;
  143573. private _handleError;
  143574. private _handleStop;
  143575. }
  143576. }
  143577. declare module BABYLON {
  143578. /**
  143579. * Class containing a set of static utilities functions for screenshots
  143580. */
  143581. export class ScreenshotTools {
  143582. /**
  143583. * Captures a screenshot of the current rendering
  143584. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143585. * @param engine defines the rendering engine
  143586. * @param camera defines the source camera
  143587. * @param size This parameter can be set to a single number or to an object with the
  143588. * following (optional) properties: precision, width, height. If a single number is passed,
  143589. * it will be used for both width and height. If an object is passed, the screenshot size
  143590. * will be derived from the parameters. The precision property is a multiplier allowing
  143591. * rendering at a higher or lower resolution
  143592. * @param successCallback defines the callback receives a single parameter which contains the
  143593. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143594. * src parameter of an <img> to display it
  143595. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143596. * Check your browser for supported MIME types
  143597. */
  143598. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  143599. /**
  143600. * Captures a screenshot of the current rendering
  143601. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143602. * @param engine defines the rendering engine
  143603. * @param camera defines the source camera
  143604. * @param size This parameter can be set to a single number or to an object with the
  143605. * following (optional) properties: precision, width, height. If a single number is passed,
  143606. * it will be used for both width and height. If an object is passed, the screenshot size
  143607. * will be derived from the parameters. The precision property is a multiplier allowing
  143608. * rendering at a higher or lower resolution
  143609. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143610. * Check your browser for supported MIME types
  143611. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143612. * to the src parameter of an <img> to display it
  143613. */
  143614. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143615. /**
  143616. * Generates an image screenshot from the specified camera.
  143617. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143618. * @param engine The engine to use for rendering
  143619. * @param camera The camera to use for rendering
  143620. * @param size This parameter can be set to a single number or to an object with the
  143621. * following (optional) properties: precision, width, height. If a single number is passed,
  143622. * it will be used for both width and height. If an object is passed, the screenshot size
  143623. * will be derived from the parameters. The precision property is a multiplier allowing
  143624. * rendering at a higher or lower resolution
  143625. * @param successCallback The callback receives a single parameter which contains the
  143626. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143627. * src parameter of an <img> to display it
  143628. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143629. * Check your browser for supported MIME types
  143630. * @param samples Texture samples (default: 1)
  143631. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143632. * @param fileName A name for for the downloaded file.
  143633. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143634. */
  143635. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143636. /**
  143637. * Generates an image screenshot from the specified camera.
  143638. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143639. * @param engine The engine to use for rendering
  143640. * @param camera The camera to use for rendering
  143641. * @param size This parameter can be set to a single number or to an object with the
  143642. * following (optional) properties: precision, width, height. If a single number is passed,
  143643. * it will be used for both width and height. If an object is passed, the screenshot size
  143644. * will be derived from the parameters. The precision property is a multiplier allowing
  143645. * rendering at a higher or lower resolution
  143646. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143647. * Check your browser for supported MIME types
  143648. * @param samples Texture samples (default: 1)
  143649. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143650. * @param fileName A name for for the downloaded file.
  143651. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143652. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143653. * to the src parameter of an <img> to display it
  143654. */
  143655. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143656. /**
  143657. * Gets height and width for screenshot size
  143658. * @private
  143659. */
  143660. private static _getScreenshotSize;
  143661. }
  143662. }
  143663. declare module BABYLON {
  143664. /**
  143665. * Interface for a data buffer
  143666. */
  143667. export interface IDataBuffer {
  143668. /**
  143669. * Reads bytes from the data buffer.
  143670. * @param byteOffset The byte offset to read
  143671. * @param byteLength The byte length to read
  143672. * @returns A promise that resolves when the bytes are read
  143673. */
  143674. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143675. /**
  143676. * The byte length of the buffer.
  143677. */
  143678. readonly byteLength: number;
  143679. }
  143680. /**
  143681. * Utility class for reading from a data buffer
  143682. */
  143683. export class DataReader {
  143684. /**
  143685. * The data buffer associated with this data reader.
  143686. */
  143687. readonly buffer: IDataBuffer;
  143688. /**
  143689. * The current byte offset from the beginning of the data buffer.
  143690. */
  143691. byteOffset: number;
  143692. private _dataView;
  143693. private _dataByteOffset;
  143694. /**
  143695. * Constructor
  143696. * @param buffer The buffer to read
  143697. */
  143698. constructor(buffer: IDataBuffer);
  143699. /**
  143700. * Loads the given byte length.
  143701. * @param byteLength The byte length to load
  143702. * @returns A promise that resolves when the load is complete
  143703. */
  143704. loadAsync(byteLength: number): Promise<void>;
  143705. /**
  143706. * Read a unsigned 32-bit integer from the currently loaded data range.
  143707. * @returns The 32-bit integer read
  143708. */
  143709. readUint32(): number;
  143710. /**
  143711. * Read a byte array from the currently loaded data range.
  143712. * @param byteLength The byte length to read
  143713. * @returns The byte array read
  143714. */
  143715. readUint8Array(byteLength: number): Uint8Array;
  143716. /**
  143717. * Read a string from the currently loaded data range.
  143718. * @param byteLength The byte length to read
  143719. * @returns The string read
  143720. */
  143721. readString(byteLength: number): string;
  143722. /**
  143723. * Skips the given byte length the currently loaded data range.
  143724. * @param byteLength The byte length to skip
  143725. */
  143726. skipBytes(byteLength: number): void;
  143727. }
  143728. }
  143729. declare module BABYLON {
  143730. /**
  143731. * Class for storing data to local storage if available or in-memory storage otherwise
  143732. */
  143733. export class DataStorage {
  143734. private static _Storage;
  143735. private static _GetStorage;
  143736. /**
  143737. * Reads a string from the data storage
  143738. * @param key The key to read
  143739. * @param defaultValue The value if the key doesn't exist
  143740. * @returns The string value
  143741. */
  143742. static ReadString(key: string, defaultValue: string): string;
  143743. /**
  143744. * Writes a string to the data storage
  143745. * @param key The key to write
  143746. * @param value The value to write
  143747. */
  143748. static WriteString(key: string, value: string): void;
  143749. /**
  143750. * Reads a boolean from the data storage
  143751. * @param key The key to read
  143752. * @param defaultValue The value if the key doesn't exist
  143753. * @returns The boolean value
  143754. */
  143755. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143756. /**
  143757. * Writes a boolean to the data storage
  143758. * @param key The key to write
  143759. * @param value The value to write
  143760. */
  143761. static WriteBoolean(key: string, value: boolean): void;
  143762. /**
  143763. * Reads a number from the data storage
  143764. * @param key The key to read
  143765. * @param defaultValue The value if the key doesn't exist
  143766. * @returns The number value
  143767. */
  143768. static ReadNumber(key: string, defaultValue: number): number;
  143769. /**
  143770. * Writes a number to the data storage
  143771. * @param key The key to write
  143772. * @param value The value to write
  143773. */
  143774. static WriteNumber(key: string, value: number): void;
  143775. }
  143776. }
  143777. declare module BABYLON {
  143778. /**
  143779. * Options used for hit testing
  143780. */
  143781. export interface IWebXRLegacyHitTestOptions {
  143782. /**
  143783. * Only test when user interacted with the scene. Default - hit test every frame
  143784. */
  143785. testOnPointerDownOnly?: boolean;
  143786. /**
  143787. * The node to use to transform the local results to world coordinates
  143788. */
  143789. worldParentNode?: TransformNode;
  143790. }
  143791. /**
  143792. * Interface defining the babylon result of raycasting/hit-test
  143793. */
  143794. export interface IWebXRLegacyHitResult {
  143795. /**
  143796. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143797. */
  143798. transformationMatrix: Matrix;
  143799. /**
  143800. * The native hit test result
  143801. */
  143802. xrHitResult: XRHitResult | XRHitTestResult;
  143803. }
  143804. /**
  143805. * The currently-working hit-test module.
  143806. * Hit test (or Ray-casting) is used to interact with the real world.
  143807. * For further information read here - https://github.com/immersive-web/hit-test
  143808. */
  143809. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143810. /**
  143811. * options to use when constructing this feature
  143812. */
  143813. readonly options: IWebXRLegacyHitTestOptions;
  143814. private _direction;
  143815. private _mat;
  143816. private _onSelectEnabled;
  143817. private _origin;
  143818. /**
  143819. * The module's name
  143820. */
  143821. static readonly Name: string;
  143822. /**
  143823. * The (Babylon) version of this module.
  143824. * This is an integer representing the implementation version.
  143825. * This number does not correspond to the WebXR specs version
  143826. */
  143827. static readonly Version: number;
  143828. /**
  143829. * Populated with the last native XR Hit Results
  143830. */
  143831. lastNativeXRHitResults: XRHitResult[];
  143832. /**
  143833. * Triggered when new babylon (transformed) hit test results are available
  143834. */
  143835. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143836. /**
  143837. * Creates a new instance of the (legacy version) hit test feature
  143838. * @param _xrSessionManager an instance of WebXRSessionManager
  143839. * @param options options to use when constructing this feature
  143840. */
  143841. constructor(_xrSessionManager: WebXRSessionManager,
  143842. /**
  143843. * options to use when constructing this feature
  143844. */
  143845. options?: IWebXRLegacyHitTestOptions);
  143846. /**
  143847. * execute a hit test with an XR Ray
  143848. *
  143849. * @param xrSession a native xrSession that will execute this hit test
  143850. * @param xrRay the ray (position and direction) to use for ray-casting
  143851. * @param referenceSpace native XR reference space to use for the hit-test
  143852. * @param filter filter function that will filter the results
  143853. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143854. */
  143855. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143856. /**
  143857. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143858. * @param event the (select) event to use to select with
  143859. * @param referenceSpace the reference space to use for this hit test
  143860. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143861. */
  143862. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143863. /**
  143864. * attach this feature
  143865. * Will usually be called by the features manager
  143866. *
  143867. * @returns true if successful.
  143868. */
  143869. attach(): boolean;
  143870. /**
  143871. * detach this feature.
  143872. * Will usually be called by the features manager
  143873. *
  143874. * @returns true if successful.
  143875. */
  143876. detach(): boolean;
  143877. /**
  143878. * Dispose this feature and all of the resources attached
  143879. */
  143880. dispose(): void;
  143881. protected _onXRFrame(frame: XRFrame): void;
  143882. private _onHitTestResults;
  143883. private _onSelect;
  143884. }
  143885. }
  143886. declare module BABYLON {
  143887. /**
  143888. * Options used in the plane detector module
  143889. */
  143890. export interface IWebXRPlaneDetectorOptions {
  143891. /**
  143892. * The node to use to transform the local results to world coordinates
  143893. */
  143894. worldParentNode?: TransformNode;
  143895. }
  143896. /**
  143897. * A babylon interface for a WebXR plane.
  143898. * A Plane is actually a polygon, built from N points in space
  143899. *
  143900. * Supported in chrome 79, not supported in canary 81 ATM
  143901. */
  143902. export interface IWebXRPlane {
  143903. /**
  143904. * a babylon-assigned ID for this polygon
  143905. */
  143906. id: number;
  143907. /**
  143908. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143909. */
  143910. polygonDefinition: Array<Vector3>;
  143911. /**
  143912. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143913. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143914. */
  143915. transformationMatrix: Matrix;
  143916. /**
  143917. * the native xr-plane object
  143918. */
  143919. xrPlane: XRPlane;
  143920. }
  143921. /**
  143922. * The plane detector is used to detect planes in the real world when in AR
  143923. * For more information see https://github.com/immersive-web/real-world-geometry/
  143924. */
  143925. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143926. private _options;
  143927. private _detectedPlanes;
  143928. private _enabled;
  143929. private _lastFrameDetected;
  143930. /**
  143931. * The module's name
  143932. */
  143933. static readonly Name: string;
  143934. /**
  143935. * The (Babylon) version of this module.
  143936. * This is an integer representing the implementation version.
  143937. * This number does not correspond to the WebXR specs version
  143938. */
  143939. static readonly Version: number;
  143940. /**
  143941. * Observers registered here will be executed when a new plane was added to the session
  143942. */
  143943. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143944. /**
  143945. * Observers registered here will be executed when a plane is no longer detected in the session
  143946. */
  143947. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143948. /**
  143949. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143950. * This can execute N times every frame
  143951. */
  143952. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143953. /**
  143954. * construct a new Plane Detector
  143955. * @param _xrSessionManager an instance of xr Session manager
  143956. * @param _options configuration to use when constructing this feature
  143957. */
  143958. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143959. /**
  143960. * Dispose this feature and all of the resources attached
  143961. */
  143962. dispose(): void;
  143963. protected _onXRFrame(frame: XRFrame): void;
  143964. private _init;
  143965. private _updatePlaneWithXRPlane;
  143966. /**
  143967. * avoiding using Array.find for global support.
  143968. * @param xrPlane the plane to find in the array
  143969. */
  143970. private findIndexInPlaneArray;
  143971. }
  143972. }
  143973. declare module BABYLON {
  143974. /**
  143975. * Configuration options of the anchor system
  143976. */
  143977. export interface IWebXRAnchorSystemOptions {
  143978. /**
  143979. * Should a new anchor be added every time a select event is triggered
  143980. */
  143981. addAnchorOnSelect?: boolean;
  143982. /**
  143983. * should the anchor system use plane detection.
  143984. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143985. */
  143986. usePlaneDetection?: boolean;
  143987. /**
  143988. * a node that will be used to convert local to world coordinates
  143989. */
  143990. worldParentNode?: TransformNode;
  143991. }
  143992. /**
  143993. * A babylon container for an XR Anchor
  143994. */
  143995. export interface IWebXRAnchor {
  143996. /**
  143997. * A babylon-assigned ID for this anchor
  143998. */
  143999. id: number;
  144000. /**
  144001. * Transformation matrix to apply to an object attached to this anchor
  144002. */
  144003. transformationMatrix: Matrix;
  144004. /**
  144005. * The native anchor object
  144006. */
  144007. xrAnchor: XRAnchor;
  144008. }
  144009. /**
  144010. * An implementation of the anchor system of WebXR.
  144011. * Note that the current documented implementation is not available in any browser. Future implementations
  144012. * will use the frame to create an anchor and not the session or a detected plane
  144013. * For further information see https://github.com/immersive-web/anchors/
  144014. */
  144015. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  144016. private _options;
  144017. private _enabled;
  144018. private _hitTestModule;
  144019. private _lastFrameDetected;
  144020. private _onSelect;
  144021. private _planeDetector;
  144022. private _trackedAnchors;
  144023. /**
  144024. * The module's name
  144025. */
  144026. static readonly Name: string;
  144027. /**
  144028. * The (Babylon) version of this module.
  144029. * This is an integer representing the implementation version.
  144030. * This number does not correspond to the WebXR specs version
  144031. */
  144032. static readonly Version: number;
  144033. /**
  144034. * Observers registered here will be executed when a new anchor was added to the session
  144035. */
  144036. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  144037. /**
  144038. * Observers registered here will be executed when an anchor was removed from the session
  144039. */
  144040. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  144041. /**
  144042. * Observers registered here will be executed when an existing anchor updates
  144043. * This can execute N times every frame
  144044. */
  144045. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144046. /**
  144047. * constructs a new anchor system
  144048. * @param _xrSessionManager an instance of WebXRSessionManager
  144049. * @param _options configuration object for this feature
  144050. */
  144051. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144052. /**
  144053. * Add anchor at a specific XR point.
  144054. *
  144055. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144056. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144057. * @returns a promise the fulfills when the anchor was created
  144058. */
  144059. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144060. /**
  144061. * attach this feature
  144062. * Will usually be called by the features manager
  144063. *
  144064. * @returns true if successful.
  144065. */
  144066. attach(): boolean;
  144067. /**
  144068. * detach this feature.
  144069. * Will usually be called by the features manager
  144070. *
  144071. * @returns true if successful.
  144072. */
  144073. detach(): boolean;
  144074. /**
  144075. * Dispose this feature and all of the resources attached
  144076. */
  144077. dispose(): void;
  144078. /**
  144079. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144080. * @param hitTestModule the hit-test module to use.
  144081. */
  144082. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144083. /**
  144084. * set the plane detector to use in order to create anchors from frames
  144085. * @param planeDetector the plane-detector module to use
  144086. * @param enable enable plane-anchors. default is true
  144087. */
  144088. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144089. protected _onXRFrame(frame: XRFrame): void;
  144090. /**
  144091. * avoiding using Array.find for global support.
  144092. * @param xrAnchor the plane to find in the array
  144093. */
  144094. private _findIndexInAnchorArray;
  144095. private _updateAnchorWithXRFrame;
  144096. }
  144097. }
  144098. declare module BABYLON {
  144099. /**
  144100. * Options interface for the background remover plugin
  144101. */
  144102. export interface IWebXRBackgroundRemoverOptions {
  144103. /**
  144104. * Further background meshes to disable when entering AR
  144105. */
  144106. backgroundMeshes?: AbstractMesh[];
  144107. /**
  144108. * flags to configure the removal of the environment helper.
  144109. * If not set, the entire background will be removed. If set, flags should be set as well.
  144110. */
  144111. environmentHelperRemovalFlags?: {
  144112. /**
  144113. * Should the skybox be removed (default false)
  144114. */
  144115. skyBox?: boolean;
  144116. /**
  144117. * Should the ground be removed (default false)
  144118. */
  144119. ground?: boolean;
  144120. };
  144121. /**
  144122. * don't disable the environment helper
  144123. */
  144124. ignoreEnvironmentHelper?: boolean;
  144125. }
  144126. /**
  144127. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144128. */
  144129. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144130. /**
  144131. * read-only options to be used in this module
  144132. */
  144133. readonly options: IWebXRBackgroundRemoverOptions;
  144134. /**
  144135. * The module's name
  144136. */
  144137. static readonly Name: string;
  144138. /**
  144139. * The (Babylon) version of this module.
  144140. * This is an integer representing the implementation version.
  144141. * This number does not correspond to the WebXR specs version
  144142. */
  144143. static readonly Version: number;
  144144. /**
  144145. * registered observers will be triggered when the background state changes
  144146. */
  144147. onBackgroundStateChangedObservable: Observable<boolean>;
  144148. /**
  144149. * constructs a new background remover module
  144150. * @param _xrSessionManager the session manager for this module
  144151. * @param options read-only options to be used in this module
  144152. */
  144153. constructor(_xrSessionManager: WebXRSessionManager,
  144154. /**
  144155. * read-only options to be used in this module
  144156. */
  144157. options?: IWebXRBackgroundRemoverOptions);
  144158. /**
  144159. * attach this feature
  144160. * Will usually be called by the features manager
  144161. *
  144162. * @returns true if successful.
  144163. */
  144164. attach(): boolean;
  144165. /**
  144166. * detach this feature.
  144167. * Will usually be called by the features manager
  144168. *
  144169. * @returns true if successful.
  144170. */
  144171. detach(): boolean;
  144172. /**
  144173. * Dispose this feature and all of the resources attached
  144174. */
  144175. dispose(): void;
  144176. protected _onXRFrame(_xrFrame: XRFrame): void;
  144177. private _setBackgroundState;
  144178. }
  144179. }
  144180. declare module BABYLON {
  144181. /**
  144182. * Options for the controller physics feature
  144183. */
  144184. export class IWebXRControllerPhysicsOptions {
  144185. /**
  144186. * Should the headset get its own impostor
  144187. */
  144188. enableHeadsetImpostor?: boolean;
  144189. /**
  144190. * Optional parameters for the headset impostor
  144191. */
  144192. headsetImpostorParams?: {
  144193. /**
  144194. * The type of impostor to create. Default is sphere
  144195. */
  144196. impostorType: number;
  144197. /**
  144198. * the size of the impostor. Defaults to 10cm
  144199. */
  144200. impostorSize?: number | {
  144201. width: number;
  144202. height: number;
  144203. depth: number;
  144204. };
  144205. /**
  144206. * Friction definitions
  144207. */
  144208. friction?: number;
  144209. /**
  144210. * Restitution
  144211. */
  144212. restitution?: number;
  144213. };
  144214. /**
  144215. * The physics properties of the future impostors
  144216. */
  144217. physicsProperties?: {
  144218. /**
  144219. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144220. * Note that this requires a physics engine that supports mesh impostors!
  144221. */
  144222. useControllerMesh?: boolean;
  144223. /**
  144224. * The type of impostor to create. Default is sphere
  144225. */
  144226. impostorType?: number;
  144227. /**
  144228. * the size of the impostor. Defaults to 10cm
  144229. */
  144230. impostorSize?: number | {
  144231. width: number;
  144232. height: number;
  144233. depth: number;
  144234. };
  144235. /**
  144236. * Friction definitions
  144237. */
  144238. friction?: number;
  144239. /**
  144240. * Restitution
  144241. */
  144242. restitution?: number;
  144243. };
  144244. /**
  144245. * the xr input to use with this pointer selection
  144246. */
  144247. xrInput: WebXRInput;
  144248. }
  144249. /**
  144250. * Add physics impostor to your webxr controllers,
  144251. * including naive calculation of their linear and angular velocity
  144252. */
  144253. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144254. private readonly _options;
  144255. private _attachController;
  144256. private _controllers;
  144257. private _debugMode;
  144258. private _delta;
  144259. private _headsetImpostor?;
  144260. private _headsetMesh?;
  144261. private _lastTimestamp;
  144262. private _tmpQuaternion;
  144263. private _tmpVector;
  144264. /**
  144265. * The module's name
  144266. */
  144267. static readonly Name: string;
  144268. /**
  144269. * The (Babylon) version of this module.
  144270. * This is an integer representing the implementation version.
  144271. * This number does not correspond to the webxr specs version
  144272. */
  144273. static readonly Version: number;
  144274. /**
  144275. * Construct a new Controller Physics Feature
  144276. * @param _xrSessionManager the corresponding xr session manager
  144277. * @param _options options to create this feature with
  144278. */
  144279. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144280. /**
  144281. * @hidden
  144282. * enable debugging - will show console outputs and the impostor mesh
  144283. */
  144284. _enablePhysicsDebug(): void;
  144285. /**
  144286. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144287. * @param xrController the controller to add
  144288. */
  144289. addController(xrController: WebXRInputSource): void;
  144290. /**
  144291. * attach this feature
  144292. * Will usually be called by the features manager
  144293. *
  144294. * @returns true if successful.
  144295. */
  144296. attach(): boolean;
  144297. /**
  144298. * detach this feature.
  144299. * Will usually be called by the features manager
  144300. *
  144301. * @returns true if successful.
  144302. */
  144303. detach(): boolean;
  144304. /**
  144305. * Get the headset impostor, if enabled
  144306. * @returns the impostor
  144307. */
  144308. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144309. /**
  144310. * Get the physics impostor of a specific controller.
  144311. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144312. * @param controller the controller or the controller id of which to get the impostor
  144313. * @returns the impostor or null
  144314. */
  144315. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144316. /**
  144317. * Update the physics properties provided in the constructor
  144318. * @param newProperties the new properties object
  144319. */
  144320. setPhysicsProperties(newProperties: {
  144321. impostorType?: number;
  144322. impostorSize?: number | {
  144323. width: number;
  144324. height: number;
  144325. depth: number;
  144326. };
  144327. friction?: number;
  144328. restitution?: number;
  144329. }): void;
  144330. protected _onXRFrame(_xrFrame: any): void;
  144331. private _detachController;
  144332. }
  144333. }
  144334. declare module BABYLON {
  144335. /**
  144336. * Options used for hit testing (version 2)
  144337. */
  144338. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144339. /**
  144340. * Do not create a permanent hit test. Will usually be used when only
  144341. * transient inputs are needed.
  144342. */
  144343. disablePermanentHitTest?: boolean;
  144344. /**
  144345. * Enable transient (for example touch-based) hit test inspections
  144346. */
  144347. enableTransientHitTest?: boolean;
  144348. /**
  144349. * Offset ray for the permanent hit test
  144350. */
  144351. offsetRay?: Vector3;
  144352. /**
  144353. * Offset ray for the transient hit test
  144354. */
  144355. transientOffsetRay?: Vector3;
  144356. /**
  144357. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144358. */
  144359. useReferenceSpace?: boolean;
  144360. }
  144361. /**
  144362. * Interface defining the babylon result of hit-test
  144363. */
  144364. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144365. /**
  144366. * The input source that generated this hit test (if transient)
  144367. */
  144368. inputSource?: XRInputSource;
  144369. /**
  144370. * Is this a transient hit test
  144371. */
  144372. isTransient?: boolean;
  144373. /**
  144374. * Position of the hit test result
  144375. */
  144376. position: Vector3;
  144377. /**
  144378. * Rotation of the hit test result
  144379. */
  144380. rotationQuaternion: Quaternion;
  144381. }
  144382. /**
  144383. * The currently-working hit-test module.
  144384. * Hit test (or Ray-casting) is used to interact with the real world.
  144385. * For further information read here - https://github.com/immersive-web/hit-test
  144386. *
  144387. * Tested on chrome (mobile) 80.
  144388. */
  144389. export class WebXRHitTest extends WebXRAbstractFeature {
  144390. /**
  144391. * options to use when constructing this feature
  144392. */
  144393. readonly options: IWebXRHitTestOptions;
  144394. private _tmpMat;
  144395. private _tmpPos;
  144396. private _tmpQuat;
  144397. private _transientXrHitTestSource;
  144398. private _xrHitTestSource;
  144399. private initHitTestSource;
  144400. /**
  144401. * The module's name
  144402. */
  144403. static readonly Name: string;
  144404. /**
  144405. * The (Babylon) version of this module.
  144406. * This is an integer representing the implementation version.
  144407. * This number does not correspond to the WebXR specs version
  144408. */
  144409. static readonly Version: number;
  144410. /**
  144411. * When set to true, each hit test will have its own position/rotation objects
  144412. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144413. * the developers will clone them or copy them as they see fit.
  144414. */
  144415. autoCloneTransformation: boolean;
  144416. /**
  144417. * Populated with the last native XR Hit Results
  144418. */
  144419. lastNativeXRHitResults: XRHitResult[];
  144420. /**
  144421. * Triggered when new babylon (transformed) hit test results are available
  144422. */
  144423. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144424. /**
  144425. * Use this to temporarily pause hit test checks.
  144426. */
  144427. paused: boolean;
  144428. /**
  144429. * Creates a new instance of the hit test feature
  144430. * @param _xrSessionManager an instance of WebXRSessionManager
  144431. * @param options options to use when constructing this feature
  144432. */
  144433. constructor(_xrSessionManager: WebXRSessionManager,
  144434. /**
  144435. * options to use when constructing this feature
  144436. */
  144437. options?: IWebXRHitTestOptions);
  144438. /**
  144439. * attach this feature
  144440. * Will usually be called by the features manager
  144441. *
  144442. * @returns true if successful.
  144443. */
  144444. attach(): boolean;
  144445. /**
  144446. * detach this feature.
  144447. * Will usually be called by the features manager
  144448. *
  144449. * @returns true if successful.
  144450. */
  144451. detach(): boolean;
  144452. /**
  144453. * Dispose this feature and all of the resources attached
  144454. */
  144455. dispose(): void;
  144456. protected _onXRFrame(frame: XRFrame): void;
  144457. private _processWebXRHitTestResult;
  144458. }
  144459. }
  144460. declare module BABYLON {
  144461. /**
  144462. * The motion controller class for all microsoft mixed reality controllers
  144463. */
  144464. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144465. protected readonly _mapping: {
  144466. defaultButton: {
  144467. valueNodeName: string;
  144468. unpressedNodeName: string;
  144469. pressedNodeName: string;
  144470. };
  144471. defaultAxis: {
  144472. valueNodeName: string;
  144473. minNodeName: string;
  144474. maxNodeName: string;
  144475. };
  144476. buttons: {
  144477. "xr-standard-trigger": {
  144478. rootNodeName: string;
  144479. componentProperty: string;
  144480. states: string[];
  144481. };
  144482. "xr-standard-squeeze": {
  144483. rootNodeName: string;
  144484. componentProperty: string;
  144485. states: string[];
  144486. };
  144487. "xr-standard-touchpad": {
  144488. rootNodeName: string;
  144489. labelAnchorNodeName: string;
  144490. touchPointNodeName: string;
  144491. };
  144492. "xr-standard-thumbstick": {
  144493. rootNodeName: string;
  144494. componentProperty: string;
  144495. states: string[];
  144496. };
  144497. };
  144498. axes: {
  144499. "xr-standard-touchpad": {
  144500. "x-axis": {
  144501. rootNodeName: string;
  144502. };
  144503. "y-axis": {
  144504. rootNodeName: string;
  144505. };
  144506. };
  144507. "xr-standard-thumbstick": {
  144508. "x-axis": {
  144509. rootNodeName: string;
  144510. };
  144511. "y-axis": {
  144512. rootNodeName: string;
  144513. };
  144514. };
  144515. };
  144516. };
  144517. /**
  144518. * The base url used to load the left and right controller models
  144519. */
  144520. static MODEL_BASE_URL: string;
  144521. /**
  144522. * The name of the left controller model file
  144523. */
  144524. static MODEL_LEFT_FILENAME: string;
  144525. /**
  144526. * The name of the right controller model file
  144527. */
  144528. static MODEL_RIGHT_FILENAME: string;
  144529. profileId: string;
  144530. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144531. protected _getFilenameAndPath(): {
  144532. filename: string;
  144533. path: string;
  144534. };
  144535. protected _getModelLoadingConstraints(): boolean;
  144536. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144537. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144538. protected _updateModel(): void;
  144539. }
  144540. }
  144541. declare module BABYLON {
  144542. /**
  144543. * The motion controller class for oculus touch (quest, rift).
  144544. * This class supports legacy mapping as well the standard xr mapping
  144545. */
  144546. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144547. private _forceLegacyControllers;
  144548. private _modelRootNode;
  144549. /**
  144550. * The base url used to load the left and right controller models
  144551. */
  144552. static MODEL_BASE_URL: string;
  144553. /**
  144554. * The name of the left controller model file
  144555. */
  144556. static MODEL_LEFT_FILENAME: string;
  144557. /**
  144558. * The name of the right controller model file
  144559. */
  144560. static MODEL_RIGHT_FILENAME: string;
  144561. /**
  144562. * Base Url for the Quest controller model.
  144563. */
  144564. static QUEST_MODEL_BASE_URL: string;
  144565. profileId: string;
  144566. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144567. protected _getFilenameAndPath(): {
  144568. filename: string;
  144569. path: string;
  144570. };
  144571. protected _getModelLoadingConstraints(): boolean;
  144572. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144573. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144574. protected _updateModel(): void;
  144575. /**
  144576. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144577. * between the touch and touch 2.
  144578. */
  144579. private _isQuest;
  144580. }
  144581. }
  144582. declare module BABYLON {
  144583. /**
  144584. * The motion controller class for the standard HTC-Vive controllers
  144585. */
  144586. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144587. private _modelRootNode;
  144588. /**
  144589. * The base url used to load the left and right controller models
  144590. */
  144591. static MODEL_BASE_URL: string;
  144592. /**
  144593. * File name for the controller model.
  144594. */
  144595. static MODEL_FILENAME: string;
  144596. profileId: string;
  144597. /**
  144598. * Create a new Vive motion controller object
  144599. * @param scene the scene to use to create this controller
  144600. * @param gamepadObject the corresponding gamepad object
  144601. * @param handness the handness of the controller
  144602. */
  144603. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144604. protected _getFilenameAndPath(): {
  144605. filename: string;
  144606. path: string;
  144607. };
  144608. protected _getModelLoadingConstraints(): boolean;
  144609. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144610. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144611. protected _updateModel(): void;
  144612. }
  144613. }
  144614. declare module BABYLON {
  144615. /**
  144616. * A cursor which tracks a point on a path
  144617. */
  144618. export class PathCursor {
  144619. private path;
  144620. /**
  144621. * Stores path cursor callbacks for when an onchange event is triggered
  144622. */
  144623. private _onchange;
  144624. /**
  144625. * The value of the path cursor
  144626. */
  144627. value: number;
  144628. /**
  144629. * The animation array of the path cursor
  144630. */
  144631. animations: Animation[];
  144632. /**
  144633. * Initializes the path cursor
  144634. * @param path The path to track
  144635. */
  144636. constructor(path: Path2);
  144637. /**
  144638. * Gets the cursor point on the path
  144639. * @returns A point on the path cursor at the cursor location
  144640. */
  144641. getPoint(): Vector3;
  144642. /**
  144643. * Moves the cursor ahead by the step amount
  144644. * @param step The amount to move the cursor forward
  144645. * @returns This path cursor
  144646. */
  144647. moveAhead(step?: number): PathCursor;
  144648. /**
  144649. * Moves the cursor behind by the step amount
  144650. * @param step The amount to move the cursor back
  144651. * @returns This path cursor
  144652. */
  144653. moveBack(step?: number): PathCursor;
  144654. /**
  144655. * Moves the cursor by the step amount
  144656. * If the step amount is greater than one, an exception is thrown
  144657. * @param step The amount to move the cursor
  144658. * @returns This path cursor
  144659. */
  144660. move(step: number): PathCursor;
  144661. /**
  144662. * Ensures that the value is limited between zero and one
  144663. * @returns This path cursor
  144664. */
  144665. private ensureLimits;
  144666. /**
  144667. * Runs onchange callbacks on change (used by the animation engine)
  144668. * @returns This path cursor
  144669. */
  144670. private raiseOnChange;
  144671. /**
  144672. * Executes a function on change
  144673. * @param f A path cursor onchange callback
  144674. * @returns This path cursor
  144675. */
  144676. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144677. }
  144678. }
  144679. declare module BABYLON {
  144680. /** @hidden */
  144681. export var blurPixelShader: {
  144682. name: string;
  144683. shader: string;
  144684. };
  144685. }
  144686. declare module BABYLON {
  144687. /** @hidden */
  144688. export var pointCloudVertexDeclaration: {
  144689. name: string;
  144690. shader: string;
  144691. };
  144692. }
  144693. // Mixins
  144694. interface Window {
  144695. mozIndexedDB: IDBFactory;
  144696. webkitIndexedDB: IDBFactory;
  144697. msIndexedDB: IDBFactory;
  144698. webkitURL: typeof URL;
  144699. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144700. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144701. WebGLRenderingContext: WebGLRenderingContext;
  144702. MSGesture: MSGesture;
  144703. CANNON: any;
  144704. AudioContext: AudioContext;
  144705. webkitAudioContext: AudioContext;
  144706. PointerEvent: any;
  144707. Math: Math;
  144708. Uint8Array: Uint8ArrayConstructor;
  144709. Float32Array: Float32ArrayConstructor;
  144710. mozURL: typeof URL;
  144711. msURL: typeof URL;
  144712. VRFrameData: any; // WebVR, from specs 1.1
  144713. DracoDecoderModule: any;
  144714. setImmediate(handler: (...args: any[]) => void): number;
  144715. }
  144716. interface HTMLCanvasElement {
  144717. requestPointerLock(): void;
  144718. msRequestPointerLock?(): void;
  144719. mozRequestPointerLock?(): void;
  144720. webkitRequestPointerLock?(): void;
  144721. /** Track wether a record is in progress */
  144722. isRecording: boolean;
  144723. /** Capture Stream method defined by some browsers */
  144724. captureStream(fps?: number): MediaStream;
  144725. }
  144726. interface CanvasRenderingContext2D {
  144727. msImageSmoothingEnabled: boolean;
  144728. }
  144729. interface MouseEvent {
  144730. mozMovementX: number;
  144731. mozMovementY: number;
  144732. webkitMovementX: number;
  144733. webkitMovementY: number;
  144734. msMovementX: number;
  144735. msMovementY: number;
  144736. }
  144737. interface Navigator {
  144738. mozGetVRDevices: (any: any) => any;
  144739. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144740. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144741. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144742. webkitGetGamepads(): Gamepad[];
  144743. msGetGamepads(): Gamepad[];
  144744. webkitGamepads(): Gamepad[];
  144745. }
  144746. interface HTMLVideoElement {
  144747. mozSrcObject: any;
  144748. }
  144749. interface Math {
  144750. fround(x: number): number;
  144751. imul(a: number, b: number): number;
  144752. }
  144753. interface WebGLRenderingContext {
  144754. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144755. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144756. vertexAttribDivisor(index: number, divisor: number): void;
  144757. createVertexArray(): any;
  144758. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144759. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144760. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144761. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144762. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144763. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144764. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144765. // Queries
  144766. createQuery(): WebGLQuery;
  144767. deleteQuery(query: WebGLQuery): void;
  144768. beginQuery(target: number, query: WebGLQuery): void;
  144769. endQuery(target: number): void;
  144770. getQueryParameter(query: WebGLQuery, pname: number): any;
  144771. getQuery(target: number, pname: number): any;
  144772. MAX_SAMPLES: number;
  144773. RGBA8: number;
  144774. READ_FRAMEBUFFER: number;
  144775. DRAW_FRAMEBUFFER: number;
  144776. UNIFORM_BUFFER: number;
  144777. HALF_FLOAT_OES: number;
  144778. RGBA16F: number;
  144779. RGBA32F: number;
  144780. R32F: number;
  144781. RG32F: number;
  144782. RGB32F: number;
  144783. R16F: number;
  144784. RG16F: number;
  144785. RGB16F: number;
  144786. RED: number;
  144787. RG: number;
  144788. R8: number;
  144789. RG8: number;
  144790. UNSIGNED_INT_24_8: number;
  144791. DEPTH24_STENCIL8: number;
  144792. MIN: number;
  144793. MAX: number;
  144794. /* Multiple Render Targets */
  144795. drawBuffers(buffers: number[]): void;
  144796. readBuffer(src: number): void;
  144797. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144798. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144799. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144800. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144801. // Occlusion Query
  144802. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144803. ANY_SAMPLES_PASSED: number;
  144804. QUERY_RESULT_AVAILABLE: number;
  144805. QUERY_RESULT: number;
  144806. }
  144807. interface WebGLProgram {
  144808. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144809. }
  144810. interface EXT_disjoint_timer_query {
  144811. QUERY_COUNTER_BITS_EXT: number;
  144812. TIME_ELAPSED_EXT: number;
  144813. TIMESTAMP_EXT: number;
  144814. GPU_DISJOINT_EXT: number;
  144815. QUERY_RESULT_EXT: number;
  144816. QUERY_RESULT_AVAILABLE_EXT: number;
  144817. queryCounterEXT(query: WebGLQuery, target: number): void;
  144818. createQueryEXT(): WebGLQuery;
  144819. beginQueryEXT(target: number, query: WebGLQuery): void;
  144820. endQueryEXT(target: number): void;
  144821. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144822. deleteQueryEXT(query: WebGLQuery): void;
  144823. }
  144824. interface WebGLUniformLocation {
  144825. _currentState: any;
  144826. }
  144827. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144828. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144829. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144830. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144831. interface WebGLRenderingContext {
  144832. readonly RASTERIZER_DISCARD: number;
  144833. readonly DEPTH_COMPONENT24: number;
  144834. readonly TEXTURE_3D: number;
  144835. readonly TEXTURE_2D_ARRAY: number;
  144836. readonly TEXTURE_COMPARE_FUNC: number;
  144837. readonly TEXTURE_COMPARE_MODE: number;
  144838. readonly COMPARE_REF_TO_TEXTURE: number;
  144839. readonly TEXTURE_WRAP_R: number;
  144840. readonly HALF_FLOAT: number;
  144841. readonly RGB8: number;
  144842. readonly RED_INTEGER: number;
  144843. readonly RG_INTEGER: number;
  144844. readonly RGB_INTEGER: number;
  144845. readonly RGBA_INTEGER: number;
  144846. readonly R8_SNORM: number;
  144847. readonly RG8_SNORM: number;
  144848. readonly RGB8_SNORM: number;
  144849. readonly RGBA8_SNORM: number;
  144850. readonly R8I: number;
  144851. readonly RG8I: number;
  144852. readonly RGB8I: number;
  144853. readonly RGBA8I: number;
  144854. readonly R8UI: number;
  144855. readonly RG8UI: number;
  144856. readonly RGB8UI: number;
  144857. readonly RGBA8UI: number;
  144858. readonly R16I: number;
  144859. readonly RG16I: number;
  144860. readonly RGB16I: number;
  144861. readonly RGBA16I: number;
  144862. readonly R16UI: number;
  144863. readonly RG16UI: number;
  144864. readonly RGB16UI: number;
  144865. readonly RGBA16UI: number;
  144866. readonly R32I: number;
  144867. readonly RG32I: number;
  144868. readonly RGB32I: number;
  144869. readonly RGBA32I: number;
  144870. readonly R32UI: number;
  144871. readonly RG32UI: number;
  144872. readonly RGB32UI: number;
  144873. readonly RGBA32UI: number;
  144874. readonly RGB10_A2UI: number;
  144875. readonly R11F_G11F_B10F: number;
  144876. readonly RGB9_E5: number;
  144877. readonly RGB10_A2: number;
  144878. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144879. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144880. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144881. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144882. readonly DEPTH_COMPONENT32F: number;
  144883. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144884. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144885. 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;
  144886. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144887. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144888. readonly TRANSFORM_FEEDBACK: number;
  144889. readonly INTERLEAVED_ATTRIBS: number;
  144890. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144891. createTransformFeedback(): WebGLTransformFeedback;
  144892. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144893. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144894. beginTransformFeedback(primitiveMode: number): void;
  144895. endTransformFeedback(): void;
  144896. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144897. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144898. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144899. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144900. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144901. }
  144902. interface ImageBitmap {
  144903. readonly width: number;
  144904. readonly height: number;
  144905. close(): void;
  144906. }
  144907. interface WebGLQuery extends WebGLObject {
  144908. }
  144909. declare var WebGLQuery: {
  144910. prototype: WebGLQuery;
  144911. new(): WebGLQuery;
  144912. };
  144913. interface WebGLSampler extends WebGLObject {
  144914. }
  144915. declare var WebGLSampler: {
  144916. prototype: WebGLSampler;
  144917. new(): WebGLSampler;
  144918. };
  144919. interface WebGLSync extends WebGLObject {
  144920. }
  144921. declare var WebGLSync: {
  144922. prototype: WebGLSync;
  144923. new(): WebGLSync;
  144924. };
  144925. interface WebGLTransformFeedback extends WebGLObject {
  144926. }
  144927. declare var WebGLTransformFeedback: {
  144928. prototype: WebGLTransformFeedback;
  144929. new(): WebGLTransformFeedback;
  144930. };
  144931. interface WebGLVertexArrayObject extends WebGLObject {
  144932. }
  144933. declare var WebGLVertexArrayObject: {
  144934. prototype: WebGLVertexArrayObject;
  144935. new(): WebGLVertexArrayObject;
  144936. };
  144937. // Type definitions for WebVR API
  144938. // Project: https://w3c.github.io/webvr/
  144939. // Definitions by: six a <https://github.com/lostfictions>
  144940. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144941. interface VRDisplay extends EventTarget {
  144942. /**
  144943. * Dictionary of capabilities describing the VRDisplay.
  144944. */
  144945. readonly capabilities: VRDisplayCapabilities;
  144946. /**
  144947. * z-depth defining the far plane of the eye view frustum
  144948. * enables mapping of values in the render target depth
  144949. * attachment to scene coordinates. Initially set to 10000.0.
  144950. */
  144951. depthFar: number;
  144952. /**
  144953. * z-depth defining the near plane of the eye view frustum
  144954. * enables mapping of values in the render target depth
  144955. * attachment to scene coordinates. Initially set to 0.01.
  144956. */
  144957. depthNear: number;
  144958. /**
  144959. * An identifier for this distinct VRDisplay. Used as an
  144960. * association point in the Gamepad API.
  144961. */
  144962. readonly displayId: number;
  144963. /**
  144964. * A display name, a user-readable name identifying it.
  144965. */
  144966. readonly displayName: string;
  144967. readonly isConnected: boolean;
  144968. readonly isPresenting: boolean;
  144969. /**
  144970. * If this VRDisplay supports room-scale experiences, the optional
  144971. * stage attribute contains details on the room-scale parameters.
  144972. */
  144973. readonly stageParameters: VRStageParameters | null;
  144974. /**
  144975. * Passing the value returned by `requestAnimationFrame` to
  144976. * `cancelAnimationFrame` will unregister the callback.
  144977. * @param handle Define the hanle of the request to cancel
  144978. */
  144979. cancelAnimationFrame(handle: number): void;
  144980. /**
  144981. * Stops presenting to the VRDisplay.
  144982. * @returns a promise to know when it stopped
  144983. */
  144984. exitPresent(): Promise<void>;
  144985. /**
  144986. * Return the current VREyeParameters for the given eye.
  144987. * @param whichEye Define the eye we want the parameter for
  144988. * @returns the eye parameters
  144989. */
  144990. getEyeParameters(whichEye: string): VREyeParameters;
  144991. /**
  144992. * Populates the passed VRFrameData with the information required to render
  144993. * the current frame.
  144994. * @param frameData Define the data structure to populate
  144995. * @returns true if ok otherwise false
  144996. */
  144997. getFrameData(frameData: VRFrameData): boolean;
  144998. /**
  144999. * Get the layers currently being presented.
  145000. * @returns the list of VR layers
  145001. */
  145002. getLayers(): VRLayer[];
  145003. /**
  145004. * Return a VRPose containing the future predicted pose of the VRDisplay
  145005. * when the current frame will be presented. The value returned will not
  145006. * change until JavaScript has returned control to the browser.
  145007. *
  145008. * The VRPose will contain the position, orientation, velocity,
  145009. * and acceleration of each of these properties.
  145010. * @returns the pose object
  145011. */
  145012. getPose(): VRPose;
  145013. /**
  145014. * Return the current instantaneous pose of the VRDisplay, with no
  145015. * prediction applied.
  145016. * @returns the current instantaneous pose
  145017. */
  145018. getImmediatePose(): VRPose;
  145019. /**
  145020. * The callback passed to `requestAnimationFrame` will be called
  145021. * any time a new frame should be rendered. When the VRDisplay is
  145022. * presenting the callback will be called at the native refresh
  145023. * rate of the HMD. When not presenting this function acts
  145024. * identically to how window.requestAnimationFrame acts. Content should
  145025. * make no assumptions of frame rate or vsync behavior as the HMD runs
  145026. * asynchronously from other displays and at differing refresh rates.
  145027. * @param callback Define the eaction to run next frame
  145028. * @returns the request handle it
  145029. */
  145030. requestAnimationFrame(callback: FrameRequestCallback): number;
  145031. /**
  145032. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  145033. * Repeat calls while already presenting will update the VRLayers being displayed.
  145034. * @param layers Define the list of layer to present
  145035. * @returns a promise to know when the request has been fulfilled
  145036. */
  145037. requestPresent(layers: VRLayer[]): Promise<void>;
  145038. /**
  145039. * Reset the pose for this display, treating its current position and
  145040. * orientation as the "origin/zero" values. VRPose.position,
  145041. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  145042. * updated when calling resetPose(). This should be called in only
  145043. * sitting-space experiences.
  145044. */
  145045. resetPose(): void;
  145046. /**
  145047. * The VRLayer provided to the VRDisplay will be captured and presented
  145048. * in the HMD. Calling this function has the same effect on the source
  145049. * canvas as any other operation that uses its source image, and canvases
  145050. * created without preserveDrawingBuffer set to true will be cleared.
  145051. * @param pose Define the pose to submit
  145052. */
  145053. submitFrame(pose?: VRPose): void;
  145054. }
  145055. declare var VRDisplay: {
  145056. prototype: VRDisplay;
  145057. new(): VRDisplay;
  145058. };
  145059. interface VRLayer {
  145060. leftBounds?: number[] | Float32Array | null;
  145061. rightBounds?: number[] | Float32Array | null;
  145062. source?: HTMLCanvasElement | null;
  145063. }
  145064. interface VRDisplayCapabilities {
  145065. readonly canPresent: boolean;
  145066. readonly hasExternalDisplay: boolean;
  145067. readonly hasOrientation: boolean;
  145068. readonly hasPosition: boolean;
  145069. readonly maxLayers: number;
  145070. }
  145071. interface VREyeParameters {
  145072. /** @deprecated */
  145073. readonly fieldOfView: VRFieldOfView;
  145074. readonly offset: Float32Array;
  145075. readonly renderHeight: number;
  145076. readonly renderWidth: number;
  145077. }
  145078. interface VRFieldOfView {
  145079. readonly downDegrees: number;
  145080. readonly leftDegrees: number;
  145081. readonly rightDegrees: number;
  145082. readonly upDegrees: number;
  145083. }
  145084. interface VRFrameData {
  145085. readonly leftProjectionMatrix: Float32Array;
  145086. readonly leftViewMatrix: Float32Array;
  145087. readonly pose: VRPose;
  145088. readonly rightProjectionMatrix: Float32Array;
  145089. readonly rightViewMatrix: Float32Array;
  145090. readonly timestamp: number;
  145091. }
  145092. interface VRPose {
  145093. readonly angularAcceleration: Float32Array | null;
  145094. readonly angularVelocity: Float32Array | null;
  145095. readonly linearAcceleration: Float32Array | null;
  145096. readonly linearVelocity: Float32Array | null;
  145097. readonly orientation: Float32Array | null;
  145098. readonly position: Float32Array | null;
  145099. readonly timestamp: number;
  145100. }
  145101. interface VRStageParameters {
  145102. sittingToStandingTransform?: Float32Array;
  145103. sizeX?: number;
  145104. sizeY?: number;
  145105. }
  145106. interface Navigator {
  145107. getVRDisplays(): Promise<VRDisplay[]>;
  145108. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145109. }
  145110. interface Window {
  145111. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145112. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145113. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145114. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145115. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145116. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145117. }
  145118. interface Gamepad {
  145119. readonly displayId: number;
  145120. }
  145121. type XRSessionMode =
  145122. | "inline"
  145123. | "immersive-vr"
  145124. | "immersive-ar";
  145125. type XRReferenceSpaceType =
  145126. | "viewer"
  145127. | "local"
  145128. | "local-floor"
  145129. | "bounded-floor"
  145130. | "unbounded";
  145131. type XREnvironmentBlendMode =
  145132. | "opaque"
  145133. | "additive"
  145134. | "alpha-blend";
  145135. type XRVisibilityState =
  145136. | "visible"
  145137. | "visible-blurred"
  145138. | "hidden";
  145139. type XRHandedness =
  145140. | "none"
  145141. | "left"
  145142. | "right";
  145143. type XRTargetRayMode =
  145144. | "gaze"
  145145. | "tracked-pointer"
  145146. | "screen";
  145147. type XREye =
  145148. | "none"
  145149. | "left"
  145150. | "right";
  145151. interface XRSpace extends EventTarget {
  145152. }
  145153. interface XRRenderState {
  145154. depthNear?: number;
  145155. depthFar?: number;
  145156. inlineVerticalFieldOfView?: number;
  145157. baseLayer?: XRWebGLLayer;
  145158. }
  145159. interface XRInputSource {
  145160. handedness: XRHandedness;
  145161. targetRayMode: XRTargetRayMode;
  145162. targetRaySpace: XRSpace;
  145163. gripSpace: XRSpace | undefined;
  145164. gamepad: Gamepad | undefined;
  145165. profiles: Array<string>;
  145166. }
  145167. interface XRSessionInit {
  145168. optionalFeatures?: XRReferenceSpaceType[];
  145169. requiredFeatures?: XRReferenceSpaceType[];
  145170. }
  145171. interface XRSession extends XRAnchorCreator {
  145172. addEventListener: Function;
  145173. removeEventListener: Function;
  145174. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145175. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145176. requestAnimationFrame: Function;
  145177. end(): Promise<void>;
  145178. renderState: XRRenderState;
  145179. inputSources: Array<XRInputSource>;
  145180. // hit test
  145181. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145182. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145183. // legacy AR hit test
  145184. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145185. // legacy plane detection
  145186. updateWorldTrackingState(options: {
  145187. planeDetectionState?: { enabled: boolean; }
  145188. }): void;
  145189. }
  145190. interface XRReferenceSpace extends XRSpace {
  145191. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145192. onreset: any;
  145193. }
  145194. type XRPlaneSet = Set<XRPlane>;
  145195. type XRAnchorSet = Set<XRAnchor>;
  145196. interface XRFrame {
  145197. session: XRSession;
  145198. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145199. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145200. // AR
  145201. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145202. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145203. // Anchors
  145204. trackedAnchors?: XRAnchorSet;
  145205. // Planes
  145206. worldInformation: {
  145207. detectedPlanes?: XRPlaneSet;
  145208. };
  145209. }
  145210. interface XRViewerPose extends XRPose {
  145211. views: Array<XRView>;
  145212. }
  145213. interface XRPose {
  145214. transform: XRRigidTransform;
  145215. emulatedPosition: boolean;
  145216. }
  145217. interface XRWebGLLayerOptions {
  145218. antialias?: boolean;
  145219. depth?: boolean;
  145220. stencil?: boolean;
  145221. alpha?: boolean;
  145222. multiview?: boolean;
  145223. framebufferScaleFactor?: number;
  145224. }
  145225. declare var XRWebGLLayer: {
  145226. prototype: XRWebGLLayer;
  145227. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145228. };
  145229. interface XRWebGLLayer {
  145230. framebuffer: WebGLFramebuffer;
  145231. framebufferWidth: number;
  145232. framebufferHeight: number;
  145233. getViewport: Function;
  145234. }
  145235. declare class XRRigidTransform {
  145236. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145237. position: DOMPointReadOnly;
  145238. orientation: DOMPointReadOnly;
  145239. matrix: Float32Array;
  145240. inverse: XRRigidTransform;
  145241. }
  145242. interface XRView {
  145243. eye: XREye;
  145244. projectionMatrix: Float32Array;
  145245. transform: XRRigidTransform;
  145246. }
  145247. interface XRInputSourceChangeEvent {
  145248. session: XRSession;
  145249. removed: Array<XRInputSource>;
  145250. added: Array<XRInputSource>;
  145251. }
  145252. interface XRInputSourceEvent extends Event {
  145253. readonly frame: XRFrame;
  145254. readonly inputSource: XRInputSource;
  145255. }
  145256. // Experimental(er) features
  145257. declare class XRRay {
  145258. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145259. origin: DOMPointReadOnly;
  145260. direction: DOMPointReadOnly;
  145261. matrix: Float32Array;
  145262. }
  145263. declare enum XRHitTestTrackableType {
  145264. "point",
  145265. "plane"
  145266. }
  145267. interface XRHitResult {
  145268. hitMatrix: Float32Array;
  145269. }
  145270. interface XRTransientInputHitTestResult {
  145271. readonly inputSource: XRInputSource;
  145272. readonly results: Array<XRHitTestResult>;
  145273. }
  145274. interface XRHitTestResult {
  145275. getPose(baseSpace: XRSpace): XRPose | undefined;
  145276. }
  145277. interface XRHitTestSource {
  145278. cancel(): void;
  145279. }
  145280. interface XRTransientInputHitTestSource {
  145281. cancel(): void;
  145282. }
  145283. interface XRHitTestOptionsInit {
  145284. space: XRSpace;
  145285. entityTypes?: Array<XRHitTestTrackableType>;
  145286. offsetRay?: XRRay;
  145287. }
  145288. interface XRTransientInputHitTestOptionsInit {
  145289. profile: string;
  145290. entityTypes?: Array<XRHitTestTrackableType>;
  145291. offsetRay?: XRRay;
  145292. }
  145293. interface XRAnchor {
  145294. // remove?
  145295. id?: string;
  145296. anchorSpace: XRSpace;
  145297. lastChangedTime: number;
  145298. detach(): void;
  145299. }
  145300. interface XRPlane extends XRAnchorCreator {
  145301. orientation: "Horizontal" | "Vertical";
  145302. planeSpace: XRSpace;
  145303. polygon: Array<DOMPointReadOnly>;
  145304. lastChangedTime: number;
  145305. }
  145306. interface XRAnchorCreator {
  145307. // AR Anchors
  145308. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145309. }